I have several DEMs as geotiff files which I load into R using raster::raster
. Additionally, I have lake outlines (located within the DEMs) in the form of shapefiles which I load into R using raster::shapefile
.
What I would like to do is to identify the catchment of the lake within the DEM. Importantly, I would like to do this without making use of GIS tools (RGRASS, RSAGA, RQGIS), only R.
One approach I came up with involves the topmodel::subcatch
function. This function allows me to get the catchment of any pixel in the raster. Therefore, I could use it to get the catchments of all the pixels which are within the lake polygon, or all the boundary pixels of the lake, alternatively.
However, since topmodel::subcatch
only allows for a single pixel as input, I would have to perform it for all the lake boundary pixels and subsequently aggregate all the catchments. This seems inefficient. Is there a better way to do this (i.e. an R function similar to topmodel::subcatch
which allows for multiple pixels, or a lake outline, as input)?
This approach would solve the problem, yet it uses R GIS tools, which I don't have access to.