nearExtract | R Documentation |
Add a circular buffer to a point until a valid raster value is extracted
nearExtract(x, y, fun = mean, b = NULL, bstep = NULL, ...)
x |
raster layer |
y |
sf points object |
b |
optional, inital buffer radius, or vector of buffer radii in metres |
bstep |
optional, incremental buffer radius increase in metres |
... |
additional arguments passed to |
A dataframe as returned by terra::extract()
with an additional
column b
, which specifies the radius of the buffer necessary to
intersect a valid raster pixel.
r <- rast(nrows = 100, ncols = 100, xmin = 0, xmax = 1, ymin = 0, ymax = 1)
values(r) <- seq(0, 100, length.out = 100*100)
p <- data.frame(
id = LETTERS[1:10],
lon = seq(-0.5, 1.5, length.out = 10),
lat = seq(-0.5, 1.5, length.out = 10))
psf <- st_as_sf(p, coords = c("lon", "lat"), crs = 4326)
crs(r) <- crs(psf)
nearExtract(r, psf)
nearExtract(r, psf, b = 1000)
nearExtract(r, psf, b = 1000, bstep = 10000)
nearExtract(r, psf, bstep = 10000)
nearExtract(r, psf, fun = min)
nearExtract(r, psf, fun = min, method="bilinear")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.