1

I'm new to Google Earth Engine.

I'm using ee.ImageCollection("GOOGLE/DYNAMICWORLD/V1") to look at land use types (specifically tree cover - band 1) within a specific shp file area.

I want to produce several map layers by calendar year, e.g. for the years 2022 and 2023 (separately). Ultimately, I want to aggregate into 300m cells (for 300m cells where at least 50% of a cell overlaps with my target shp area) and calculate % of 10m cells within each 300m aggregate cell that are classed as trees in each year.

I want to be able to compare the same 300m cells each year to track how their individual % tree cover values are changing. I'd want to be able to export an csv/Excel for a specific calendar year with a list of 300m cells and their % tree cover (i.e. % of 10m cells classed as trees).

I'm focusing only on Madagascar, so am looking first to clip the dataset to the Madagascar country boundary to reduce the size of the file I'm dealing with. The below isn't working:

var madagascar = ee.FeatureCollection('USDOS/LSIB_SIMPLE/2017')
  .filter(ee.Filter.eq('country_na', 'Madagascar'));

// load land type data, filtered by year
var dynamic = ee.ImageCollection("GOOGLE/DYNAMICWORLD/V1")
    .filterDate('2022-01-01', '2022-12-31')
    .filterBounds(menabe);

// Make a composite.
var composite = ee.Algorithms.Landsat.simpleComposite({
  collection: dynamic,
  asFloat: true
});

// Clip composite to Madagascar
var clipped_composite = composite.clip(madagascar);

// Visualize the clipped composite 
Map.addLayer(clipped_composite);

The error is:

Layer 1: Layer error: Landsat.simpleComposite: ImageCollection band names do not match a Landsat instrument.

1
  • Landsat.simpleComposite: ImageCollection band names do not match a Landsat instrument because it is a GOOGLE/DYNAMICWORLD/V1 product. You cannot use that algorithm (ee.Algorithms.Landsat and its simpleComposite method). You need to try another approach for producing the composite.
    – xunilk
    Commented Jul 19 at 22:15

1 Answer 1

0

GOOGLE/DYNAMICWORLD/V1 product has a lot of images for Madagascar entire country and GEE can freeze without any result. So, as I saw in your filterBounds method the region of Menabe (one of 22 possible), I used that region for mosaicking all Image Collection instead.

Complete code can be observed as follows:

var dataset = ee.FeatureCollection('FAO/GAUL/2015/level2');

print(dataset.aggregate_array('ADM0_NAME').distinct().sort());

var madagascar = dataset.filter(ee.Filter.eq('ADM0_NAME', 'Madagascar'));

Map.addLayer(madagascar, {}, 'Madagascar', false);

print(madagascar.aggregate_array('ADM1_NAME').distinct().sort());

var menabe = dataset.filter(ee.Filter.eq('ADM1_NAME', 'Menabe'));

print(menabe);

Map.addLayer(menabe, {}, 'Menabe');

// load land type data, filtered by year
var dynamic = ee.ImageCollection("GOOGLE/DYNAMICWORLD/V1")
    .filterDate('2022-01-01', '2022-12-31')
    .filterBounds(menabe);

//print(dynamic);

// Make a composite.
var mosaic = dynamic.mosaic();

// Clip composite to Madagascar
var clipped_mosaic = mosaic.clip(menabe);

// Visualize the clipped composite 
Map.addLayer(clipped_mosaic);
Map.centerObject(menabe, 8);

After running it in GEE code editor, the result looks as in the following picture.

enter image description here

In above image, each color represents each one of nine classes founded in GOOGLE/DYNAMICWORLD/V1 product (green light, label 1, corresponds to trees and red, label 0, to water). I hope it helps.

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.