3

I am working with FeatureCollection('WCMC/WDPA/current/polygons') and ImageCollection('LANDSAT/LC08/C01/T1_ANNUAL_EVI'). I would like to add a filter to the WCMC/WDPA data to display only Parks Canada protected areas. I have tried the following code lines with no success.

.filterMetadata('country', 'equals', 'Canada')  
.filterMetadata('MANG_AUTH', 'equals', Parks Canada);

The following two scripts load successfully.

var dataset = ee.FeatureCollection('WCMC/WDPA/current/polygons')
var visParams = {
  palette: ['2ed033', '5aff05', '67b9ff', '5844ff', '0a7618', '2c05ff'],
  min: 0.0,
  max: 1550000.0,
  opacity: 0.8,
};  
var image = ee.Image().float().paint(dataset, 'REP_AREA');  
Map.setCenter(41.104, -17.724, 6);  
Map.addLayer(image, visParams, 'WCMC/WDPA/current/polygons');  
Map.addLayer(dataset, null, 'for Inspector', false);  
var dataset = ee.ImageCollection('LANDSAT/LC08/C01/T1_ANNUAL_EVI')
                  .filterDate('2017-01-01', '2017-12-31');  
var colorized = dataset.select('EVI');  
var colorizedVis = {
  min: 0.0,
  max: 1.0,
  palette: [
    'FFFFFF', 'CE7E45', 'DF923D', 'F1B555', 'FCD163', '99B718', '74A901',
    '66A000', '529400', '3E8601', '207401', '056201', '004C00', '023B01',
    '012E01', '011D01', '011301'
  ],
};  
Map.setCenter(6.746, 46.529, 6);
Map.addLayer(colorized, colorizedVis, 'Colorized');

1 Answer 1

0

It turns out that Parks Canada as an entry of "MANG_AUTH" is labeled "Parks Canada / Ministère des Forêts, de la Faune et des Parcs", which is likely why your filter did not work. Additionally, the "WCMC/WDPA/current/polygons" FeatureCollection does not contain a property titled: "country".

The ee.Filter.stringContains collection filter can be helpful if you are unsure of the exact name of a property entry of interest:

// Import the protected areas FeatureCollection.
var dataset = ee.FeatureCollection('WCMC/WDPA/current/polygons');

// Filter to 'MANG_AUTH' eq 'Parks Canada' using stringContains..
var parksCanada = dataset.filter(ee.Filter.stringContains('MANG_AUTH', 'Parks Canada'));

// Map the features.
Map.addLayer(parksCanada);

To see a full list of available entries for a property, you can use something like this to print the unique list.

print(ee.List(dataset.aggregate_array('MANG_AUTH')).distinct().sort());

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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