Find nearest position on a linestring
See original GitHub issueIs there a way to determine the nearest position on a linestring to a given point? I’m looking to snap a point to its closest position on a line.
nearestPointOnLine
returns the nearest vertex while pointToLineDistance
returns the distance to the nearest position, but not the actual coordinate.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
How to get the nearest point on a linestring to a given point?
The solution I found is to select all the linestrings within my point using the expand() method and determine the distance between each...
Read more >How to find closest point to a linestring in python?
I want to find a closest point to a linestring. I tried something but I guess it doesn't work. How can I do...
Read more >ST_LineLocatePoint - PostGIS
Returns a float between 0 and 1 representing the location of the closest point on a LineString to the given Point, as a...
Read more >ST_NearestPoints function - IBM
This example finds the nearest points on the linestring to the point with coordinates (10,0). In this case, the nearest point is at...
Read more >get index of nearest feature — st_nearest_feature • sf - r-spatial
st_nearest_points for finding the nearest points for pairs of feature geometries ... ls2, ls3)) #> Geometry set for 3 features #> Geometry type:...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Oh hell, I just figured it out. Turf uses Long/Lat, and Leaflet uses Lat/Long.
Something I noticed when I put my numbers into a fiddle for demonstrating this function is that it’s waaaay off.
Compare a jsfiddle with real numbers that we’d use here: https://jsfiddle.net/wishinghand/jeb1o72p/2/
and one with numbers I had to tweak in order for it not to be in Antarctica: https://jsfiddle.net/wishinghand/mjtz6yLc/10/