Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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.

share|improve this question
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
add comment

2 Answers 2

up vote 5 down vote accepted

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.

share|improve this answer
add comment

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.

share|improve this answer
    
LocationIndexedLine is looking very promising ... –  Wally Atkins Mar 24 '11 at 20:17
add comment

Your Answer

 
discard

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.