1

I try to convert some coordinates from ETRS89-LAEA (EPSG:3035) to WGS84 (EPSG:4326) with geotools. Here is the code:

Coordinate c = new Coordinate(3847988.7, 3161178.2);
MathTransform mt = CRS.findMathTransform(
   CRS.decode("EPSG:3035"),
   CRS.decode("EPSG:4326"));
c = JTS.transform(new GeometryFactory().createPoint(c), mt).getCoordinate();
System.out.println(c);

As a final result, I get:

(56.34206943661075, -8.998327460134755)

which is obviously wrong. What is wrong with my code?

Note:

    System.out.println(CRS.decode("EPSG:3035"));

returns:

PROJCS["ETRS89 / LAEA Europe", 
  GEOGCS["ETRS89", 
    DATUM["European Terrestrial Reference System 1989", 
      SPHEROID["GRS 1980", 6378137.0, 298.257222101, AUTHORITY["EPSG","7019"]], 
      TOWGS84[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], 
      AUTHORITY["EPSG","6258"]], 
    PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], 
    UNIT["degree", 0.017453292519943295], 
    AXIS["Geodetic latitude", NORTH], 
    AXIS["Geodetic longitude", EAST], 
    AUTHORITY["EPSG","4258"]], 
  PROJECTION["Lambert_Azimuthal_Equal_Area", AUTHORITY["EPSG","9820"]], 
  PARAMETER["latitude_of_center", 52.0], 
  PARAMETER["longitude_of_center", 10.0], 
  PARAMETER["false_easting", 4321000.0], 
  PARAMETER["false_northing", 3210000.0], 
  UNIT["m", 1.0], 
  AXIS["Northing", NORTH], 
  AXIS["Easting", EAST], 
  AUTHORITY["EPSG","3035"]]

and

    System.out.println(CRS.decode("EPSG:4326"));

returns:

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"]]

which both seem correct...

2

OK: It is a matter of swapping X <-> Y coordinates in the input...

A possible fix is:

CRS.decode("EPSG:3035", true);
CRS.decode("EPSG:4326", true);

or (as suggested by Ian Turton below), to simply change the order in the coordinates:

Coordinate c = new Coordinate(3161178.2, 3847988.7);
  • 2
    The clue is in the definition both are North East projections so yx, so the better fix is to fix the order in your coordinates – Ian Turton Feb 2 at 17:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.