I have a netCDF file ("SSP119.nc") containing information on land-use change from 2015 to 2100, inclusive (source: https://luh.umd.edu/data.shtml). I also have a shapefile containing polygons of global Key Biodiversity Areas (KBA). I want to know how much land area overlaps with the KBA polygons for certain land-use types in certain years (yep, it's complicated... but I hope my code makes it easier to understand).
As an aside, the land-use data contains information for 14 land-use types. The resolution is at 0.25 x 0.25 degree grid-cells. Each grid-cell contains the fraction of each land-use type within it, e.g., if one land-use type covers 60% of the grid-cell, its value will be 0.6.
Here is my code, so far:
SSP119_r_primf <- stack("SSP119.nc", varname = "primf") # this creates a raster stack of the
# land-use "primary forested area" from the netCDF file
SSP119_r_primf
`class : RasterStack
dimensions : 720, 1440, 1036800, 86 (nrow, ncol, ncell, nlayers)
resolution : 0.25, 0.25 (x, y)
extent : -180, 180, -90, 90 (xmin, xmax, ymin, ymax)
crs : +proj=longlat +datum=WGS84 +no_defs
names : X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14, ...
years since 2015-01-01 0:0:0: 0 - 85 (range)
`
proj4string(SSP119_r_primf) = CRS("+init=EPSG:4326")
plot(SSP119_r_primf) # will produce 86 plots of primary forested areas,
# annually between 2015 and 2100
primf_2100 <- subset(SSP119_r_primf, 86) # creates a subset of SSP119_r_primf
# specifically for the year 2100
plot(primf_2100) # to give you a visual idea of the data
[Primary forested land in year 2100](https://i.stack.imgur.com/TsVo7.png)
KBA <- readOGR("KBAsGlobal_2022_September_02_POL.shp") # to read in the KBA
# shapefile polygon data
Any ideas on the next steps? Thanks a million, appreciate any help!