2

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?

  • You can do your analysis in GEE also, and just export the results. FYI. – Jon Apr 12 at 17:07
  • I thought about that too (even though I don't know how), but in the end I need 100x100m² grids for certain countries and I think that's too much for GEE. Apart from that I need R for the analysis later on anyway. – tho_mi Apr 12 at 17:09
  • You'd be surprised at what GEE will export! I don't use r so I don't think I can help, but it sounds like you want something like Zonal Statistics (QGIS) or rasterstats (python). These packages will return statistics of rasters within polygon boundaries. I am sure that there is a similar package for r. – Jon Apr 12 at 19:27
  • I'd be very happy to use GEE for more than just downloading the raw data @Jon. Unfortunately my experience with GEE is limited and it seems to be much easier to find info on how to do this in R. But I'd be very grateful for GEE-related tips :) – tho_mi Apr 13 at 2:56
  • You should have access to the GEE developer's forum--it's the best place to "google" for GEE-related questions and steal/borrow code. GEE's documentation also has a lot of helpful mini-tutorials; you should look at developers.google.com/earth-engine/reducers_reduce_regions, and more generally become familiar with "reducers". – Jon Apr 13 at 17:13
0

It sounds like 'Extract by Mask' is what you need. Here's info... https://support.esri.com/en/technical-article/000013000

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

  • Thanks for the hint. Since I need it in R (or GEE) I'll google a bit. – tho_mi Apr 13 at 3:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.