mbtyers / riverdist

River Network Distance Computation and Applications
23 stars 2 forks source link

"No route detected." as a result but points and stream shapefiles are ok #14

Closed danielmerbet closed 5 years ago

danielmerbet commented 6 years ago

Hello,

I am using this code:

stream <- line2network("/directory", layer="branco_r", tolerance = 100)
segvert <- pointshp2segvert(path="directory", layer="branco_p", rivers=stream)
riverdistance(startseg = 12, startvert = 18, endseg = 23, endvert = 1, stream)

When I check the plots of the river and points, they seem correct, but I am encoutering this error:

Error in detectroute(start = startseg, end = endseg, rivers = rivers,  : 
  No route detected.

I send you the initial shapefiles (river and points, with the same projection). Thank you in advance for your help and thank you for this great package.

branco_riverANDpoints.zip

jsta commented 6 years ago

It looks to me like your segments 20 and 17 are unconnected. You can check with the topologydots function. I ran the cleanup function to connect these segments and got a riverdistance of 2309719.

jsta commented 6 years ago

Also, I imagine you want your startvert to be 19 not 18 as this is the "end" of the segment. nrow(stream$lines[12][[1]])

danielmerbet commented 6 years ago

@jsta Thank you very much...You are right, the stream shapefile had unconnected segments. Now, it is working properly.