google-earth-engine,export,error,features,feature-collection – How to Fix Error When Exporting FeatureCollection in Google Earth Engine

errorexportfeature-collectionfeaturesgoogle-earth-engine

I got an Error: "Invalid argument: 'collection' must be a FeatureCollection. (Error code: 3)", when I was trying to export FeatureCollection. Geometry was a rectangle I draw to clip the featurecolletion.

var dataset = ee.FeatureCollection('LARSE/GEDI/GEDI02_A_002/GEDI02_A_2021244154857_O15413_04_T05622_02_003_02_V002')
              .filterBounds(geometry);
dataset = dataset.style({color: 'black',  pointSize: 1});
Map.setCenter(-64.88, -31.77, 15);
Map.addLayer(dataset);

Export.table.toDrive({
collection: dataset,
description:"GEDI",
fileFormat: 'csv'
});

However, it worked if I replace 'collection: dataset' with 'collection: ee.FeatureCollection('LARSE/GEDI/GEDI02_A_002/GEDI02_A_2021244154857_O15413_04_T05622_02_003_02_V002').filterBounds(geometry)'. I'm not sure why I can't export dataset here.

Best Answer

Calling dataset.style() doesn't just add styling information; it converts the FeatureCollection into an Image with the features painted using that style.

  • If you want to export features to a table, don't call style(). There is no way to convey the style information in a CSV, anyway.
  • If you want to see a picture with the specific style you have chosen, you will have to Export.image instead of Export.table.