lucarraro / rivnet

An R-package allowing seamless extraction of river networks from Digital Elevation Models data
https://lucarraro.github.io/rivnet/
Other
13 stars 1 forks source link

Error in z[[i]] : subscript out of bounds extract_river() #5

Closed tanharri closed 7 months ago

tanharri commented 7 months ago

Hi,

Thank you for making this package. I was trying to use it for a river in Scotland. The example on the vignette works fine:

extract_river(outlet = c(637478, 237413), EPSG = 21781, #CH1903/LV03 coordinate system ext = c(6.2e5, 6.6e5, 2e5, 2.5e5), z = 10)

However, when trying to use the extract_river function, using either the UTM zone 30N, British National Grid, or WGS84 EPSG 4326 coordinate reference systems, I am returned the following error: Error in z[[i]] : subscript out of bounds

extract_river(outlet = c(556982, 6333954), EPSG = 32630, ext = c(454795.5, 556990, 6304181, 6362366), z = 10) extract_river(outlet = c(396571, 806047.8), EPSG = 27700, ext = c(294153.5, 396572, 777448.9, 834982.5), z = 10) extract_river(outlet = c(-2.058302, 57.14531), EPSG = 4326, ext = c(-3.744192, -2.058302, 56.8808, 57.19146), z = 10)

Am I making an obvious mistake here?

Thank you

lucarraro commented 7 months ago

Hello,

Thanks for your interest in the package.

If you add the argument showPlot = T, you can have a better idea of what is going on. As of rivnet v0.3.4, a figure shows the original (i.e., user-provided) and relocated (snapped to the extracted river network) locations of the outlet, and the extracted river network in the proximity of the outlet.

The river you are looking for appears white, meaning that its cells have an undefined drainage area value. This is because the coordinate extent ("ext") you provided does not fully contain the watershed you're looking for.

I tried to re-run your first extract_river call with a more "generous" ext ( = c(450000, 560000, 6300000, 6370000)), and the issue seems to be solved.

Hope this helps. Let me know if you need further assistance.

tanharri commented 7 months ago

Ahh perfect thank you.