st_sample_geotools: st_sample_geotools

st_sample_geotoolsR Documentation

st_sample_geotools

Description

st_sample_geotools

Usage

st_sample_geotools(
  geodata,
  n,
  fraction = NULL,
  weight_var,
  type = "random",
  iter = 9,
  ...
)

Arguments

geodata

sf object

n

number of features to sample

fraction

fraction of features to sample

weight_var

(optional) variable in geodata to weight by

type

passed to spsample; defaults to "random"

iter

passed to spsample

...

reserved for future use

Examples

county_geodata <- TIGER2015::TIGER2015_SFBA_counties %>% with_county_populations()
county_sample <- county_geodata %>% st_sample(n = 1000, weight_var = "county_pop_total")

tract_geodata <- TIGER2015::TIGER2015_SFBA_tracts %>% filter(str_detect(GEOID, "^06095")) %>% with_tract_populations()
tract_sample <- tract_geodata %>% st_sample(n = 1000, weight_var = "tract_pop_total")

ALA_block_geodata <- TIGER2015::TIGER2015_SFBA_blocks %>% filter(str_detect(GEOID10, "^06001")) %>% with_block_populations()
ALA_block_sample <- ALA_block_geodata %>% dplyr::select(block_id, block_pop_total) %>% st_sample(frac = 0.1, weight_var = "block_pop_total")

mapview::mapview(ALA_block_sample, cex = 1, color = NULL)


BAAQMD/geotools documentation built on Feb. 29, 2024, 5:44 a.m.