ah9
ah9

Reputation: 51

Alternative to clip for Features and Feature Collection in Google Earth Engine

I am very new to Google Earth Engine and I want to be able to perform a feature overlay analysis like shown in this ArcGIS document: http://resources.esri.com/help/9.3/arcgisdesktop/com/gp_toolref/geoprocessing/overlay_analysis.htm

I can't seem to find a method to help me do this in GEE. I have two FeatureCollections. Both are collections of around 50 polygons, one of study sites and one of regions and I want to find out where the sites overlap the regions and if they overlap, what proportion of the site is in each region it overlaps. I have tried to use "intersection" but this only shows me the area of the intersection between sites and regions. There is a "clip" method that would be useful to clip the sites to the regions they are in but this appears to only be available to images not feature collections. Do you have any suggestions of how I might do this?

Thanks

Upvotes: 5

Views: 6505

Answers (1)

Tristian
Tristian

Reputation: 81

Although QGIS does the job rather easily, as already stated by Rodrigo E. Principe in the comments, it is possible to do this in GEE as well.

As I understand from your question, you did not get a feature returned from calling intersect(). There are actually mutliple ways to call intersect, depending on the type of data you try to apply it to. For every way, the output might be slightly different as well (just check the docs tab in the code editor).

Now I will assume that both you study sites and regions are in a featureCollection. The study sites will be called studySites and the regions will be called regions. The code you are looking for looks something like this:

// Extract geometries from you regions 
// If you have one region (type: feature), do:
var regionGeom = region.geometry();
// for more than one region (type: featureCollection), do something like:
var regionGeom = region.map(function(f) {
  return f.geometry();
});

// Now map over your study sites and use intersect to clip them on the region(s)
var stuySitesClip = studySites.map(function(f) {
  return f.intersection(regionGeom, 1); //1 refers to the maxError argument
});

Another option might be to use the GEE plugin in QGIS and combine the powers from both worlds (although I do not have any experience in that yet, but it might be worth the effort to try).

Upvotes: 4

Related Questions