Thoughts by Techxplorer

Thoughts on my experiences with technology

Converting Map Data into KML

By: Rebecca Dominguez

A important part of the AusStage Mapping Service is the ability to download maps in the Keyhole Markup Language (KML) format. It’s important as it allows our users to download an manipulate maps in software such as Google Earth which provide advanced functionality that we can’t provide in a web page. Some of the more exciting manipulations are those that mashup data from a variety of different sources.

So far the source that we’ve used the most is the Australian Bureau of Australia (ABS) 2006 Census data. Our researchers have indicated that this a rich dataset that when combined with data on events and venues held in the AusStage database can provide insights that weren’t possible before.

Using the census data to produce a mashup is only possible because the ABS released the Statistical Geography – Australian Standard Geographical Classification (ASGC), Digital Boundaries for 2006 as files available for download in the MapInfo Interchange Format under a permissive Creative Commons license.

Unfortunately this format isn’t supported by the tools that we have available to us, including the standard version of Google Earth, and so we need to convert them into something that is more appropriate. Our target format is KML as it works with all of our tools and as it uses XML can be edited with relative ease.

We’ve used a variety of tools and just recently I discovered the FWTools package and in particular the ogr2ogr application. Using this package is very easy and it supports a wide range of formats.

I used this application recently when I needed to start work on an overlay of the local government areas in the Northern Territory using the Australian Standard Geographical Classification (ASGC) Digital Boundaries (Intercensal), Australia for July 2009 dataset.

Once installed on my Ubuntu system, via the gdal-bin package, I was able to use a command like the one outlined below to extract the local government areas from the Northern Territory into a file in the KML format.

ogr2ogr -f "KML" -where "state_code_2009 = 7" nt-lga-prelim.kml LGA09aAust.mid

In the above example:

  • the -f switch specifies the output format as KML
  • The where switch uses a condition on the STATE_CODE_2009 data field specified in the dataset to 7 indicating the local government areas in the Northern Territory
  • The third parameter is the name of the output file
  • The fourth and final parameter is the name of the input file, sourced from the download from the ABS website.

Once the file is converted we can use our standard tools to adjust the file to include such things as style information to add colour to the overlay and add the standard Dublin Core based metadata that we include in all of our overlays.

The “Northern Territory Flag” photo was uploaded to Flickr by Rebecca Dominguez and used under the terms of a Creative Commons license.

Category: Thoughts
Tag: