tags:

views:

139

answers:

1

Do any open source or 'free' libraries exist for Java where i can perform coordinate transforms from one spatial system to another?

I found Opengeo http://opengeo.org/ but it's a huge and comprehensive library for all sorts of spatial things.

Does anything smaller exist? I need to convert from MGA56 to WGS84.

+1  A: 

A simple solution is PROJ.4, but it doesn't have Java bindings, so working with it might be a bit tricky. A more complete (but probably bigger than you want) solution would be GeoTools. But a quick search found the Java Map Projection Library, which appears to be a Java port of PROJ.4. I would give that a try.

Since it appears you need to do a datum shift, not only a projection, you will need to have some kind of coordinate system database. The easiest to get a hold of is the EPSG database -- PROJ.4 comes with an EPSG mapping file, which should be good enough for most purposes.

It looks like MGA56 is EPSG:28356, and of course WGS84 is EPSG:4326.

Daniel Pryden
OP appears to be already using GeoTools: http://stackoverflow.com/questions/1676940/google-maps-spatial-reference-system
Greg Hewgill
PROJ.4 looks great. i used ProjectionFactory.getNamedPROJ4CoordinateSystem() to grab the projections. But no transform is possible. I read the docs it says "Coordinate system and geodetic datum conversion is missing. "
JavaRocky
If you're using GeoTools, don't bother with working with PROJ4 directly -- use `CRSAuthorityFatory.createCoordinateReferenceSystem(epsgString)`, for EPSG strings `"EPSG:28356"` and `"EPSG:4326"` and then do `CRS.findMathTransform(sourceCRS, targetCRS, true)`. You will need to have one of the GeoTools EPSG JARs on your classpath -- I would recommend `gt-epsg-hsql`, which is the easiest to work with.
Daniel Pryden