crop_dem.Rd
A function for sampling a DEM by cropping squares based on xy cooridnates.
crop_dem(data, x0, y0, L, plot = FALSE)
A DEM in RasterLayer format.
A value or vector of center x coordinate(s).
A value or vector of center y coordinate(s).
Size of square to cut out of DEM.
Logical. Plot the DEM and the cropped sections?
A cropped RasterLayer or a list of RasterLayers.
# around one point
dem_cropped <- crop_dem(horseshoe, -468, 1266, L = 2)
raster::plot(dem_cropped)
points(-468, 1266)
# around multiple points
points <- data.frame(x = c(-467, -465, -466), y = c(1270, 1265, 1268))
dem_list <- crop_dem(horseshoe, points$x, points$y, L = 1, plot = TRUE)
# plot the first element
raster::plot(dem_list[[1]])