I have land cover data from GEE (https://developers.google.com/earth-engine/datasets/catalog/ESA_GLOBCOVER_L4_200901_200912_V2_3) for specific countries. I would like to extract the values from the raster for certain regions. Specifically, I'd like to have a SpatialPolygonsDataFrame with one variable for each land cover class containing the area (absolute or relative) of that region covered in a specific class. My first idea was to transform the raster into a SpatialPolygons object and then calculate the intersection, but from what I read transforming rasters is quite inefficient and functions like extract should be used. How can I achieve what I want without transforming the raster?
edit: Sorry, I feel like title and text don't really match. My original idea was to convert the raster, then create a subset only containing areas with a certain values, then calculating intersections and distances. Is it possible to do this with the raster too?