7

Looking for a Java based (foss4g) solution for the following:

I am using a path along with a buffer to find features that are along the path. For each of the features returned I want to find the coordinate that is best fit ... meaning a straight line from the feature to the path and gleaning the point on the path.

  • 1
    What software do you want to use? – whuber Mar 24 '11 at 17:44
  • 1
    I am already using GeoTools and would like to stick with that if possible ... definitely a Java based solution would be best. – Wally Atkins Mar 24 '11 at 18:33
6

For Java, I'd recommend JTS Topology Suite. There is both a "Nearest Point" and "Closest Point" routine (I'm not sure if it is the same, or was renamed between versions) that does what you want. JTS

The result from the above is LINESTRING (205 305, 250 300), so the first point of the result is your closest point coordinates, and the length property of the result is the distance.

2

http://docs.codehaus.org/display/GEOTDOC/Closest+Point+on+a+Line seems to discuss the solution to your problem.

--- update by author of that page --

This page has been ported to sphinx based documentation:

That page just goes through how the JTS classes for snapping to a line can be used.

  • LocationIndexedLine is looking very promising ... – Wally Atkins Mar 24 '11 at 20:17

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.