TransWikia.com

Function to reduce and export summary data using biome feature collection in Google Earth Engine

Geographic Information Systems Asked on June 16, 2021

I want to be able to use a feature collection with continental biome classifications and reduced an NDVI trend I made for each biome on each continent. I know how to do this the very inefficient way, but is there a way to write a function that loops through all of the biomes in a single continent without me having to code it all out by hand?
This is what I have so far for one biome in one continent (I highly recommend looking at the script linked below):

var africa = continents.filter(ee.Filter.eq('CONTINENT','Africa'));
var asia = continents.filter(ee.Filter.eq('CONTINENT','Asia'));
var australia = continents.filter(ee.Filter.eq('CONTINENT','Australia'));
var europe = continents.filter(ee.Filter.eq('CONTINENT','Europe'));
var nam = continents.filter(ee.Filter.eq('CONTINENT','North America'));
var oceania = continents.filter(ee.Filter.eq('CONTINENT','Oceania'));
var sam = continents.filter(ee.Filter.eq('CONTINENT','South America'));


var cats = tnc.aggregate_array('WWF_MHTNAM');
var cats_list = ee.List(cats);
var biomes = cats_list.distinct()
print(biomes);

var tropical_coniferous_forests = tnc.filter(ee.Filter.eq('WWF_MHTNAM','Tropical and Subtropical Coniferous Forests'));
var africa_tropical_coniferous_forests_mean = fit_year_ndvi.reduceRegion({
  reducer: ee.Reducer.mean(),
  geometry: africa,
  scale: 500,
  tileScale:8,
  maxPixels: 1e12
});
Export.table.toDrive({
  collection: ee.FeatureCollection([
    ee.Feature(null, africa_tropical_coniferous_forests_mean)
  ]),
  description: 'africa_tropical_coniferous_forests_mean',
  fileFormat: 'CSV',
  folder: 'africa_biome_trends'
});

Link to script: https://code.earthengine.google.com/d23a5acd90580b3771075e4457163538

Link to continents asset: https://code.earthengine.google.com/?asset=users/anna_odell/continents

Link to "tnc" asset: https://code.earthengine.google.com/?asset=users/anna_odell/tnc_terr_ecoregions

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP