ogc

Module for working with Sentinel Hub OGC services

class sentinelhub.ogc.OgcService(base_url=None, instance_id=None)[source]

Bases: object

The base class for Sentinel Hub OGC services

Parameters:
  • base_url (str or None) – base url of Sentinel Hub’s OGC services. If None, the url specified in the configuration file is taken.
  • instance_id (str or None) – user’s instance id granting access to Sentinel Hub’s OGC services. If None, the instance ID specified in the configuration file is taken.
class sentinelhub.ogc.OgcImageService(**kwargs)[source]

Bases: sentinelhub.ogc.OgcService

Sentinel Hub OGC services class for providing image data

Intermediate layer between QGC-type requests (WmsRequest and WcsRequest) and the Sentinel Hub OGC (WMS and WCS) services.

Parameters:
  • base_url (str or None) – base url of Sentinel Hub’s OGC services. If None, the url specified in the configuration file is taken.
  • instance_id (str or None) – user’s instance id granting access to Sentinel Hub’s OGC services. If None, the instance ID specified in the configuration file is taken.
get_request(request)[source]

Get download requests

Create a list of DownloadRequests for all Sentinel-2 acquisitions within request’s time interval and acceptable cloud coverage.

Parameters:request (OgcRequest or GeopediaRequest) – QGC-type request with specified bounding box, time interval, and cloud coverage for specific product.
Returns:list of DownloadRequests
get_url(request, *, date=None, size_x=None, size_y=None, geometry=None)[source]

Returns url to Sentinel Hub’s OGC service for the product specified by the OgcRequest and date.

Parameters:
  • request (OgcRequest or GeopediaRequest) – OGC-type request with specified bounding box, cloud coverage for specific product.
  • date (datetime.datetime or None) – acquisition date or None
  • size_x (int or str) – horizontal image dimension
  • size_y (int or str) – vertical image dimension
Returns:

dictionary with parameters

Returns:

url to Sentinel Hub’s OGC service for this product.

Return type:

str

get_base_url(request)[source]

Creates base url string.

Parameters:request (OgcRequest or GeopediaRequest) – OGC-type request with specified bounding box, cloud coverage for specific product.
Returns:base string for url to Sentinel Hub’s OGC service for this product.
Return type:str
static get_filename(request, date, size_x, size_y)[source]

Get filename location

Returns the filename’s location on disk where data is or is going to be stored. The files are stored in the folder specified by the user when initialising OGC-type of request. The name of the file has the following structure:

{service_type}_{layer}_{crs}_{bbox}_{time}_{size_x}X{size_y}_*{custom_url_params}.{image_format}

In case of TIFF_d32f a ‘_tiff_depth32f’ is added at the end of the filename (before format suffix) to differentiate it from 16-bit float tiff.

Parameters:
  • request (OgcRequest or GeopediaRequest) – OGC-type request with specified bounding box, cloud coverage for specific product.
  • date (datetime.datetime or None) – acquisition date or None
  • size_x (int or str) – horizontal image dimension
  • size_y (int or str) – vertical image dimension
Returns:

filename for this request and date

Return type:

str

static filename_add_custom_url_params(filename, request)[source]

Adds custom url parameters to filename string

Parameters:
  • filename (str) – Initial filename
  • request (OgcRequest or GeopediaRequest) – OGC-type request with specified bounding box, cloud coverage for specific product.
Returns:

Filename with custom url parameters in the name

Return type:

str

static finalize_filename(filename, file_format=None)[source]

Replaces invalid characters in filename string, adds image extension and reduces filename length

Parameters:
  • filename (str) – Incomplete filename string
  • file_format (MimeType) – Format which will be used for filename extension
Returns:

Final filename string

Return type:

str

get_dates(request)[source]

Get available Sentinel-2 acquisitions at least time_difference apart

List of all available Sentinel-2 acquisitions for given bbox with max cloud coverage and the specified time interval. When a single time is specified the request will return that specific date, if it exists. If a time range is specified the result is a list of all scenes between the specified dates conforming to the cloud coverage criteria. Most recent acquisition being first in the list.

When a time_difference threshold is set to a positive value, the function filters out all datetimes which are within the time difference. The oldest datetime is preserved, all others all deleted.

Parameters:request (WmsRequest or WcsRequest) – OGC-type request
Returns:List of dates of existing acquisitions for the given request
Return type:list(datetime.datetime) or [None]
static get_image_dimensions(request)[source]

Verifies or calculates image dimensions.

Parameters:request (WmsRequest or WcsRequest) – OGC-type request
Returns:horizontal and vertical dimensions of requested image
Return type:(int or str, int or str)
get_wfs_iterator()[source]

Returns iterator over info about all satellite tiles used for the request

Returns:Iterator of dictionaries containing info about all satellite tiles used in the request. In case of DataSource.DEM it returns None.
Return type:Iterator[dict] or None
class sentinelhub.ogc.WebFeatureService(bbox, time_interval, *, data_source=<DataSource.SENTINEL2_L1C: (<_Source.SENTINEL2: 'Sentinel-2'>, <_ProcessingLevel.L1C: 'L1C'>)>, maxcc=1.0, **kwargs)[source]

Bases: sentinelhub.ogc.OgcService

Class for interaction with Sentinel Hub WFS service

The class is an iterator over info data of all available satellite tiles for requested parameters. It collects data from Sentinel Hub service only during the first iteration. During next iterations it returns already obtained data. The data is in the order returned by Sentinel Hub WFS service.

Parameters:
  • bbox (geometry.BBox) – Bounding box of the requested image. Coordinates must be in the specified coordinate reference system.
  • time_interval ((str, str)) – interval with start and end date of the form YYYY-MM-DDThh:mm:ss or YYYY-MM-DD
  • data_source (constants.DataSource) – Source of requested satellite data. Default is Sentinel-2 L1C data.
  • maxcc (float) – Maximum accepted cloud coverage of an image. Float between 0.0 and 1.0. Default is 1.0.
  • base_url (str or None) – base url of Sentinel Hub’s OGC services. If None, the url specified in the configuration file is taken.
  • instance_id (str or None) – user’s instance id granting access to Sentinel Hub’s OGC services. If None, the instance ID specified in the configuration file is taken.
get_dates()[source]

Returns a list of acquisition times from tile info data

Returns:List of acquisition times in the order returned by WFS service.
Return type:list(datetime.datetime)
get_geometries()[source]

Returns a list of geometries from tile info data

Returns:List of multipolygon geometries in the order returned by WFS service.
Return type:list(shapely.geometry.MultiPolygon)
get_tiles()[source]

Returns list of tiles with tile name, date and AWS index

Returns:List of tiles in form of (tile_name, date, aws_index)
Return type:list((str, str, int))