[postgis-users] Bug or Problem with st_transform

Stephen Woodbridge woodbri at swoodbridge.com
Tue May 18 06:45:35 PDT 2010


Hi guys,

This is looking like it might be a bug on version "POSTGIS="1.3.3" 
GEOS="3.0.0-CAPI-1.4.1" PROJ="Rel. 4.6.0, 21 Dec 2007" USE_STATS" which 
I know is ancient, but upgrading is not trivial.

What I am trying to do is construct a shape in 900913 in meters and then 
rotate, transform it to 4326 and translate it to a location.

The problem is the transform does not look correct. To just rough out 
the math, 4030 meters should be about 0.036202 degrees based on
4030/40075016*360 = 0.036202 but st_transform is giving back numbers 
like -5.67596869587729e-09

Is this a known problem on this version?
Is my logic faulty?
Is there a better way to do this?

Thanks,
   -Steve

900913 definition:
900913;"spatialreference.org";900913;"PROJCS["unnamed",GEOGCS["unnamed 
ellipse",DATUM["unknown",
    SPHEROID["unnamed",6378137,0]],PRIMEM["Greenwich",0],
    UNIT["degree",0.0174532925199433]],PROJECTION["Mercator_2SP"],
    PARAMETER["standard_parallel_1",0],PARAMETER["central_meridian",0],
    PARAMETER["false_easting",0],PARAMETER["false_northing",0],
    UNIT["Meter",1],
    EXTENSION["PROJ4","+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 +wktext 
+no_defs"]]";"+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 +wktext  +no_defs"

Test query showing problem:

SELECT astext(st_linefromtext('LINESTRING(0 0,4030 0,4030 4030,0 4030)', 
900913)),
        astext(st_rotate(st_linefromtext('LINESTRING(0 0,4030 0,4030 
4030,0 4030)', 900913), radians(90))),
        astext(st_transform(st_rotate(st_linefromtext('LINESTRING(0 
0,4030 0,4030 4030,0 4030)', 900913), radians(90)), 4326)),

astext(st_translate(st_transform(st_rotate(st_linefromtext('LINESTRING(0 
0,4030 0,4030 4030,0 4030)', 900913), radians(90)), 4326),-71.26162, 
42.30028))

I also get messages:

WARNING:  transform: -38 (failed to load NAD27-83 correction file)
WARNING:  transform: -38 (failed to load NAD27-83 correction file)
WARNING:  transform: -38 (failed to load NAD27-83 correction file)
WARNING:  transform: -38 (failed to load NAD27-83 correction file)
WARNING:  transform: -38 (failed to load NAD27-83 correction file)
WARNING:  transform: -38 (failed to load NAD27-83 correction file)
WARNING:  transform: -38 (failed to load NAD27-83 correction file)
WARNING:  transform: -38 (failed to load NAD27-83 correction file)


The results are:

"LINESTRING(0 0,4030 0,4030 4030,0 4030)";

"LINESTRING(0 0,2.46766330028192e-13 4030,-4030 4030,-4030 
2.46766330028192e-13)";

"LINESTRING(0 0,3.47552844773335e-25 
5.67596699566489e-09,-5.67596869587729e-09 
5.67596699566489e-09,-5.67596869587729e-09 0)";

"LINESTRING(-71.26162 42.30028,-71.26162 
42.300280005676,-71.261620005676 42.300280005676,-71.261620005676 
42.30028)"





More information about the postgis-users mailing list