Sf: st_snap returning the start/end point of the linestring

Created on 12 Jul 2018  路  5Comments  路  Source: r-spatial/sf

Hi all,

I noticed that st_snap is returning the start/end point of the closest linestring. Is the the expected behavior of the function? I was expecting that st_snap would work similarly to maptools::snapPointsToLines and snap a point to the closest point on a line segment.

There is a reproducible example here.

Most helpful comment

Hi @edzer . Yes, @tim-salabim provided a good workaround to the problem and I'm grateful for that. :) Nevertheless, that's still just a workaround, hence my previous question whether there are any plans to develop a built-in function in sf that works similarly to maptools::snapPointsToLines. I think this could be a valuable function for future versions of sf but I understand if you don't think that's worth pursuing here.

All 5 comments

No, it is a straight copy of PostGIS' st_snap.

Thank you for the clarification, @edzer . Are there any plans to create an sf function similar to maptools::snapPointsToLines ?

@tim-salabim gave you a good suggestion on SO; with st_length you seem to have what you're looking for. Please choose whether to pursue this issue here, or on SO.

Hi @edzer . Yes, @tim-salabim provided a good workaround to the problem and I'm grateful for that. :) Nevertheless, that's still just a workaround, hence my previous question whether there are any plans to develop a built-in function in sf that works similarly to maptools::snapPointsToLines. I think this could be a valuable function for future versions of sf but I understand if you don't think that's worth pursuing here.

See st_nearest_points.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ekarsten picture ekarsten  路  4Comments

dpprdan picture dpprdan  路  4Comments

angela-li picture angela-li  路  4Comments

kendonB picture kendonB  路  4Comments

faridcher picture faridcher  路  4Comments