sentinelhub_batch

Module implementing an interface with Sentinel Hub Batch service

class sentinelhub.sentinelhub_batch.SentinelHubBatch(request_id=None, *, request_info=None, config=None)[source]

Bases: object

An interface class for Sentinel Hub Batch API

For more info check Batch API reference.

Parameters:
  • request_id (str or None) – A batch request ID
  • request_info (dict or None) – Information about batch request parameters obtained from the service. This parameter can be given instead of request_id
  • config (SHConfig or None) – A configuration object
classmethod create(sentinelhub_request, tiling_grid, output=None, bucket_name=None, description=None, config=None)[source]

Create a new batch request

Batch API reference

Parameters:
  • sentinelhub_request (SentinelHubRequest or dict) – An instance of SentinelHubRequest class containing all request parameters. Alternatively, it can also be just a payload dictionary for Process API request
  • tiling_grid (dict) – A dictionary with tiling grid parameters. It can be built with tiling_grid method
  • output (dict or None) – A dictionary with output parameters. It can be built with output method. Alternatively, one can set bucket_name parameter instead.
  • bucket_name (str or None) – A name of an s3 bucket where to save data. Alternatively, one can set output parameter to specify more output parameters.
  • description (str or None) – A description of a batch request
  • config (SHConfig or None) – A configuration object
static tiling_grid(grid_id, resolution, buffer=None, **kwargs)[source]

A helper method to build a dictionary with tiling grid parameters

Parameters:
  • grid_id (int) – An ID of a tiling grid
  • resolution (float or int) – A grid resolution
  • buffer ((int, int) or None) – Optionally, a buffer around each tile can be defined. It can be defined with a tuple of integers (buffer_x, buffer_y), which specifies a number of buffer pixels in horizontal and vertical directions.
  • kwargs – Any other arguments to be added to a dictionary of parameters
Returns:

A dictionary with parameters

Return type:

dict

static output(*, default_tile_path=None, cog_output=None, cog_parameters=None, create_collection=None, collection_id=None, responses=None, **kwargs)[source]

A helper method to build a dictionary with tiling grid parameters

Parameters:
  • default_tile_path (str or None) – A path or a template on an s3 bucket where to store results. More info at Batch API documentation
  • cog_output (bool or None) – A flag specifying if outputs should be written in COGs (cloud-optimized GeoTIFFs )or normal GeoTIFFs
  • cog_parameters (dict or None) – A dictionary specifying COG creation parameters
  • create_collection (bool or None) – If True the results will be written in COGs and a batch collection will be created
  • collection_id (str or None) – If True results will be added to an existing collection
  • responses (list or None) – Specification of path template for individual outputs/responses
  • kwargs – Any other arguments to be added to a dictionary of parameters
Returns:

A dictionary of output parameters

Return type:

dict

static iter_tiling_grids(config=None, **kwargs)[source]

An iterator over tiling grids

Batch API reference

Parameters:
  • config (SHConfig) – A configuration object
  • kwargs – Any other request query parameters
Returns:

An iterator over tiling grid definitions

Return type:

Iterator[dict]

static get_tiling_grid(grid_id, config=None)[source]

Provides a single tiling grid

Batch API reference

Parameters:
  • grid_id (str or int) – An ID of a requested tiling grid
  • config (SHConfig) – A configuration object
Returns:

A tiling grid definition

Return type:

dict

info

A dictionary with a Batch request information. It loads a new dictionary only if one doesn’t exist yet.

Returns:Batch request info
Return type:dict
update_info()[source]

Updates information about a batch request

Batch API reference

Returns:Batch request info
Return type:dict
evalscript

Provides an evalscript used by a batch request

Returns:An evalscript
Return type:str
bbox

Provides a bounding box used by a batch request

Returns:An area bounding box together with CRS
Return type:BBox
Raises:ValueError
geometry

Provides a geometry used by a batch request

Returns:An area geometry together with CRS
Return type:Geometry
Raises:ValueError
static iter_requests(user_id=None, config=None, **kwargs)[source]

Iterate existing batch requests

Batch API reference

Parameters:
  • user_id (str or None) – Filter requests by a user id who defined a request
  • config (SHConfig or None) – A configuration object
  • kwargs – Any additional parameters to include in a request query
Returns:

An iterator over existing batch requests

Return type:

Iterator[SentinelHubBatch]

static get_latest_request(config=None)[source]

Provides a batch request that has been created the latest

delete()[source]

Delete a batch job request

Batch API reference

start_analysis()[source]

Starts analysis of a batch job request

Batch API reference

start_job()[source]

Starts running a batch job

Batch API reference

cancel_job()[source]

Cancels a batch job

Batch API reference

restart_job()[source]

Restarts only those parts of a job that failed

Batch API reference

iter_tiles(status=None, **kwargs)[source]

Iterate over info about batch request tiles

Batch API reference

Parameters:
  • status (str or None) – A filter to obtain only tiles with a certain status
  • kwargs – Any additional parameters to include in a request query
Returns:

An iterator over information about each tile

Return type:

Iterator[dict]

get_tile(tile_id)[source]

Provides information about a single batch request tile

Batch API reference

Parameters:tile_id (int or None) – An ID of a tile
Returns:Information about a tile
Return type:dict
reprocess_tile(tile_id)[source]

Reprocess a single failed tile

Batch API reference

Parameters:tile_id (int or None) – An ID of a tile