Archive for January, 2009

Python templating

Awhile back, I started using Genshi as a templating solution for some Python application development.  Easy to use, we were able to come up with a SensorML generator for description and discovery of monitoring stations.

Lately, I’ve been helping out a bit on the new MapServer website, driven by Sphinx.  Digging deeper, I noticed Sphinx using Jinja2 for templating, so I tried this out a bit.  Not bad either!

Templating is key to many applications, and I wonder how these differ.  Perhaps the geo/python gurus out there have some further insight.

Really Easy Coordinate Transformation

One of the most frequent questions I get from clients is how to transform lat/long to LCC coordinates in a very lightweight fashion, in their webapps.  There are many solutions and approaches under the MetaCRS umbrella to choose from, depending on your requirements.

Here’s a super lightweight way to do it with proj4js:

<script src="http://svn.osgeo.org/metacrs/proj4js/trunk/lib/proj4js-compressed.js"></script>
<script src="http://svn.osgeo.org/metacrs/proj4js/trunk/lib/defs/EPSG42304.js"></script>

...

var x = -75.0;
var y = 45.0;
var p = new Proj4js.Point(x,y);
Proj4js.transform(new Proj4js.Proj("EPSG:4326"), new Proj4js.Proj("EPSG:42304"), p);
alert(p.x + " " + p.y);

Done!  Kudos to Mike Adair et. al.!

Modified: 4 January 2009 13:33:19 EST