Extract summarized values from raster with points and a buffer radius
Source:R/processing.R
extract_at_buffer.Rd
For simplicity, it is assumed that the coordinate systems of the points and the raster are the same.
Usage
extract_at_buffer(
points = NULL,
surf = NULL,
radius = NULL,
id = NULL,
qsegs = 90L,
func = "mean",
kernel = NULL,
bandwidth = NULL,
extent = NULL,
max_cells = 2e+07,
...
)
extract_at_buffer_flat(
points = NULL,
surf = NULL,
radius = NULL,
id = NULL,
qsegs = NULL,
func = "mean",
kernel = NULL,
bandwidth = NULL,
max_cells = 2e+07,
...
)
extract_at_buffer_kernel(
points = NULL,
surf = NULL,
radius = NULL,
id = NULL,
qsegs = NULL,
func = stats::weighted.mean,
kernel = NULL,
bandwidth = NULL,
max_cells = 2e+07,
...
)
Arguments
- points
sf
/SpatVector
object. Coordinates where buffers will be generated.- surf
SpatRaster
object or file path(s) with extensions that are GDAL-compatible. A raster from which a summary will be calculated- radius
numeric(1). Buffer radius. Here we assume circular buffers only
- id
character(1). Unique identifier of each point.
- qsegs
integer(1). Number of vertices at a quarter of a circle. Default is
90L
.- func
a function taking a numeric vector argument.
- kernel
character(1). Name of a kernel function One of
"uniform"
,"triweight"
,"quartic"
, and"epanechnikov"
- bandwidth
numeric(1). Kernel bandwidth.
- extent
numeric(4) or SpatExtent. Extent of clipping vector. It only works with
points
of character(1) file path. When using numeric(4), it should be in the order ofc(xmin, xmax, ymin, ymax)
. The coordinate system should be the same as thepoints
.- max_cells
integer(1). Maximum number of cells in memory. See
exactextractr::exact_extract
for more details.- ...
Placeholder.
Note
When Sys.setenv("CHOPIN_FORCE_CROP" = "TRUE")
is set, the raster will be
cropped to the extent of the polygons (with snap
= "out"
).
To note, the function is designed to work with the exactextractr
package.
Arguments of exactextractr::exact_extract
are set as below
(default otherwise listed):
force_df
=TRUE
stack_apply
=TRUE
max_cells_in_memory
=2e8
progress
=FALSE
See also
Other Macros for calculation:
extract_at()
,
extract_at_poly()
,
kernelfunction()
,
summarize_aw()
,
summarize_sedc()
Author
Insang Song geoissong@gmail.com
Examples
library(terra)
rrast <- terra::rast(nrow = 100, ncol = 100)
terra::crs(rrast) <- "EPSG:5070"
terra::values(rrast) <- rgamma(1e4, 4, 2)
rpnt <- terra::spatSample(rrast, 100L, as.points = TRUE)
rpnt$pid <- sprintf("id_%03d", seq(1, 100))
extract_at_buffer(rpnt, rrast, 4, "pid")
#> pid mean
#> 1 id_001 1.651610
#> 2 id_002 1.375360
#> 3 id_003 1.869488
#> 4 id_004 1.879870
#> 5 id_005 1.830806
#> 6 id_006 2.203978
#> 7 id_007 2.025010
#> 8 id_008 2.104624
#> 9 id_009 2.044772
#> 10 id_010 1.882280
#> 11 id_011 1.506968
#> 12 id_012 2.049565
#> 13 id_013 1.596740
#> 14 id_014 2.027810
#> 15 id_015 1.891467
#> 16 id_016 2.026121
#> 17 id_017 1.724052
#> 18 id_018 1.845675
#> 19 id_019 1.516506
#> 20 id_020 1.870031
#> 21 id_021 1.701714
#> 22 id_022 2.313477
#> 23 id_023 2.263182
#> 24 id_024 1.995274
#> 25 id_025 2.431489
#> 26 id_026 2.374461
#> 27 id_027 2.080226
#> 28 id_028 1.700923
#> 29 id_029 1.962064
#> 30 id_030 2.107451
#> 31 id_031 2.165406
#> 32 id_032 2.240682
#> 33 id_033 2.274774
#> 34 id_034 2.040657
#> 35 id_035 1.396226
#> 36 id_036 1.964290
#> 37 id_037 1.866187
#> 38 id_038 1.559619
#> 39 id_039 1.822197
#> 40 id_040 1.903492
#> 41 id_041 2.117386
#> 42 id_042 1.392489
#> 43 id_043 2.339543
#> 44 id_044 2.585882
#> 45 id_045 1.813985
#> 46 id_046 2.156444
#> 47 id_047 1.653794
#> 48 id_048 1.688204
#> 49 id_049 1.952219
#> 50 id_050 2.010062
#> 51 id_051 2.029783
#> 52 id_052 2.473734
#> 53 id_053 2.347674
#> 54 id_054 1.847772
#> 55 id_055 1.885386
#> 56 id_056 2.378431
#> 57 id_057 2.591648
#> 58 id_058 2.317759
#> 59 id_059 1.790030
#> 60 id_060 1.946267
#> 61 id_061 1.878067
#> 62 id_062 1.625792
#> 63 id_063 1.669429
#> 64 id_064 2.041649
#> 65 id_065 2.333508
#> 66 id_066 1.969423
#> 67 id_067 1.440952
#> 68 id_068 2.481989
#> 69 id_069 1.950975
#> 70 id_070 1.949170
#> 71 id_071 1.800481
#> 72 id_072 1.727038
#> 73 id_073 1.856413
#> 74 id_074 2.165578
#> 75 id_075 2.798059
#> 76 id_076 2.008407
#> 77 id_077 1.824913
#> 78 id_078 2.024015
#> 79 id_079 1.740571
#> 80 id_080 2.040131
#> 81 id_081 2.149531
#> 82 id_082 2.495682
#> 83 id_083 2.375884
#> 84 id_084 1.835961
#> 85 id_085 1.960443
#> 86 id_086 2.293348
#> 87 id_087 2.268371
#> 88 id_088 2.319497
#> 89 id_089 1.744779
#> 90 id_090 1.748024
#> 91 id_091 2.193364
#> 92 id_092 2.249387
#> 93 id_093 2.230290
#> 94 id_094 2.054080
#> 95 id_095 2.208818
#> 96 id_096 1.823460
#> 97 id_097 1.687319
#> 98 id_098 1.775530
#> 99 id_099 1.922610
#> 100 id_100 2.047888