Tag Archive for 'GIS'

Quantum GIS and Homebrew, Pt. 1

A few weeks ago I decided to give Homebrew as package manager a try and move some of my projects to Mac OS X as development platform. Until now I really liked the advantages of using Ubuntu as virtual machine, have development dependencies separated from my day-to-day system, safely try stuff out and be able to rollback to a snapshot if something goes terribly wrong. Sharing hardware resources is obviously the drawback of given setup, which basically made me think about alternatives.

Homebrew is great so far: very easy to setup, integrates well with Mac OS X, large repository and a great “Formula” system to add your own packages.

When it comes to GIS applications and libraries on Mac OS X, William Kyngesburye’s site is one of the best resources you’ll find out there. I used his’ downloads quite a bit. But with the move to Homebrew, I also had the intention to manage my GIS packages with it. Although Homebrew doesn’t provide user friendly double-click-to-install packages, like William does, its Terminal commands are simple enough:

$ brew install mypackage

Drawback of having Homebrew manage my GIS dependencies was, as I noticed immediately, that William’s Quantum GIS package didn’t work any longer. So I decided to build Quantum GIS on my own, from source, against dependencies managed by Homebrew. The entire build process is very well documented on QGIS’s wiki. Using Homebrew for getting all dependencies is as simple as:

$ brew install python --framework --universal
$ brew install postgis qt gdal geos proj \
sqlite libspatialite libiconv gsl pyqt qwt cmake

I edited the existing SIP-Formula slightly (added a “–universal” option) to meet QGIS’ requirements on Mac OS X.

$ brew install sip --universal

Next step is to configure and make QGIS. Some paths and libs weren’t found automatically by cmake, so I had to specify them:

$ cmake -D CMAKE_INSTALL_PREFIX=~/Applications \
-D CMAKE_BUILD_TYPE=Release \
-D CMAKE_BUILD_TYPE=MinSizeRel \
-D WITH_INTERNAL_SPATIALITE=TRUE \
-D QWT_LIBRARY=/usr/local/lib/libqwt.dylib \
-D QWT_INCLUDE_DIR=/usr/local/include \
-D GEOS_INCLUDE_DIR=/usr/local/include \
-D GEOS_LIBRARY=/usr/local/lib/libgeos_c.dylib \
-D GDAL_INCLUDE_DIR=/usr/local/include \
-D GDAL_LIBRARY=/usr/local/lib/libgdal.dylib \
-D GSL_INCLUDE_DIR=/usr/local/include \
-D GSL_LIBRARIES=/usr/local/lib/libgsl.dylib \
-D POSTGRES_INCLUDE_DIR=/usr/local/include \
-D POSTGRES_LIBRARY=/usr/local/lib/libpq.dylib \
-D PYTHON_EXECUTABLE=/usr/local/bin/python2.7 \
..
$ make
$ make install

…produces the QGIS.app in your ~/Applications folder.

The Homebrew Formula for QGIS that I’ve started, doesn’t make a successful QGIS build yet. It fails somewhere at

Linking CXX shared library libqgis_analysis.dylib
[ 33%] Built target qgis_analysis
make: *** [all] Error 2

…although Homebrew is basically building against the same dependencies as my “manual” steps did – working on it.

So far so good. However, the bad news, maybe just in my case, is that QGIS seems to be linked to Mac OS 10.6 original Python version 2.6.1 and throws following error at startup:

Couldn’t load SIP module. (note: SIP is installed in /usr/local/bin)
Python support will be disabled.

Traceback (most recent call last):
File “”, line 1, in
ImportError: No module named sip

Python version:
2.6.1 (r261:67515, Jun 24 2010, 21:47:49)
[GCC 4.2.1 (Apple Inc. build 5646)]

Major downer here is the second line, “disabled Python”, which means most plugins won’t work. This is major since one of Quantum GIS’ strength is its plugin-architecture.

To be continued…

Topology rules with GeoDjango

I’m still very new to GeoDjango and the Django world in general, but I have to say that, based on what I’ve seen so far, I’m very impressed by how easy, fast and clean you can build powerful geographic web applications with it.

Django 1.2 is the current version and one thing that caught my eye in the release notes was Model validation. Among other benefits, model validation allows you to “perform custom validation on your Model” everytime a user wants to save data through a ModelForm. Translated to GeoDjango, that basically means that one can access the unleashed power of PostGIS (or the functionality of your supported geo-database of choice) to validate geometries and provide feedback for users through a nice web interface. Best part of it: it’s all done only by a few lines of additional code in your data model.

I’m not going into much detail how Django’s model validation works, you should check out the documentation if you’re interested, but here’s a quick example of creating something like a simple topology rule with GeoDjango:

Let’s say I have users entering and modifying point data and need to make sure that each point falls inside a polygon from another layer.

# models.py
from django.contrib.gis.db import models
from django.core.exceptions import ValidationError

class Poly(models.Model):
	geometry = models.PolygonField()
	objects = models.GeoManager()

class Point(models.Model):
	geometry = models.PointField()
	objects = models.GeoManager()

	# simple topology rule
	def clean(self):
		# find Polys that contain the Point
		pq = Poly.objects.filter(geometry__contains=self.geometry)
		if not pq: # no Poly has been found
			raise ValidationError('Point is not within a Poly.')

That’s it. You only need to add a custom clean() method and put your validation rules there. Those few lines of additional code check if the new point falls inside a polygon and tell the user if it’s not through the Django admin interface.

GeoDjango Model Validation

I’ve posted the project on bitbucket if you want to give it a shot. Add a little more PostGIS extravaganza and you can have a pretty sophisticated set of topology rules in your web application, bundled with the great capabilities Django apps offer.

Wrapping up Gov 2.0 Camp New England

Gov 2.0 Camp New EnglandI had a fantastic time yesterday at Gov 2.0 Camp New England and enjoyed the event a lot. In particular I was very impressed by the interest of the public sector. I wouldn’t say it’s typical that an event, held on a Saturday, which happens to be the first nice spring day in Boston, attracts so many government employees, ranging from the governor’s office to local town administrations, and affiliated organizations. Throughout the event you could feel the commitment to work on better and more inclusive governance at all levels.

My personal highlight was the first session I attended, about Open 311. It’s clearly not my core area, but I’m interested in the current development and felt that I learned a lot in that session. One of the most interesting points during the discussion was the evaluation of “Resistat”. Resistat is an initiative to include residents in 311 statistics in Somerville. It works very simple: a mailing-list facilitates communication and statistics and results are sent out to residents as powerpoint files. Not rocket science, but it’s enough communication technology that even though only about 25% of involved residents have been to in-person meetings, 85% of them say that they feel better engaged with their local government (by sending powerpoints to a mailing list, it’s as simple as that!). Anyway, great insights when talking about the “town hall meeting divide”, can’t wait to read the entire study about the program.

Our session about Open Data Strategies was “merged” together with I think 5 other sessions that had the word “data” in the title. Unfortunately it didn’t really work out as we intended it and the discussion went somehow all over the place. Better luck next time I guess.

The last session I picked was all about data visualization. Two young IBM researchers showed and demoed amazing data visualization tools – Many Eyes and sense.us among them. Their latest project, called “IBM Visual Bill explorer”, should make it easy for citizens to visually explore and analyze legal texts. Tremendously valuable when trying to understand or to find potential pitfalls in 1000+ pages documents written by lawyers, as bills usually are.

On a side note: I had absolutely no idea that IBM is running such a great research department. Where are marketing departments when you really need them?

Happy hour – free beer was involved – went straight to talking GIS and Open Source. As it turned out, there are very similar problems across gov agencies (surprising, huh!). One notion during the discussion was, that, instead of throwing money individually at our problems, why not join forces and contribute to and customize Open Source projects where we all benefit from? Interesting thought, will be continued…

Heating up SVG

Last week I came over Raphaël, a great JavaScript library for vector graphics visualizations, and I started playing around with maps and SVG again. Long time no see!

To bring some map content from ArcMap to Raphaël I used the VBA Macro I wrote 4 years ago in ArcMap. It still does the job and gives me clean vector graphics the way I want them. I couldn’t find a decent SVG export option for QGIS, although there are some efforts to improve that kind of functionality.

AsSVG, a Python geoprocessing script for ArcGIS is pretty good too. It provides some nice export options, such as pick style and data attribute fields, and I actually ended up using it a lot.

However, it’s 2009 and there are other ways available for sharing code then just providing a plain text file. So I ended up wrapping a bitbucket repository around it. Just in case if somebody is interested in working on or improving the script…

OpenStreetMap as WMS

Another option to integrate rendered OpenStreetMap images in a GIS desktop client or web application is to add OpenStreetMap as OGC compliant Web Map Service. For the European continent such a service is now provided by the German WhereGroup.

The service is available as a free basic WMS (GetCapabilities), updated biannually, and two commercial versions, updated daily, for specific map customization needs and high performances.

OpenStreetMap is on the way to become a serious alternative map source in professional GIS environments. The question how the professional GIS community responds to Creative Commons licensing will surely open some interesting debates anytime soon.

OpenStreetMap in ArcMap

My favorite ArcMap extension Arc2Earth got updated and brings now rendered OpenStreetMap layers into ArcMap:

Previous versions supported map tile layers import from Virtual Earth, Yahoo! or Ask. Certainly a great feature which allows easy access to good and up-to-date base maps in many regions. The only problem is that without proper licensing it’s not possible to use them for commercial purposes. I’m not a lawyer, but as far as I understand the term commercial purpose, only loading and viewing those layers in ArcMap in a business environment (e.g. at the office) can already result in a license violation. Good license deals might not be such a problem at the enterprise level, for small businesses who need those maps here and there, it is quite often an issue.

Being able to load OpenStreetMap instead of Virtual Earth, etc. into ArcMap removes a lot of those licensing headaches.

OpenStreetMap data can be used freely under the terms of the Creative Commons Attribution-ShareAlike 2.0 license.

As long as attribution and share alike work for you, you can basically do whatever you want with OpenStreetMap in ArcMap – copy, distribute, print, derive, etc.

There is a long list of other new features and fixes that come with the latest release of Arc2Earth. OpenLayers as additional viewer for exported map tiles is one of those which caught my attention.

FOSS GIS sandbox

That’s what I actually had in mind: creating a local Sandbox in VMware for testing GeoServer in conjunction with other FOSS GIS software. As it turned out, it’s not necessary to set such a system up by myself. Ricardo Pinho did it already and made a VMware image already available:

GISVM is intended to be a full-feature GIS Workstation based exclusively on free GIS software: PostgreSQL, PostGIS, GeoServer, Mapserver, FWTools, QGIS/GRASS, gvSIG, uDIG and Kosmo, on Ubuntu Desktop.

Great work! Exactly what I wanted. It’s a huge time saver. GISVM gives you a feel what FOSS GIS software can do for you, without going through any installation and configuration hassles.

uDig accessing GeoServer WFS in GISVM

GISVM works well as sandbox in VMware Fusion (aff link) here on the MacBook (1 processor and 512MB RAM enabled) , although it asked for upgrading the image file and installing VMware Tools for better performance.

VMware Fusion

The OpenStreetMap Shapefiles

Yesterday, after reading the post about routeable OSM data, I discovered the download section of CloudMade. By country they offer OSM data in various file formats. Shapefile is one of them. I downloaded the Austrian OSM data as Shapefile (still, after decades, the unbeaten #1 file format when it comes to geodata interoperability btw). There are 3 filesets included: highways, POI and natural.

After loading them into QGIS and having a quick look at the data, I must say that I’m impressed by the data quality and level of detail. Recently I proposed that our public national mapping agency should support projects like OpenStreetMap and provide parts of their road network data to the OSM community. Hereby I take this proposal back, I should’ve had a look at recent OSM updates first. The OSM road network data is, after some initial checks, better than what I’ve seen so far from our national mapping agency for general mapping purposes.

Dear mapping agency,
I’m afraid some of your departments are obsolete by now. You simply missed the train. The community has taken over your job and does it with friendlier, and probably more sustainable, licensing.

What I’ve to figure out now is a simple process how to send data edits on the Shapefile back to the OSM database. There is a good chance that we, while using the data in projects, will work on and maybe improve attributes or features. A smart tool to bridge desktop GIS and the OSM database would be very helpful here.

Another thing is to create more awareness about CC licensing and what community based work means. I’m quite often confronted with share-unfriendly attitudes like “pull down what you can get but don’t give anything in return”. There is very little understanding that sharing your work and data, base data to build individual projects on, creates a bigger benefit for all parties. I guess it’s a relic of times where geodata has been the most precious treasure you had to hide…

A 3D-model for Salzburg

Autodesk and the Centre for Geoinformatics (Z_GIS) at Salzburg University announced today a cooperation on a Digital Cities research project. According to the press release, Salzburg will be the first city worldwide fully covered with such a 3D-model:

Imagine a combined digital ecosystem that can capture, analyze, and visualize projects on a city and regional scale—an open platform that supports secure and robust integration of CAD; building information modeling (BIM); and geospatial, simulation, and visualization data.

I don’t know the details of Autodesk’s Digital Cities, but as I read the short descriptions it’s aimed to become the Swiss army knife of city planning. Unlike so many other 3D-models, which look impressing at a first glance, Digital Cities doesn’t only scratch on a city’s surface but integrates all underlying information and data a city is built on. That’s truly an ambitious project. [via OTS]

In search of the point

What’s the point of having a national mapping agency when even semi-public agencies like our Umweltbundesamt (environmental agency) are doing data dissemination based on Google Maps and Geonames? [via joesonic]

Speaking of paleogeography is in that case certainly appropriate: neogeography makes the national mapping agency look like an endangered species. Even though I never really liked the terms and heated discussions about paleo- vs. neogeography. To me, paleogeography sounds way too negative for what it actually does. Paleogeography still provides a major part of the backend and a lot of necessary knowledge for the so called Geoweb. Period.

While neogeography is the cool thing. It’s fresh, slick, easy to use and attracts a lot of bright people outside the geography area who are doing amazing things with geographic information. Personally I see myself somewhere in between and try to get the best out of both.

Obviously some paleo organizations, like our national mapping agency is for instance, should look slightly to the left and to the right of their very straight path. It seems they are still serving the geo market of the last century. Their traditional products, like the topographic and cadastral maps, are certainly great and important works, but in the meantime they have to face the fact that the geo market has a little changed in the last couple of years.

Believe it or not, even in Austria there are map based businesses growing. Companies or start-ups who arrange their business models around easy and affordable access to local geographic information. Most of them depend on the goodwill of global players like Google or Microsoft. The EC usually is very quick when it comes to express concerns about monopolies of those companies and threaten them with law suits. I think, as for the geo market, the European mapping agencies have enough resources – in terms of geo data, infrastructure and knowledge – to throw into the game. They are powerful enough to compete with the big players, provide alternative map services and eventually support local economies. If they only wanted to.

Besides, the above mentioned example shows very well the benefits of neogeography for the public sector and that there is growing demand for such technologies.

So, again, where is the point of keeping a huge tax funded public body when it rejects to move on, serve current public needs, support local economies and public wealth?