Generate Regularly Spaced Points Inside Polygons
Source:R/ngr_spk_poly_to_points.R
ngr_spk_poly_to_points.Rd
This function generates a regularly spaced grid of points inside each polygon
in a given sf
object and assigns it an ID. The point density is determined by a specified column.
See also
Other spacehakr:
ngr_spk_ext_raster()
,
ngr_spk_gdalwarp()
,
ngr_spk_odm()
,
ngr_spk_res()
Examples
poly <- sf::st_sf(
region = c("A", "B"),
col_density = c(1, 5),
geometry = sf::st_sfc(
sf::st_polygon(list(rbind(c(0, 0), c(10, 0), c(10, 10), c(0, 10), c(0, 0)))),
sf::st_polygon(list(rbind(c(15, 15), c(20, 15), c(20, 20), c(15, 20), c(15, 15))))
)
)
points <- ngr_spk_poly_to_points(poly, col_density = "col_density", col_id = "region")
plot(sf::st_geometry(poly))
plot(sf::st_geometry(points), add = TRUE, col = "red", pch = 16)