When I export an image in GEE code editor I can pass a geometry to the 'region' parameter without problem. However, it doesn't work for Python API and I get below error for the shown code:
task = ee.batch.Export.image.toCloudStorage(
image=imageOfSeries.toArray(),
description=AssetName,
fileNamePrefix=AssetName,
bucket=GCbucketName,
scale=scale,
region=box,
fileFormat='TFRecord',
formatOptions={
'patchDimensions': [patch_size, patch_size],
'tensorDepths': [tDepth],
'compressed': True
}
)
Traceback (most recent call last):
File "D:/Shahriar/OneDrive - SUNY ESF/Thesis/Codes/Landsat_Classification/ExtractLandsatArrayImage.py", line 205, in <module>
'compressed': True
File "C:\Python36\lib\site-packages\ee\batch.py", line 332, in toCloudStorage
Task.ExportDestination.GCS)
File "C:\Python36\lib\site-packages\ee\batch.py", line 854, in _prepare_image_export_config
_canonicalize_parameters(config, export_destination)
File "C:\Python36\lib\site-packages\ee\batch.py", line 1418, in _canonicalize_parameters
config['region'] = _canonicalize_region(config['region'])
File "C:\Python36\lib\site-packages\ee\batch.py", line 1503, in _canonicalize_region
return json.dumps(region)
File "C:\Python36\lib\json\__init__.py", line 231, in dumps
return _default_encoder.encode(obj)
File "C:\Python36\lib\json\encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "C:\Python36\lib\json\encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "C:\Python36\lib\json\encoder.py", line 180, in default
o.__class__.__name__)
TypeError: Object of type 'Geometry' is not JSON serializable
How can I solve this problem?