glowabio / hydrographr

https://glowabio.github.io/hydrographr/
GNU General Public License v3.0
13 stars 1 forks source link

get_distance fails if a basin-layer is not available #52

Open domisch opened 4 months ago

domisch commented 4 months ago

By running

distance_table <- get_distance(data = snapped_coordinates,
                               lon = "lon_snap",
                               lat = "lat_snap",
                               id = "occurrence_id",
                               stream_layer = stream_vect,
                               distance = "network")

without having a basin.tif on disk, the function fails as it keeps looking for "basin_layer" (but the user does not now if a basin layer should be supplied). Most probably it's because of this line: wsl_basin_layer <- fix_path(basin_layer) Is the basin-layer actually needed for the function or can this line be commented / removed?

merretbuurman commented 2 months ago

I looked at it, and I don't think it depends on whether you have a basin raster on disk. The function uses the variable "basin_layer" in line 289, but the variable is never defined, not as a parameter in the function definition (lines 122-123) nor later. If I'm not wrong, the function should fail all the time (in windows), no matter what you have on disk. Unless I understand R fundamentally wrong :D but I cannot test this as I don't have windows (@tomitho , @ytorres-cambas ?).

So, just remove the entire line wsl_basin_layer <- fix_path(basin_layer), this should fix the problem and not affect the functionality in any way.