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

Function _prepare_image_export_config

python/ee/batch.py:1177–1261  ·  view source on GitHub ↗

Performs all preparation steps for an image export. Args: image: The Image to be exported. config: All the user-specified export parameters. May be modified. export_destination: One of the Task.ExportDestination values. Returns: A config dict containing all information required

(
    image: _arg_types.Image,
    config: dict[str, Any],
    export_destination: Task.ExportDestination,
)

Source from the content-addressed store, hash-verified

1175
1176
1177def _prepare_image_export_config(
1178 image: _arg_types.Image,
1179 config: dict[str, Any],
1180 export_destination: Task.ExportDestination,
1181) -> dict[str, Any]:
1182 """Performs all preparation steps for an image export.
1183
1184 Args:
1185 image: The Image to be exported.
1186 config: All the user-specified export parameters. May be modified.
1187 export_destination: One of the Task.ExportDestination values.
1188
1189 Returns:
1190 A config dict containing all information required for the export.
1191 """
1192 # Supply some defaults.
1193 if (export_destination != Task.ExportDestination.ASSET and
1194 'fileFormat' not in config):
1195 config['fileFormat'] = 'GeoTIFF'
1196
1197 _canonicalize_parameters(config, export_destination)
1198
1199 image, config = image.prepare_for_export(config)
1200 # Build an ExportImageRequest. Delete values from "config" as we go so we
1201 # can check at the end for any leftovers. Any computed objects will be
1202 # serialised in data.py before the request is sent.
1203 request = {}
1204 request['expression'] = image
1205 if 'description' in config:
1206 request['description'] = config.pop('description')
1207
1208 if export_destination == Task.ExportDestination.ASSET:
1209 asset_export_options = {}
1210 asset_export_options[
1211 'earthEngineDestination'] = _build_earth_engine_destination(config)
1212 # This can only be set by internal users.
1213 if 'tileSize' in config and 'shardSize' in config:
1214 raise ee_exception.EEException(
1215 'Both "shardSize" and "tileSize" cannot be set.')
1216 if 'tileSize' in config:
1217 asset_export_options['tileSize'] = {
1218 'value': int(config.pop('tileSize'))}
1219 # "shardSize" is the old name for "tileSize".
1220 if 'shardSize' in config:
1221 asset_export_options['tileSize'] = {'value': int(config.pop('shardSize'))}
1222 if 'pyramidingPolicy' in config:
1223 pyramiding_policy = config.pop('pyramidingPolicy')
1224 if '.default' in pyramiding_policy:
1225 asset_export_options[
1226 'pyramidingPolicy'] = pyramiding_policy.pop('.default').upper()
1227 if pyramiding_policy:
1228 asset_export_options['pyramidingPolicyOverrides'] = {
1229 band: policy.upper() for band, policy in pyramiding_policy.items()
1230 }
1231 request['assetExportOptions'] = asset_export_options
1232 else:
1233 request['fileExportOptions'] = _build_image_file_export_options(
1234 config, export_destination)

Callers 3

toAssetMethod · 0.85
toCloudStorageMethod · 0.85
toDriveMethod · 0.85

Tested by

no test coverage detected