Archive for December, 2007

Importing Spatial References from URLs in GDAL 1.5

Thursday, December 13th, 2007

We’ve been busting hard to get things in shape for the GDAL 1.5 release that will be on December 20th. Besides its typical blizzard of new GDAL and OGR drivers, one of the more useful little features that I added for this release allows you to import a spatial reference definition from a URL. It’s expected that you might use http://spatialreference.org URLs, but any old URL will do.

For example, this command will reproject the world_borders shapefile to an Albers projection that a user contributed that focuses on the Northern Pacific:

ogr2ogr -t_srs http://spatialreference.org/ref/user/north-pacific-albers-conic-equal-area/
-s_srs EPSG:4326 world_borders_albers.shp world_borders.shp

It may seem rather innocuous, but this feature can help you out quite a bit when using OGR and GDAL command line utilities. It is a hard and painful problem to ensure that you are using the correct spatial reference, and demonstrating to others what you are using in a bug report can be even harder. By using a wiki-style spatial reference repository like spatialreference.org you can ensure that everyone is using the same one. I’ll admit it’s not very useful for well known spatial references like those in the EPSG list, but if you ever cook your own reference or your pet one was missed by the powers that be, sharing them and consuming them will be a little bit easier with spatialreference.org and GDAL 1.5.

Hopefully some other projects follow suit. Fetching your spatial references from a URL *every* single time through a million member loop might not be the best approach, but it can be really handy in other scenarios.