To Tom,
I am pretty sure you have been bitten by the axis order "feature" of the
epsg database. The proj4 library (used by postgis) assumes that
coordinates are x,y (or long.,lat.). EPSG actually defines axis orders
for CRS's so the order could be lat,long or long,lat (or z,y,x, or etc).
The WKT for your wgs84 crs is:
GEOGCS["WGS 84",
DATUM["World Geodetic System 1984",
SPHEROID["WGS 84", 6378137.0, 298.257223563,
AUTHORITY["EPSG","7030"]],
AUTHORITY["EPSG","6326"]],
PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]],
UNIT["degree", 0.017453292519943295],
AXIS["Geodetic latitude", NORTH],
AXIS["Geodetic longitude", EAST],
AUTHORITY["EPSG","4326"]]
Notice that the axis order is lat,long.
When I try the transformation I get:
Input: -87.64, 41.61 //somewhere in northern illinois (long,lat)
Output: 503,148.995, -14,231,707.88
Which is a similar output to what you had. But when I change the order
of the coordinates, I get:
Input: 41.61, -87.65 //(lat,long)
Output: 356,979.477, 549,043.524
This is much closer to what you expect and what postgis (proj4) told
you. Also if you look at the WKT for the transform, you will see that
the first concatenated transformation is an affine transform that is
switching the axis order from lat,long to long,lat.
Rueben
On Fri, 2006-31-03 at 08:18 -0600, Tom Howe wrote:
> Hi, I have features in postgis which are stored in WGS84. I'm trying
> to display them as nad83/Illinois east. When I run this query in post
> gis:
>
> select AsEWKT(Transform(calmet_gis, 26971)) from calmet_gis;
>
> I get:
>
> "SRID=26971;POINT(287301.149420534 535251.282126835)"
>
> Which seems right.
>
> When I run the following in geotools:
>
> CRSAuthorityFactory crsFactory =
> FactoryFinder.getCRSAuthorityFactory("EPSG", hints);
> CoordinateOperationFactory coopFactory =
> FactoryFinder.getCoordinateOperationFactory(hints);
> CoordinateReferenceSystem nad83 =
> crsFactory.createCoordinateReferenceSystem("26971");
> CoordinateReferenceSystem wgs84 =
> crsFactory.createCoordinateReferenceSystem("4326");
> MathTransform transform = coopFactory.createOperation(wgs84,
> nad83).getMathTransform();
> ... (Grabbing feature from table)
> Geometry geom = source.getFeatures
> ().features().next().getDefaultGeometry();
> System.out.println(JTS.transform(geom, transform));
>
> I get
>
> POINT (429798.4637989126 -14169731.083200943)
>
> Which does not seem right. Am I doing something wrong or is something
> not working?
>
> -Tom
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users