[mapserver-users] pj_transform & pj_datum_transform

Frank Warmerdam warmerdam at pobox.com
Tue Jan 22 09:36:15 PST 2002


On Tue, Jan 22, 2002 at 08:49:39AM -0800, Arthur, John wrote:
> Now that these 2 function are included into php_proj.dll, what is the
> correct way to use them?  I was able to transform UTM to LatLong, but the
> datums do not change from nad27 to nad83 when I use the following:
> 
> $lat = doubleval("336276.6563");
> $lon = doubleval("4145316.5");
> 
> 
> $parms[0] = "proj=utm";
> $parms[1] = "ellps=clrk66";
> $parms[2] = "zone=18";
> $parms[3] = "no_defs";
> $projUTM = pj_init($parms);
> 
> $parms[0] = "proj=latlong";
> $parms[1] = "ellps=GRS80";
> $parms[2] = "lat_0=36.0";
> $parms[3] = "lon_0=-79.5";
> $parms[4] = "lat_1=37.0";
> $parms[5] = "lat_2=39.5";
> $projGEO = pj_init($parms);
> 				
> 				   
> $ret = pj_datum_transform($projUTM, $projGEO, $lat, $lon, 0 );
> $ln = ($ret["u"]);
> $lt = ($ret["v"]);
> echo "<BR>".$ln."<BR>".$lt;
> 
> This returns:
> -76.8507223773
> 37.442055949314
> Which is NAD27, but should return:
> -76.850410
> 37.442204
> Which is NAD83
> 
> What am I doing wrong?  I have the PROJ_LIB path set.  I am on a WINDOWS
> 2000 server w/apache & PHP 4.

John,

I am a bit surprised that pj_datum_transform() access is provided. 
Generally you shouldn't need to use this directly but rather operate 
through pj_transform() which will also do datum shifting if needed.

The problem in your case is that you aren't specifying your datums.  Instead
of ellps=clrk66 use datum=NAD27 and instead of ellps=GRS80 use datum=NAD83.
For NAD27/NAD83 datum shifting to work you will need to ensure that the
grid shift files are available and can be found.  You will need to have 
the file "conus" in the directory referenced in the PROJ_LIB environment
variable.  

When building PROJ.4 by hand this generally means downloading the extra 
grid shift distribution, and untarring it over the proj distribution
then running the extra "nmake /f makefile.vc nadshift" command to 
translate the input conus.lla into a platform specific binary file. 

  ftp://ftp.remotesensing.org/pub/proj/proj-nad27-1.1.tar.gz

Good luck,

-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent




More information about the MapServer-users mailing list