Version 5 of proj.4

Updated 2010-06-15 07:33:35 by jhjl

PROJ.4 is a cartographic projections library written in C, originally written by Gerald Evenden (at that time at the USGS). It is in active use by quite a lot of applications, like QuantumGIS [L1 ], GRASS GIS [L2 ], MapServer, PostGIS, and many others.

More information can be found here: http://trac.osgeo.org/proj/

Proj.4 is released under an MIT license and thus can be used quite freely.

Tcl binding for proj.4

TR (2010-06-10) It turned out, that making a Tcl binding to proj.4 was quite simple. It just took a few days to get all things right. There is a more or less well-defined API [L3 ], that can be used and what I am currently coming up with is a new Tcl package with the main command proj::project. It works like this:

package require tclproj
# give an input coordinate system in proj.4 format,
# an output coordinate system,
# and a list of x/y coordinate pairs in a list:
proj::project "+proj=latlong +ellps=clrk66" "+proj=merc +ellps=clrk66 +lat_ts=33" {-16 20.25}
-1495284.21147 1920596.78992

proj::project "+proj=latlong +ellps=WGS84" "+proj=merc +ellps=WGS84 +lat_ts=33" {-16 20.25 10.33 54.55 9.23433 55.01132}
-1495251.43594 1920692.42348 965371.708328 6078165.01069 862977.824527 6152753.87339

(2010-06-11) Today I added the proj::info command. It gives you the following:

# return the proj.4 release used here:
proj::info version
# return a list with the available projection identifiers and names:
proj::info projections
# return a list with the available ellipsoid identifiers and names:
proj::info ellipsoids
# return a list with the available datum identifiers and names:
proj::info datums
# return a list with the available conversion unit identifiers and names:
proj::info units

As of now, there is basic error checking, and some other commands already, but the heart is the proj::project command. The extension can be built with the proj.4 library statically linked in, so there is no need of seperately installing proj.4 on your system. My test system is a Mac right now, but my build script should also work nicely on Unix. I don't know about Windows yet.

It would be fairly easy to also add commands that correspond to the ones used in the tcllib module mapproj.

If there is an interest for this work within the Tcl community, I can try to set up a place where you can download the source and maybe some binaries ... just drop me a line.


Download code and package

I have placed the current state of the package here (containing the library and a pkgIndex.tcl script, no separate installation of proj.4 needed). The package should work with Tcl 8.4, 8.5, and 8.6.

  • tclproj-linux.zip [L4 ]
  • tclproj-mac.zip [L5 ], (for a x86_64 tclsh, i386 version soon following)
  • tclproj.c [L6 ], the current source code for the package (feel free to comment
  • test-tclproj.tcl [L7 ], a tcltest script for the new commands

Related topics: geodesy


arjen - 2010-06-11 03:06:59

Torsten, you have beaten me to it :). Nice work.

TR - Good to hear!


'''JHJl - 2010-06-15 Have just built on Windows XP using Visual Studio 2008 Pro. Only change was to add a DLLEXPORT Tclproj_init. Thanks for making this available.