7.10 Extraction

A very common use case for raster data cube analysis is the extraction of values at certain locations, or computing aggregations over certain geometries

set.seed(115517)
pts <- st_bbox(r) |> st_as_sfc() |> st_sample(20)
(e <- st_extract(r, pts))
## stars object with 2 dimensions and 1 attribute
## attribute(s):
##              Min. 1st Qu. Median     Mean 3rd Qu. Max.
## L7_ETMs.tif    12   41.75     63 60.95833    80.5  145
## dimension(s):
##          from to                     refsys point
## geometry    1 20 SIRGAS 2000 / UTM zone 25S  TRUE
## band        1  6                         NA    NA
##                                                         values
## geometry POINT (293002.2 9115516),...,POINT (290941.1 9114128)
## band                                                      NULL