MCPcopy
hub / github.com/google/earthengine-api / _build_image_file_export_options

Function _build_image_file_export_options

python/ee/batch.py:1427–1531  ·  view source on GitHub ↗

Builds an ImageFileExportOptions from values in a config dict. Args: config: All the user-specified export parameters. Will be modified in-place by removing parameters used in the ImageFileExportOptions. export_destination: One of the Task.ExportDestination values. Returns: A

(
    config: dict[str, Any], export_destination: str
)

Source from the content-addressed store, hash-verified

1425
1426
1427def _build_image_file_export_options(
1428 config: dict[str, Any], export_destination: str
1429) -> dict[str, Any]:
1430 """Builds an ImageFileExportOptions from values in a config dict.
1431
1432 Args:
1433 config: All the user-specified export parameters. Will be modified in-place
1434 by removing parameters used in the ImageFileExportOptions.
1435 export_destination: One of the Task.ExportDestination values.
1436
1437 Returns:
1438 An ImageFileExportOptions containing information extracted from config.
1439 """
1440 file_export_options = {}
1441
1442 file_format = _cloud_api_utils.convert_to_image_file_format(
1443 config.pop('fileFormat'))
1444 file_export_options['fileFormat'] = file_format
1445
1446 if export_destination == Task.ExportDestination.DRIVE:
1447 file_export_options['driveDestination'] = _build_drive_destination(
1448 config)
1449 elif export_destination == Task.ExportDestination.GCS:
1450 file_export_options[
1451 'cloudStorageDestination'] = _build_cloud_storage_destination(
1452 config)
1453 else:
1454 raise ee_exception.EEException(
1455 f'"{export_destination}" is not a valid export destination'
1456 )
1457
1458 file_format_options = config.pop(IMAGE_FORMAT_OPTIONS_FIELD, {})
1459
1460 if file_format == 'GEO_TIFF':
1461 geo_tiff_options = {}
1462 if file_format_options.pop('cloudOptimized', False):
1463 geo_tiff_options['cloudOptimized'] = True
1464 if 'noData' in file_format_options:
1465 geo_tiff_options['noData'] = {
1466 'floatValue': file_format_options.pop('noData')
1467 }
1468 file_dimensions = file_format_options.pop('fileDimensions', None)
1469 if 'fileDimensions' in config:
1470 if file_dimensions is not None:
1471 raise ee_exception.EEException('File dimensions specified twice.')
1472 file_dimensions = config.pop('fileDimensions')
1473 if file_dimensions is not None:
1474 if isinstance(file_dimensions, int):
1475 file_dimensions = (file_dimensions, file_dimensions)
1476 geo_tiff_options['tileDimensions'] = {
1477 'width': file_dimensions[0],
1478 'height': file_dimensions[1]
1479 }
1480 if config.pop('skipEmptyTiles', False):
1481 geo_tiff_options['skipEmptyFiles'] = True
1482 if config.get('shardSize', None):
1483 geo_tiff_options['tileSize'] = {'value': config.pop('shardSize')}
1484 if geo_tiff_options:

Callers 2

Calls 3

_build_drive_destinationFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected