2

I copied the example from geotools, which shows how to transform a shapefile into a different projection. (http://docs.geotools.org/latest/userguide/tutorial/geometry/geometrycrs.html) But when transforming from Gauss Krueger 4 into Pseudo Mercator (3857) the shapes are not at the correct position, they are displaced several meters.

What can I do to fix this?

The sample code contains :

 CoordinateReferenceSystem dataCRS = schema.getCoordinateReferenceSystem();
            CoordinateReferenceSystem worldCRS = map.getCoordinateReferenceSystem();
            boolean lenient = true; // allow for some error due to different datums
            MathTransform transform = CRS.findMathTransform(dataCRS, worldCRS, lenient);

... and then ...

Geometry geometry2 = JTS.transform(geometry, transform);

additional information:

The sample data of the source as the following CRS

PROJCS["PD_83_3_degree_Gauss_Kruger_zone_4", 
  GEOGCS["GCS_PD/83", 
    DATUM["D_Potsdam_Datum_83", 
      SPHEROID["Bessel_1841", 6377397.155, 299.1528128]], 
    PRIMEM["Greenwich", 0.0], 
    UNIT["degree", 0.017453292519943295], 
    AXIS["Longitude", EAST], 
    AXIS["Latitude", NORTH]], 
  PROJECTION["Transverse_Mercator"], 
  PARAMETER["central_meridian", 12.0], 
  PARAMETER["latitude_of_origin", 0.0], 
  PARAMETER["scale_factor", 1.0], 
  PARAMETER["false_easting", 4500000.0], 
  PARAMETER["false_northing", 0.0], 
  UNIT["m", 1.0], 
  AXIS["x", EAST], 
  AXIS["y", NORTH]]

and the target has the following CRS:

PROJCS["WGS 84 / Pseudo-Mercator", 
  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"]], 
  PROJECTION["Popular Visualisation Pseudo Mercator"], 
  PARAMETER["semi_minor", 6378137.0], 
  PARAMETER["latitude_of_origin", 0.0], 
  PARAMETER["central_meridian", 0.0], 
  PARAMETER["scale_factor", 1.0], 
  PARAMETER["false_easting", 0.0], 
  PARAMETER["false_northing", 0.0], 
  UNIT["m", 1.0], 
  AXIS["Easting", EAST], 
  AXIS["Northing", NORTH], 
  AUTHORITY["EPSG","3857"]]

Any idea? D3

4
  • compared to what? Several meters sounds pretty good to me.
    – Ian Turton
    Commented Jun 17, 2013 at 15:45
  • about 300 meters, the polygon has a size of 2000 x 2000 m, so 300 is really not ok. I'm checking the displacement with QGis and a google basemap, since the result needs to be displayed in an online map
    – ABX
    Commented Jun 17, 2013 at 16:09
  • That sounds like a missing datum transformation. What GeoCRS is the GK 4 based upon? I tried converting $randompoint assuming DHDN to 3857 with/without transformation and the results differed by 141m in easting and 209m in northing.
    – mkennedy
    Commented Jun 17, 2013 at 21:07
  • 1
    Potsdam Datum 1983 to WGS84 should be EPSG:15867, see crs-geo.eu/nn_124226/sid_C1AF789874129462184B098637665158/…. The rotation parameters might have to be multiplied by -1 for Proj.4 purposes.
    – AndreJ
    Commented Jun 18, 2013 at 9:06

1 Answer 1

2

Meanwhile I learned that I have to use the Bursa Wolf parameters for a precise transformation between shapes with different datum. The required parameters are in the Geotools hsql database, which can be 'queried' by CRS.decode().

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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