On 31/07/13 11:48, gaby wrote:
> 1) To obtain the correct raster projection from NZMG to NZTM I need to set
> the system property and NOT use the OGC URN code

And we expect this to work for the reasons discussed earlier.

> 2) There is no problem at all to reproject a ReferencedEnvelope from NZMG to
> NZTM
[...]
> All's good here

And that also uses the property?:
System.setProperty("org.geotools.referencing.forceXY", "true");
As expected. But has the problems discussed earlier.

> 3) *There is a problem reprojecting the ReferencedEnvelope from NZTM to
> NZMG.*
> The ReferencedEnvelope reprojection consistently gives the wrong answers,
> whether I use the system setting, OSG URN or various combinations of the
> above.
> You can see for yourself by trying
> <pre>
> CoordinateReferenceSystem sourceCRS =
> CRS.decode("urn:ogc:def:crs:EPSG::2193");
> ReferencedEnvelope envelope = new ReferencedEnvelope(1567451.39, 1570650.34,
> 5178586.92, 5184734.56, sourceCRS);

Wrong. Outside the zone of validity. x = Northings and y = Eastings for 
EPSG:2193. You have them the other way around. (And this form is immune 
to the forceXY hack.)

> CoordinateReferenceSystem targetCRS =
> CRS.decode("urn:ogc:def:crs:EPSG::27200");
> ReferencedEnvelope newEnv = envelope.transform(targetCRS, false);
> System.out.println(newEnv.getMinX());
> System.out.println(newEnv.getMaxX());
> System.out.println(newEnv.getMinY());
> System.out.println(newEnv.getMaxY());
> </pre>
> The only way I can get this to work is by manually swapping x and y
> coordinates :-(
> ReferencedEnvelope envelope = new ReferencedEnvelope(5178586.92, 5184734.56,
> 1567451.39, 1570650.34, sourceCRS);

Good. Everything is working just fine.

Note that EPSG:2193 has Northing/Easting axis order, and EPSG:27200 has 
Easting/Northing axis order.

See: http://www.epsg-registry.org/

> This, as discussed previously, is not a acceptable solution.

Why? This is how EPSG:2193 was registered in the database, apparently by 
LINZ not being pedantic and EPSG being obtuse.

> So it seems to me, that there is a bug somewhere in the ReferencedEnvelope
> reprojection.

I am not so sure. I think you are trying to convert between two CRSes 
with opposite axis order. If you want to make your own 
CoordinateReferenceSystem that is like EPSG:2193 but with 
Easting/Northing axis order, you can use this OGC WKT, but please note 
that this is not the correct data for EPSG:2193:
http://spatialreference.org/ref/epsg/2193/prettywkt/

According to EPSG: "Users who wish to augment the EPSG data with their 
own information should utilise codes greater than 32767." So please hack 
the WKT to change the code from 2193 to something like 992193.

Kind regards,

-- 
Ben Caradoc-Davies <ben.caradoc-dav...@csiro.au>
Software Engineer
CSIRO Earth Science and Resource Engineering
Australian Resources Research Centre

------------------------------------------------------------------------------
Get your SQL database under version control now!
Version control is standard for application code, but databases havent 
caught up. So what steps can you take to put your SQL databases under 
version control? Why should you start doing it? Read more to find out.
http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to