[GIS] How to convert Lat/Long to UTM using Proj(4j) similar to JScience UTM.latLongToUTM

convertprojutm

I'd like to use Proj(4j) to convert between UTM and Lat/Long coordinates.

I used to use JScience for UTM <-> LatLong conversions like this:

UTM.latLongToUtm(latlong, ReferenceEllipsoid.WGS84);
UTM.utmToLatLong(coordinate, ReferenceEllipsoid.WGS84);

But I would like to accomplish this using Proj4j. So I'm currently having set up two CoordinateReferenceSystems:

CRS_FACTORY.createFromParameters("EPSG:4326", "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs");
CRS_FACTORY.createFromParameters("?", "+proj=utm +? +zone=?);

Where I don't know how to fill up the ? gaps.

Why do I have to specify a zone-parameter? Is there a way to accomplish the same above in JScience using proj4j?

Best Answer

If you're using WGS84, for a northern hemisphere zone, concatenate 326 + zone number. For a southern hemisphere zone, concatenate 327 + zone number. The 326 comes from 4326, the code for a 2D WGS84.

So for zone 30N, 32630.

There are a few other drop-first-integer-and-concatenate-zone-number, but none as complete as WGS84. Others, like NAD83, the first zones added follow the same convention but later ones do not.

I should have made this a comment on simplexio's answer--vote for that answer!