Given a stars data object and shapefile, extracts the relevant data using exactextractr::exact_extract(). Stars inputs should be in raster format with x and y dimensions. This function is planned for deprecation whenever direct support for exact_extract() is better supported via stars::aggregate().

dgg_extract(dat, dgg, var = NULL, fun, progress = FALSE)

Arguments

dat

The raster data to extract.

dgg

Shapefile containing the DGG boundaries to use for the extraction.

var

The variable to extract.

fun

The function to pass to exactextractr::exact_extract().

Value

Examples

dgg_extract(hyde_med, dgg_med, 'crops', 'sum')
#> stars object with 2 dimensions and 1 attribute #> attribute(s): #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> crops 0 0.2012841 3.241196 11.98653 15.58761 95.97917 #> dimension(s): #> from to offset delta refsys point #> geometry 1 7036 NA NA WGS 84 FALSE #> time 1 6 NA NA NA NA #> values #> geometry POLYGON ((29.14886 30.80048...,...,POLYGON ((38.837 39.99234, ... #> time 3000BC,...,2000AD