5

I'm currently having a problem with Geotools.

I try to generate a buffer (in meter using Lambert 72) on a map that has WGS84 as it's coordinatesystem. (problem is a bit like this one: http://www.mail-archive.com/[email protected]/msg08046.html, however I can't manage to solve my problem with it).

I have a couple of points in a map (in WGS84), and I want to add buffers around it using meters. As said here ( http://docs.geotools.org/latest/userguide/library/jts/operation.html ) you should transform the Geometry into the other CRS, buffer and then go back.

So what I do:

CoordinateReferenceSystem WGS = DefaultGeographicCRS.WGS84;
CoordinateReferenceSystem lambert = CRS.decode("EPSG:31300");
MathTransform convertToMeter = CRS.findMathTransform(WGS, lambert,false);
MathTransform convertFromMeter = CRS.findMathTransform(lambert, WGS,false);
//Start
targetGeometry=(Point) simpleFeature.getDefaultGeometry();
//transform to meter
targetGeometry = JTS.transform(targetGeometry, convertToMeter);
//add a buffer of 1000meters
targetGeometry= targetGeometry.buffer(1000d);
//go back to WGS 84
targetGeometry = JTS.transform(targetGeometry, convertFromMeter);

So now I expect to get a buffer of 1000meters, however what I get is a buffer of around 750meter, and I don't have any clue why.

Anyone could give me some advice (or could tell me the stupid error I'm making)?

asked Sep 14, 2012 at 17:00

1 Answer 1

6

Browsing one of the given links a couple of times over and trying with a different file, I realised that the I did need to alter the:

CoordinateReferenceSystem WGS = CRS.decode("EPSG:4326");
CoordinateReferenceSystem lambert = CRS.decode("EPSG:31300");

to:

CoordinateReferenceSystem WGS = CRS.decode("EPSG:4326",true);
CoordinateReferenceSystem lambert = CRS.decode("EPSG:31300",true);

to alter the longitude to the first coordinate and then it comes out right. I expected that if the CRS was wrong the error would be bigger. Anyway solved now.

answered Sep 16, 2012 at 9:18

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.