Skip to contents

Sample a random DEM with specified size from a larger DEM

Usage

dem_sample(data, L, allow_NA = 0, plot = FALSE, max_iter = 100)

Arguments

data

Digital elevation model of class RasterLayer.

L

Size of square to cut out of DEM.

allow_NA

Proportion of NA values allowed in the sample. Useful when DEM is not regular.

plot

Logical. Plot the DEM and the cropped section?

max_iter

Maximum number of random crops to try when allow_NA = FALSE before failing.

Value

Digital elevation model of class RasterLayer.

Note

Not allowing NAs may increase sampling time for irregular DEMs that contain a lot of NAs; e.g., structure from motion transects.

Examples

dem <- dem_sample(horseshoe, L = 2, plot=TRUE)