sentinelhub.constants

Module defining constants and enumerate types used in the package

class sentinelhub.constants.ServiceUrl[source]

Bases: object

Most commonly used Sentinel Hub service URLs

MAIN = 'https://services.sentinel-hub.com'
USWEST = 'https://services-uswest2.sentinel-hub.com'
CREODIAS = 'https://creodias.sentinel-hub.com'
MUNDI = 'https://shservices.mundiwebservices.com'
CODE_DE = 'https://code-de.sentinel-hub.com'
class sentinelhub.constants.ServiceType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

Enum constant class for type of service

Supported types are WMS, WCS, WFS, AWS, IMAGE

WMS = 'wms'
WCS = 'wcs'
WFS = 'wfs'
AWS = 'aws'
IMAGE = 'image'
FIS = 'fis'
PROCESSING_API = 'processing'
class sentinelhub.constants.ResamplingType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

Enum constant class for type of resampling.

NEAREST = 'NEAREST'
BILINEAR = 'BILINEAR'
BICUBIC = 'BICUBIC'
class sentinelhub.constants.MosaickingOrder(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

Enum constant class for type of mosaicking order.

MOST_RECENT = 'mostRecent'
LEAST_RECENT = 'leastRecent'
LEAST_CC = 'leastCC'
class sentinelhub.constants.CRSMeta(cls, bases, classdict)[source]

Bases: EnumType

Metaclass used for building CRS Enum class

This is executed at the beginning of runtime when CRS class is created

class sentinelhub.constants.CRS(crs_value, *args, **kwargs)[source]

Bases: Enum

Coordinate Reference System enumerate class

Available CRS constants are WGS84, POP_WEB (i.e. Popular Web Mercator) and constants in form UTM_<zone><direction>, where zone is an integer from [1, 60] and direction is either N or S (i.e. northern or southern hemisphere)

WGS84 = '4326'
POP_WEB = '3857'
classmethod has_value(value)[source]

Tests whether CRS contains a constant defined with string value.

Parameters:

value (str) – The string representation of the enum constant.

Returns:

True if there exists a constant with string value value, False otherwise

Return type:

bool

property epsg: int

EPSG code property

Returns:

EPSG code of given CRS

ogc_string()[source]

Returns a string of the form authority:id representing the CRS.

Parameters:

self – An enum constant representing a coordinate reference system.

Returns:

A string representation of the CRS.

Return type:

str

property opengis_string: str

Returns a URL to OGC webpage where the CRS is defined

Returns:

A URL with CRS definition

is_utm()[source]

Checks if crs is one of the 64 possible UTM coordinate reference systems.

Parameters:

self – An enum constant representing a coordinate reference system.

Returns:

True if crs is UTM and False otherwise

Return type:

bool

projection()[source]

Returns a projection in form of pyproj class.

For better time performance this method will cache 128 most recent results. Cache can be released with CRS.projection.cache_clear().

Returns:

pyproj projection class

Return type:

Proj

pyproj_crs()[source]

Returns a pyproj CRS class.

For better time performance this method will cache 128 most recent results. Cache can be released with CRS.pyproj_crs.cache_clear().

Returns:

pyproj CRS class

Return type:

CRS

get_transform_function(other, always_xy=True)[source]

Returns a function for transforming geometrical objects from one CRS to another. The function will support transformations between any objects that pyproj supports.

For better time performance this method will cache results. Cache can be released with CRS.get_transform_function.cache_clear().

Parameters:
  • self – Initial CRS

  • other (CRS) – Target CRS

  • always_xy (bool) – Parameter that is passed to pyproj.Transformer object and defines axis order for transformation. The default value True is in most cases the correct one.

Returns:

A projection function obtained from pyproj package

Return type:

Callable[[…], tuple]

static get_utm_from_wgs84(lng, lat)[source]

Convert from WGS84 to UTM coordinate system

Parameters:
  • lng (float) – Longitude

  • lat (float) – Latitude

Returns:

UTM coordinates

Return type:

CRS

UTM_1N = '32601'
UTM_2N = '32602'
UTM_3N = '32603'
UTM_4N = '32604'
UTM_5N = '32605'
UTM_6N = '32606'
UTM_7N = '32607'
UTM_8N = '32608'
UTM_9N = '32609'
UTM_10N = '32610'
UTM_11N = '32611'
UTM_12N = '32612'
UTM_13N = '32613'
UTM_14N = '32614'
UTM_15N = '32615'
UTM_16N = '32616'
UTM_17N = '32617'
UTM_18N = '32618'
UTM_19N = '32619'
UTM_20N = '32620'
UTM_21N = '32621'
UTM_22N = '32622'
UTM_23N = '32623'
UTM_24N = '32624'
UTM_25N = '32625'
UTM_26N = '32626'
UTM_27N = '32627'
UTM_28N = '32628'
UTM_29N = '32629'
UTM_30N = '32630'
UTM_31N = '32631'
UTM_32N = '32632'
UTM_33N = '32633'
UTM_34N = '32634'
UTM_35N = '32635'
UTM_36N = '32636'
UTM_37N = '32637'
UTM_38N = '32638'
UTM_39N = '32639'
UTM_40N = '32640'
UTM_41N = '32641'
UTM_42N = '32642'
UTM_43N = '32643'
UTM_44N = '32644'
UTM_45N = '32645'
UTM_46N = '32646'
UTM_47N = '32647'
UTM_48N = '32648'
UTM_49N = '32649'
UTM_50N = '32650'
UTM_51N = '32651'
UTM_52N = '32652'
UTM_53N = '32653'
UTM_54N = '32654'
UTM_55N = '32655'
UTM_56N = '32656'
UTM_57N = '32657'
UTM_58N = '32658'
UTM_59N = '32659'
UTM_60N = '32660'
UTM_1S = '32701'
UTM_2S = '32702'
UTM_3S = '32703'
UTM_4S = '32704'
UTM_5S = '32705'
UTM_6S = '32706'
UTM_7S = '32707'
UTM_8S = '32708'
UTM_9S = '32709'
UTM_10S = '32710'
UTM_11S = '32711'
UTM_12S = '32712'
UTM_13S = '32713'
UTM_14S = '32714'
UTM_15S = '32715'
UTM_16S = '32716'
UTM_17S = '32717'
UTM_18S = '32718'
UTM_19S = '32719'
UTM_20S = '32720'
UTM_21S = '32721'
UTM_22S = '32722'
UTM_23S = '32723'
UTM_24S = '32724'
UTM_25S = '32725'
UTM_26S = '32726'
UTM_27S = '32727'
UTM_28S = '32728'
UTM_29S = '32729'
UTM_30S = '32730'
UTM_31S = '32731'
UTM_32S = '32732'
UTM_33S = '32733'
UTM_34S = '32734'
UTM_35S = '32735'
UTM_36S = '32736'
UTM_37S = '32737'
UTM_38S = '32738'
UTM_39S = '32739'
UTM_40S = '32740'
UTM_41S = '32741'
UTM_42S = '32742'
UTM_43S = '32743'
UTM_44S = '32744'
UTM_45S = '32745'
UTM_46S = '32746'
UTM_47S = '32747'
UTM_48S = '32748'
UTM_49S = '32749'
UTM_50S = '32750'
UTM_51S = '32751'
UTM_52S = '32752'
UTM_53S = '32753'
UTM_54S = '32754'
UTM_55S = '32755'
UTM_56S = '32756'
UTM_57S = '32757'
UTM_58S = '32758'
UTM_59S = '32759'
UTM_60S = '32760'
class sentinelhub.constants.MimeType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

Enum class to represent supported file formats

Supported file formats are TIFF 8-bit, TIFF 16-bit, TIFF 32-bit float, PNG, JPEG, JPEG2000, JSON, CSV, ZIP, HDF5, XML, GML, RAW

TIFF = 'tiff'
PNG = 'png'
JPG = 'jpg'
JP2 = 'jp2'
JSON = 'json'
CSV = 'csv'
ZIP = 'zip'
HDF = 'hdf'
XML = 'xml'
GML = 'gml'
TXT = 'txt'
TAR = 'tar'
RAW = 'raw'
SAFE = 'safe'
PICKLE = 'pkl'
NPY = 'npy'
GPKG = 'gpkg'
GEOJSON = 'geojson'
GZIP = 'gz'
property extension: str

Returns file extension of the MimeType object

Returns:

A file extension string

static from_string(mime_type_str)[source]

Parses mime type from a file extension string

Parameters:

mime_type_str (str) – A file extension string

Returns:

A mime type enum

Return type:

MimeType

is_image_format()[source]

Checks whether file format is an image format

Example: MimeType.PNG.is_image_format() or MimeType.is_image_format(MimeType.PNG)

Parameters:

self – File format

Returns:

True if file is in image format, False otherwise

Return type:

bool

is_api_format()[source]

Checks if mime type is supported by Sentinel Hub API

Returns:

True if API supports this format and False otherwise

Return type:

bool

classmethod has_value(value)[source]

Tests whether MimeType contains a constant defined with string value

Parameters:

value (str) – The string representation of the enum constant

Returns:

True if there exists a constant with string value value, False otherwise

Return type:

bool

get_string()[source]

Get file format as string

Returns:

String describing the file format

Return type:

str

matches_extension(path)[source]

Checks if mime type enum is used as the last file extension in given file path.

Parameters:

path (str) – Path that might have an extension at the end.

Returns:

A boolean value indicating if the file path ends with the expected extension.

Return type:

bool

get_expected_max_value()[source]

Returns max value of image MimeType format and raises an error if it is not an image format

Returns:

A maximum value of specified image format

Raises:

ValueError

Return type:

float | int

class sentinelhub.constants.RequestType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

Enum constant class for GET/POST request type.

GET = 'GET'
POST = 'POST'
DELETE = 'DELETE'
PUT = 'PUT'
PATCH = 'PATCH'
class sentinelhub.constants.SHConstants[source]

Bases: object

Common constants used in various requests.

LATEST = 'latest'
HEADERS: ClassVar[dict[str, str]] = {'User-Agent': 'sentinelhub-py/v3.10.1'}