sentinelhub.geo_utils
Module for manipulation of geographical information
- sentinelhub.geo_utils.bbox_to_dimensions(bbox, resolution)[source]
Calculates width and height in pixels for a given bbox of a given pixel resolution (in meters). The result is rounded to the nearest integers.
- Parameters:
bbox (BBox) – bounding box
resolution (float | tuple[float, float]) – Resolution of desired image in meters. It can be a single number or a tuple of two numbers - resolution in horizontal and resolution in vertical direction.
- Returns:
width and height in pixels for given bounding box and pixel resolution
- Return type:
tuple[int, int]
- sentinelhub.geo_utils.bbox_to_resolution(bbox, width, height, meters=True)[source]
Calculates pixel resolution for a given bbox of a given width and height. By default, it returns result in meters.
- Parameters:
bbox (BBox) – bounding box
width (int) – width of bounding box in pixels
height (int) – height of bounding box in pixels
meters (bool) – If True result will be given in meters, otherwise it will be given in units of current CRS
- Returns:
resolution east-west at north and south, and resolution north-south for given CRS
- Raises:
ValueError if CRS is not supported
- Return type:
tuple[float, float]
- sentinelhub.geo_utils.get_image_dimension(bbox, width=None, height=None)[source]
Given bounding box and one of the parameters width or height it will return the other parameter that will best fit the bounding box dimensions
- Parameters:
bbox (BBox) – bounding box
width (int | None) – image width or None if height is unknown
height (int | None) – image height or None if height is unknown
- Returns:
width or height rounded to integer
- Return type:
int
- sentinelhub.geo_utils.get_utm_bbox(img_bbox, transform)[source]
Get UTM coordinates given a bounding box in pixels and a transform
- Parameters:
img_bbox (Sequence[float]) – boundaries of bounding box in pixels as [row1, col1, row2, col2]
transform (Sequence[float]) – georeferencing transform of the image, e.g. (x_upper_left, res_x, 0, y_upper_left, 0, -res_y)
- Returns:
UTM coordinates as [east1, north1, east2, north2]
- Return type:
list[float]
- sentinelhub.geo_utils.wgs84_to_utm(lng, lat, utm_crs=None)[source]
Convert WGS84 coordinates to UTM. If UTM CRS is not set it will be calculated automatically.
- Parameters:
lng (float) – longitude in WGS84 system
lat (float) – latitude in WGS84 system
utm_crs (CRS | None) – UTM coordinate reference system enum constants
- Returns:
east, north coordinates in UTM system
- Return type:
tuple[float, float]
- sentinelhub.geo_utils.to_wgs84(east, north, crs)[source]
Convert any CRS with (east, north) coordinates to WGS84
- Parameters:
east (float) – east coordinate
north (float) – north coordinate
crs (CRS) – CRS enum constants
- Returns:
latitude and longitude coordinates in WGS84 system
- Return type:
tuple[float, float]
- sentinelhub.geo_utils.utm_to_pixel(east, north, transform, truncate=True)[source]
Convert a UTM coordinate to image coordinate given a transform
- Parameters:
east (float) – east coordinate of point
north (float) – north coordinate of point
transform (Sequence[float]) – georeferencing transform of the image, e.g. (x_upper_left, res_x, 0, y_upper_left, 0, -res_y)
truncate (bool) – Truncate pixel coordinates. Default is True
- Returns:
row and column pixel image coordinates
- Return type:
tuple[float, float] | tuple[int, int]
- sentinelhub.geo_utils.pixel_to_utm(row, column, transform)[source]
Convert pixel coordinate to UTM coordinate given a transform
- Parameters:
row (float) – row pixel coordinate
column (float) – column pixel coordinate
transform (Sequence[float]) – georeferencing transform of the image, e.g. (x_upper_left, res_x, 0, y_upper_left, 0, -res_y)
- Returns:
east, north UTM coordinates
- Return type:
tuple[float, float]
- sentinelhub.geo_utils.wgs84_to_pixel(lng, lat, transform, utm_epsg=None, truncate=True)[source]
Convert WGS84 coordinates to pixel image coordinates given transform and UTM CRS. If no CRS is given it will be calculated it automatically.
- Parameters:
lng (float) – longitude of point
lat (float) – latitude of point
transform (Sequence[float]) – georeferencing transform of the image, e.g. (x_upper_left, res_x, 0, y_upper_left, 0, -res_y)
utm_epsg (CRS | None) – UTM coordinate reference system enum constants
truncate (bool) – Truncate pixel coordinates. Default is True
- Returns:
row and column pixel image coordinates
- Return type:
tuple[float, float] | tuple[int, int]
- sentinelhub.geo_utils.get_utm_crs(lng, lat, source_crs=CRS.WGS84)[source]
Get CRS for UTM zone in which (lat, lng) is contained.