The GeoTIFF Projections Pages include most of the common PROJ.4 projections, and a definition of the projection specific options for each.
% cs2cs +proj=latlong +datum=NAD27 +to +proj=latlong +datum=NAD83 -117 30
producing:
117d0'2.901"W 30d0'0.407"N 0.000
In order for datum shifting to work properly the various grid shift files must be available. See below. More details are available in the General Parameters document.
On Windows the extra nadshift target must be used. For instance nmake /f makefile.vc nadshift in the proj/src directory.
A default build and install on Unix will normally build knowledge of the directory where the grid shift files are installed into the PROJ.4 library (usually /usr/local/share/proj). On Windows the library is normally built thinking that C:\PROJ\NAD is the installed directory for the grid shift files. If the built in concept of the PROJ.4 data directory is incorrect, the PROJ_LIB environment can be defined with the correct directory.
% cs2cs -v +init=epsg:26711 # ---- From Coordinate System ---- #Universal Transverse Mercator (UTM) # Cyl, Sph # zone= south # +init=epsg:26711 +proj=utm +zone=11 +ellps=clrk66 +datum=NAD27 +units=m # +no_defs +nadgrids=conus,ntv1_can.dat #--- following specified but NOT used # +ellps=clrk66 # ---- To Coordinate System ---- #Lat/long (Geodetic) # # +proj=latlong +datum=NAD27 +ellps=clrk66 +nadgrids=conus,ntv1_can.datThe proj/nad/epsg file can be browsed and searched in a text editor for coordinate systems. There are known to be problems with some coordinate systems, and any coordinate systems with odd axes, a non-greenwich prime meridian or other quirkyness are unlikely to work properly. Caveat Emptor!
On unix-like platforms, this problem can be avoided by forcing the use of the default numeric locale by setting the LC_NUMERIC environment variable to C.
eg.
$ export LC_NUMERIC=C $ proj ...
+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0
+x_0=0.0 +y_0=0 +k=1.0 +units=m +no_defs
But, if you do something like:
cs2cs +proj=latlong +datum=WGS84
+to +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0
+x_0=0.0 +y_0=0 +k=1.0 +units=m +no_defs
to convert between WGS84 and mercator on the sphere there will be substantial
shifts in the Y mercator coordinates. This is because internally cs2cs is
having to adjust the lat/long coordinates from being on the sphere to being
on the WGS84 datum which has a quite differently shaped ellipsoid.In this case, and many other cases using spherical projections, the desired approach is to actually treat the lat/long locations on the sphere as if they were on WGS84 without any adjustments when using them for converting to other coordinate systems. The solution is to "trick" PROJ.4 into applying no change to the lat/long values when going to (and through) WGS84. This can be accomplished by asking PROJ to use a null grid shift file for switching from your spherical lat/long coordinates to WGS84.
cs2cs +proj=latlong +datum=WGS84
+to +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0
+x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs
Note the strategic addition of +nadgrids=@null to the spherical
projection definition.Similar issues apply with many other datasets distributed with projections based on a spherical earth model - such as many NASA datasets, and also (I think) the Google Maps mercator projection.