Skip to content
Prev 29426 / 29559 Next

How to randomly select polygons

I would take the same approach I would for most other things.

1. Count the number of observations
2. Define your sample size
3. Sample `n` from 1:N
4. Use those as an index to subset from

nc  <- sf::st_read(system.file("shape/nc.shp", package = "sf"))

n <- 10
idx <- sample(1:nrow(nc), n)
nc[idx, ]
On Mon, Sep 23, 2024 at 2:45?PM Manuel Sp?nola <mspinola10 at gmail.com> wrote: