Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I copied the example from geotools, which shows how to transform a shapefile into a different projection. ( 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

      SPHEROID["Bessel_1841", 6377397.155, 299.1528128]], 
    PRIMEM["Greenwich", 0.0], 
    UNIT["degree", 0.017453292519943295], 
    AXIS["Longitude", EAST], 
    AXIS["Latitude", NORTH]], 
  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"]], 
    PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], 
    UNIT["degree", 0.017453292519943295], 
    AXIS["Geodetic latitude", NORTH], 
    AXIS["Geodetic longitude", EAST], 
  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], 

Any idea? D3

share|improve this question
compared to what? Several meters sounds pretty good to me. – iant Jun 17 '13 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 – I. Gona Jun 17 '13 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 Jun 17 '13 at 21:07
Potsdam Datum 1983 to WGS84 should be EPSG:15867, see…. The rotation parameters might have to be multiplied by -1 for Proj.4 purposes. – AndreJ Jun 18 '13 at 9:06
up vote 1 down vote accepted

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().

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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