2

How do I export a table (CSV) without .geo and system:index in Google Earth Engine?

These two parameters are automatically added when I make a feature.

What I'm trying to do is extract some properties from Image Collection and export CSV of them.

var featColl = someImgCollection.map(function (image) {
    var someValA = image.get("someValueA");
    var someValB = image.get("someValueB");
    var object = {
        someValueA: someValA,
        someValueB: someValB
    }
    var feature = ee.Feature(null, object);  
    return feature;
});

Export.table.toDrive({
    collection: featureCollection,
    fileFormat: 'CSV'
});

Then I'd like to remove "system:index" and ".geo" from the result.

system:index someValueA someValueB .geo
2020_01_01 20 34
2020_01_02 14 21

2 Answers 2

3

You simply provide an array of the properties/columns you want exported in the selectors property.

var collection = ee.FeatureCollection([
  ee.Feature(ee.Geometry.Point([0, 0]), {
    foo: 'A',
    bar: 'B'
  })
])

Export.table.toDrive({
    collection: collection,
    selectors: ['foo', 'bar']
});

https://code.earthengine.google.com/b1a512469bb452a2f5a5e84c2bf52a39

1
  • Thank you! It's a useful option. I'm ashamed of myself spending some time without checking docs well and also sorry for the duplicated questions, I just found. gis.stackexchange.com/questions/348606/…
    – leccmo
    Commented May 28, 2021 at 8:09
0

I have a solution using .select() for when you are dealing with a lot of properties. If you just want to select all except exporting the .geo values to the csv, you can try this one:

var collection = ee.FeatureCollection([ee.Feature(ee.Geometry.Polygon(
    [[[-54.11113281250001, 37.461515212585624],
      [-54.46269531250001, 36.760625534542804],
      [-54.37480468750001, 35.41116773646161],
      [-49.80449218750001, 35.482768058471024],
      [-50.59550781250001, 38.91214931918128],
      [-54.46269531250001, 38.224974683387785]]]),  {
foo: 'A',
bar: 'B',
foo2: 'A',
bar2: 'B',
foo3: 'A',
bar3: 'B'  })]);

Export.table.toDrive({
collection: collection.select(['.*'],null,false)});

Please find the test link here: https://code.earthengine.google.com/b89b4a3bf5dd258e61e7e99d5fd43d79

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.