Get the URL for a thumbnail of this collection. Args: valid_formats: A list of supported formats, the first of which is used as a default if no format is supplied in 'params'. params: Parameters identical to getMapId, plus, optionally: dimensions - (a number or
(
self,
valid_formats: Sequence[str],
# TODO(user): Need to drop the default None and use dict[str, Any]]
params: Any | None = None,
thumbType: str | None = None, # pylint: disable=g-bad-name
)
| 252 | return self._getThumbURL(['png', 'jpg'], params, thumbType='filmstrip') |
| 253 | |
| 254 | def _getThumbURL( |
| 255 | self, |
| 256 | valid_formats: Sequence[str], |
| 257 | # TODO(user): Need to drop the default None and use dict[str, Any]] |
| 258 | params: Any | None = None, |
| 259 | thumbType: str | None = None, # pylint: disable=g-bad-name |
| 260 | ) -> str: |
| 261 | """Get the URL for a thumbnail of this collection. |
| 262 | |
| 263 | Args: |
| 264 | valid_formats: A list of supported formats, the first of which is used as |
| 265 | a default if no format is supplied in 'params'. |
| 266 | params: Parameters identical to getMapId, plus, optionally: |
| 267 | dimensions - |
| 268 | (a number or pair of numbers in format WIDTHxHEIGHT) Max dimensions of |
| 269 | the thumbnail to render, in pixels. If only one number is passed, it is |
| 270 | used as the maximum, and the other dimension is computed by proportional |
| 271 | scaling. |
| 272 | crs - a CRS string specifying the projection of the output. |
| 273 | crs_transform - the affine transform to use for the output pixel grid. |
| 274 | scale - a scale to determine the output pixel grid; ignored if both crs |
| 275 | and crs_transform are specified. |
| 276 | region - (E,S,W,N or GeoJSON) Geospatial region of the result. By default, |
| 277 | the whole image. |
| 278 | format - (string) The output format |
| 279 | thumbType: must be either 'video' or 'filmstrip'. |
| 280 | |
| 281 | Returns: |
| 282 | A URL to download a thumbnail of the specified ImageCollection. |
| 283 | |
| 284 | Raises: |
| 285 | EEException: If the region parameter is not an array or GeoJSON object. |
| 286 | """ |
| 287 | def map_function(input_image, input_params): |
| 288 | # pylint: disable=protected-access |
| 289 | output_image, request = input_image._apply_spatial_transformations( |
| 290 | input_params) |
| 291 | output_image, request = output_image._apply_visualization(request) |
| 292 | # pylint: enable=protected-access |
| 293 | return output_image, request |
| 294 | |
| 295 | clipped_collection, request = self._apply_preparation_function( |
| 296 | map_function, params) |
| 297 | |
| 298 | assert params is not None |
| 299 | request['format'] = params.get('format', valid_formats[0]) |
| 300 | if request['format'] not in valid_formats: |
| 301 | raise ee_exception.EEException( |
| 302 | f'Invalid format specified for thumbnail: "{request["format"]}"' |
| 303 | ) |
| 304 | |
| 305 | if params and 'framesPerSecond' in params: |
| 306 | request['framesPerSecond'] = params.get('framesPerSecond') |
| 307 | request['image'] = clipped_collection |
| 308 | if params and params.get('dimensions') is not None: |
| 309 | request['dimensions'] = params.get('dimensions') |
| 310 | if thumbType not in ['video', 'filmstrip']: |
| 311 | raise ee_exception.EEException( |
no test coverage detected