3

I am converting a process that works in the Javascript code editor into Python and it fails at the point of export but the documentation seems very sparse. There is a similar question here but the solution doesn't seem to apply in my case (exporting a table vs an image).

I have calculated a confusion matrix and now have to export the results to avoid a time-out error. My working Javascript code is as follows:

var utterConfusion = validated.errorMatrix('class','classification');

Export.table.toDrive({
  collection: ee.FeatureCollection([
      ee.Feature(null, {
          'array': utterConfusion.array(),
          'accuracy': utterConfusion.accuracy(),
          'kappa': utterConfusion.kappa()
        }),
    ]),
    description: 'ConfusionMatrix',
    fileFormat: 'CSV'
});

My failing Python code is as follows:

collection = ee.FeatureCollection([
  ee.Feature(None, {
      'array': utterConfusion.array(),
      'accuracy': utterConfusion.accuracy(),
      'kappa': utterConfusion.kappa()
    }),
])

task_config = {
    'description': 'ConfusionMatrix_jupyter',
    'folder': 'Colab Notebooks',
    'fileFormat': 'CSV'
}

task = ee.batch.Export.table.toDrive(collection, **task_config)
task.start()

I have tried a few variations on this code (such as passing the arguments from task_config in the toDrive() call rather than as **kwargs) but I consistently get the same error (from task.status()):

'error_message': 'Collection.reduceColumns: Empty date ranges not supported for the current operation.'

This error messages doesn't seem related as I am exporting a table with null geometry - something that works perfectly in Javascript. No dates are involved. I get no errors leading up to the creation of the Confusion Matrix.

Can anybody shed some light on what I am doing wrong please?

EDIT: I originally used the format suggested by Nicholas in his answer below, but I get the same error.

Note that the only time I need to reference dates is in the filtering of my images, and this appears to work (at least the javascript variation does):
sen2_temporal_filter = sen2_spatial_filter.filterDate('2016-06-05', '2016-06-05')

I know that two images exist for the dat as given above but I have also tried extending the date range and it still returns the same error.

MappaGnosis
  • 1,179
  • 1
  • 11
  • 25

0 Answers0