Archive for January, 2007

Geographic Projection Web Services redux

Tuesday, January 9th, 2007

A couple of years ago I was playing around with Twisted Python and developed a simple web service for reprojecting data (this is no longer live). It was merely a glorified wrapper around the spatial reference tools in GDAL, but a few folks found it useful and I still receive an email about it here and there.

Lately, I’ve been playing around with Django, mostly as an effort to find a less punishing framework than Zope/Plone. I’m not very much of a web person however, but I’ve been following some of the recent developments like OpenLayers, GeoJSON, and, of course, the Google. One of the more common and somewhat insane things that I see as part of my daily routine hanging out on #gdal on IRC is somebody showing up asking about projection math and how they can implement it in JavaScript. The Open Source GIS world already has a world-class projections library in Proj.4, but for some reason it makes sense to a few folks to try and re-invent this wheel. I’ve always thought it was kind of silly, and any attempt to do so would probably result in a miserable development effort that retreads the misery that Gerald and Frank endured making Proj.4 in the first place.

JSON

JSON, or JavaScript Object Notation, is rapidly becoming the transport of choice for all of the AJAXian wunderkinds out there. The greatest advantage of JSON is that the parsing overhead of it for JavaScript is zero, and it can practically be eval’d in directly to the client. With these two things in mind, I set about to play around with a JSON-emitting webservice that projects geographic data (points).

The projector lives at http://projection.hobu.biz/json . It takes in these parameters:

Parameter Value Description
x -93.0 The x coordinate (longitude)
y 42.0 The y coordinate (latitude)
inref EPSG:4326 The input spatial reference of the point
outref EPSG:26915 The output spatial reference of the point
function myfunction The name of the JavaScript function to wrap the output in
id 3 An id to give the data

Here’s an example that projects a point in Iowa from EPSG:4326 to EPSG:26915 (decimal degrees WGS 84 to UTM Zone 15):

http://projection.hobu.biz/json/project/?y=43&x=-93&function=myfunction&outref=EPSG%3A26915&inref=EPSG%3A4326

Using the service with EPSG codes would probably be the most common way to work, but because the service builds on the spatial referencing library in GDAL, there are many more options. For example, we could specify our input projection in Proj.4 format instead:

Proj.4 input example

Or even get really nuts and specify our output projection in OGC WKT:

OGC WKT output example

Finally, we can output a coordinate in a spatial reference that doesn’t have an EPSG code, like USGS Albers:

USGS Albers output example

Python usage

You aren’t limited to using GET requests either (although you could probably construct one easily with urllib). For example, with jsonrpclib for Python, you can request projection of points much like you would with XMLRPC:

>>> import jsonrpclib>>> rpc = jsonrpclib.ServerProxy('http://projection.hobu.biz/json')>>> rpc.project('-93.0', '42.0', 'EPSG:4326', 'EPSG:26195')>>>{u'id': 2, u'result': {u'features': {u'center': [500000.0, 4649776.2247029999, 0.0], u’title’: u’title’, u’spatialCoordinates’: [[500000.0, 4649776.2247029999, 0.0]], u’srs’: u’EPSG:26915′, u’geometryType’: u’point’, u’id’: u’1′}}}

If you find it useful, let me know.

GDAL 1.4.0 Released

Sunday, January 7th, 2007

Head to http://www.gdal.org to get a copy. Here’s the note from Frank and relevant news items that describe some of the changes:

The GDAL development team is pleased to announce the release of
GDAL/OGR 1.4.0.  This new release includes many new features
and bug fixes since the 1.3.2 release nine months ago.  These
are described at:

http://www.gdal.org/NEWS.html

The new release source may be downloaded from:

http://www.gdal.org/dl/gdal-1.4.0.tar.gz
http://www.gdal.org/dl/gdal140.zip

Binaries corresponding to the GDAL/OGR 1.4.0 release can
be found included in the FWTools 1.1.3 release for Windows
and Linux at:

http://www.gdal.org/dl/fwtools/FWTools113.exe (windows)
http://www.gdal.org/dl/fwtools/FWTools-linux-1.1.3.tar.gz (linux)

The GDAL project has also introduced the new gdal-announce
list, hosted by OSGeo.  Those interested in just occasional
notices of GDAL/OGR project progress are encouraged to join
this mailing list.

http://lists.osgeo.org/mailman/listinfo/gdal-announce

GDAL/OGR 1.4.0 - General Changes

Perl Bindings:
  • Added doxygen based documentation.
NG Python Bindings:
  • Implemented numpy support.
CSharp Bindings:
  • Now mostly operational.
WinCE Porting:
  • CPL
  • base OGR, OSR and mitab and shape drivers.
  • GDAL, including GeoTIFF, DTED, AAIGrid drivers
  • Added test suite (gdalautotest/cpp)
Mac OSX Port:
  • Added framework support (–with-macosx-framework)

GDAL 1.4.0 - Overview Of Changes

WCS Driver:
  • New
PDS (Planetary Data Set) Driver:
  • New
ISIS (Mars Qubes) Driver:
  • New
HFA (.img) Driver:
  • Support reading ProjectionX PE strings.
  • Support producing .aux files with statistics.
  • Fix serious bugs with u1, u2 and u4 compressed data.
NITF Driver:
  • Added BLOCKA reading support.
  • Added ICORDS=’D’
  • Added jpeg compression support (readonly)
  • Support multiple images as subdatasets.
  • Support CGM data (as metadata)
AIGrid Driver:
  • Use VSI*L API (large files, in memory, etc)
  • Support upper case filenames.
  • Support .clr file above coverage.
HDF4 Driver:
  • Added support for access to geolocation arrays (see RFC 4).
  • External raw raster bands supported.
PCIDSK (.pix) Driver:
  • Support METER/FEET as LOCAL_CS.
  • Fix serious byte swapping error on creation.
BMP Driver:
  • Various fixes, including 16bit combinations, and non-intel byte swapping.
GeoTIFF Driver:
  • Fixed in place update for LZW and Deflated compressed images.
JP2KAK (JPEG2000) Driver:
  • Added support for reading and writing gmljp2 headers.
  • Read xml boxes as metadata.
  • Accelerate YCbCr handling.
JP2MrSID (JPEG2000) Driver:
  • Added support for reading gmljp2 headers.
EHDR (ESRI BIL) Driver:
  • Support 1-7 bit data.
  • Added statistics support.

OGR 1.4.0 - Overview of Changes

OGR SQL:
  • RFC 6: Added support for SQL/attribute filter access to geometry, and
    style strings.
OGRSpatialReference:
  • Support for OGC SRS URNs.
  • Support for +wktext/EXTENSION stuff for preserving PROJ.4 string in WKT.
  • Added Two Point Equidistant projection.
  • Added Krovak projection.
  • Updated support files to EPSG 6.11.
OGRCoordinateTransformation:
  • Support source and destination longitude wrapping control.
OGRFeatureStyle:
  • Various extensions and improvements.
INFORMIX Driver:
  • New
KML Driver:
  • New (write only)
E00 Driver:
  • New (read only)
  • Polygon (PAL) likely not working properly.
Postgres/PostGIS Driver:
  • Updated to support new EWKB results (PostGIS 1.1?)
  • Fixed serious bug with writing SRSes.
  • Added schema support.
GML Driver:
  • Strip namespaces off field names.
  • Handle very large geometries gracefully.
ODBC Driver:
  • Added support for spatial_ref_sys table.
SDE Driver:
  • Added logic to speed things up while actually detecting layer geometry types
PGeo Driver:
  • Added support for MDB Tools ODBC driver on linux/unix.
VRT Driver:
  • Added useSpatialSubquery support.

Five Things

Wednesday, January 3rd, 2007

Sean tagged me, so here goes:

  1. I have cheated death three times.  First, I overturned a farm tractor and had a 500 lb. barrel roll inches past my head.  About two years later, I fell asleep driving and drove off a curve at 60+ mph.  Finally, about a year afterward, I was struck by lightning driving down the freeway at 70 miles per hour (totaled the car but didn’t touch me). 
  2. I am halfway to completing my private pilot’s license (no close calls so far ;)
  3. My first successful Linux installation was on a Compaq iPaq using the handhelds.org distribution about five years ago.
  4. I own an original Palm I handheld. I still would have rather had a Newton.
  5. My first computer was an Apple IIgs.  Graphics and sound, baby!

Mateusz, Frank, Sandro, Jo, and Gary,  you’re it.