Skip to content

Expected behavior for polygon supplied in "from" or "to" argument of st_network_cost? #151

Answered by luukvdmeer
zackarno asked this question in Q&A
Discussion options

You must be logged in to vote

Internally, sfnetworks calls sf::st_nearest_feature() (in the form st_nearest_feature(input_geoms, network_nodes) to find the nearest network node to each input geometry, see https://r-spatial.github.io/sf/reference/st_nearest_feature.html. As far as I am aware (but not 100% sure!), that should do exactly what you are asking for. Hence, when your input geometries are polygons, it should use the nearest network nodes to the boundaries of these polygons (and not to their centroids) for shortest path calculations. To be honest I am not sure how st_nearest_features behaves when there are nodes inside your polygons.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by luukvdmeer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants