Skip to contents

Sample points from a spatial object, optionally by local density

Usage

morie_spatial_sample(x, size, by_density = TRUE, seed = 42L)

Arguments

x

A morie_spatial.

size

Number of points to sample.

by_density

If TRUE, sampling probability is proportional to local point density (denser areas more likely); if FALSE, uniform.

seed

RNG seed.

Value

Integer row indices of the sampled points.

Examples

morie_spatial_sample(morie_spatial(expand.grid(lon = 1:5, lat = 1:5)),
                     size = 5)
#> [1] 25 21 17 10 24