Here's an example that hopefully does something like what you want, but you'll need to modify it to meet your requirements for "manually selected marker points" and Sentinel 2.
In general, do NOT use for-loops or getInfo()
. To be clear, DO NOT USE FOR LOOPS unless you have a very good reason to be doing so. If you don't know, use map()
for all the reasons described here, here, here and here. (And check the same guides for why to NOT use getInfo()
or convert to a list as I've done here.) The reason it's OK to do this here (necessary, in fact) is because Export
is a client side function and you can't use a client function in map()
.
// Get some imagery to play with.
var landsat = ee.ImageCollection("LANDSAT/LC08/C01/T1")
.filterDate('2016-01-01', '2017-01-01');
var composite = ee.Algorithms.Landsat.simpleComposite({
collection: landsat,
asFloat: true
});
var rgbVis = {bands: ["B4", "B3", "B2"], min:0, max: 0.3};
Map.addLayer(composite, rgbVis, "RGB");
// This is a hacky way to get a pixel grid at arbitrary resolution.
var pixels = ee.Image.random().multiply(10000000).toInt32()
.reduceToVectors({
reducer: ee.Reducer.countEvery(),
geometry: Map.getBounds(true),
geometryType: 'bb' ,
eightConnected: false,
scale: 20000,
crs: 'EPSG:4326'
});
Map.addLayer(pixels);
// Only do this is you have a few regions. Not suitable for
// large feature collections.
var pixelsList = pixels.toList(pixels.size());
// This is one of the few places in the EE API where you need
// a for-loop and a getInfo() call. Export is a client function.
for (var i=0; i<pixels.size().getInfo(); i++) {
Export.image.toDrive({
image: composite,
description: 'foo_' + i,
fileNamePrefix: 'foo_' + i,
region: ee.Feature(pixelsList.get(i)).geometry(),
scale: 30,
});
}
If you really need precise control over the export regions, you can make lists of coordinates and turn those into a collection of the ROIs you want to export. All that aside, you still need to click 'Run' on the exports. If you want it completely automated, use the Python API and ee.batch.Export
followed by task.start()
.
Without sharing the table it is impossible to recreate your error. You could share the complete script by using the "Get Link" button.
If you want to export the error matrix you need to cast it to a FeatureCollection first - just as the error message tells you.
var exportAccuracy = ee.Feature(null, {matrix: testAccuracy.array()})
// Export the FeatureCollection.
Export.table.toDrive({
collection: ee.FeatureCollection(exportAccuracy),
description: 'exportAccuracy',
fileFormat: 'CSV'
});
Best Answer
Calling
dataset.style()
doesn't just add styling information; it converts theFeatureCollection
into anImage
with the features painted using that style.style()
. There is no way to convey the style information in a CSV, anyway.Export.image
instead ofExport.table
.