How to use the sentinelhub.constants.CRS function in sentinelhub

To help you get started, we’ve selected a few sentinelhub examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sentinel-hub / sentinelhub-py / sentinelhub / geometry.py View on Github external
def transform(self, crs):
        """ Transforms Geometry from current CRS to target CRS

        :param crs: target CRS
        :type crs: constants.CRS
        :return: Geometry in target CRS
        :rtype: Geometry
        """
        new_crs = CRS(crs)

        geometry = self.geometry
        if new_crs is not self.crs:
            transform_function = self.crs.get_transform_function(new_crs)
            geometry = shapely.ops.transform(transform_function, geometry)

        return Geometry(geometry, crs=new_crs)
github sentinel-hub / sentinelhub-py / sentinelhub / geo_utils.py View on Github external
def to_utm_bbox(bbox):
    """ Transform bbox into UTM CRS

    :param bbox: bounding box
    :type bbox: geometry.BBox
    :return: bounding box in UTM CRS
    :rtype: geometry.BBox
    """
    if CRS.is_utm(bbox.crs):
        return bbox
    lng, lat = bbox.middle
    utm_crs = get_utm_crs(lng, lat, source_crs=bbox.crs)
    return bbox.transform(utm_crs)
github sentinel-hub / sentinelhub-py / sentinelhub / constants.py View on Github external
def ogc_string(self):
        """ Returns a string of the form authority:id representing the CRS.

        :param self: An enum constant representing a coordinate reference system.
        :type self: CRS
        :return: A string representation of the CRS.
        :rtype: str
        """
        return 'EPSG:{}'.format(CRS(self).value)
github sentinel-hub / sentinelhub-py / sentinelhub / geometry.py View on Github external
def __init__(self, crs):
        """
        :param crs: Coordinate reference system of the geometry
        :type crs: constants.CRS
        """
        self._crs = CRS(crs)
github sentinel-hub / sentinelhub-py / sentinelhub / constants.py View on Github external
def get_utm_from_wgs84(lng, lat):
        """ Convert from WGS84 to UTM coordinate system

        :param lng: Longitude
        :type lng: float
        :param lat: Latitude
        :type lat: float
        :return: UTM coordinates
        :rtype: tuple
        """
        _, _, zone, _ = utm.from_latlon(lat, lng)
        direction = 'N' if lat >= 0 else 'S'
        return CRS['UTM_{}{}'.format(str(zone), direction)]
github sentinel-hub / sentinelhub-py / sentinelhub / geopedia.py View on Github external
:param gpd_session: Optional parameter for specifying a custom Geopedia session, which can also contain login
            credentials. This can be used for accessing private Geopedia layers. By default it is set to `None` and a
            basic Geopedia session without credentials will be created.
        :type gpd_session: GeopediaSession or None
        :param base_url: Base url of Geopedia REST services. If `None`, the url specified in the configuration
            file is taken.
        :type base_url: str or None
        """
        super().__init__(**kwargs)

        self.layer = self._parse_layer(layer)

        self.query = {}
        if bbox is not None:
            if bbox.crs is not CRS.POP_WEB:
                bbox = bbox.transform(CRS.POP_WEB)

            self.query[self.FILTER_EXPRESSION] = 'bbox({},"EPSG:3857")'.format(bbox)
        if query_filter is not None:
            if self.FILTER_EXPRESSION in self.query:
                self.query[self.FILTER_EXPRESSION] = '{} && ({})'.format(self.query[self.FILTER_EXPRESSION],
                                                                         query_filter)
            else:
                self.query[self.FILTER_EXPRESSION] = query_filter

        self.gpd_session = gpd_session if gpd_session else GeopediaSession(is_global=True)
        self.features = []
        self.layer_size = None
        self.index = 0

        self.next_page_url = '{}data/v2/search/tables/{}/features'.format(self.base_url, self.layer)
github sentinel-hub / sentinelhub-py / sentinelhub / data_request.py View on Github external
def __init__(self, layer, service_type, *, bbox=None, theme=None, image_format=MimeType.PNG, **kwargs):
        self.layer = layer
        self.service_type = service_type

        self.bbox = bbox
        if bbox.crs is not CRS.POP_WEB:
            raise ValueError('Geopedia Request at the moment supports only bounding boxes with coordinates in '
                             '{}'.format(CRS.POP_WEB))

        self.theme = theme
        self.image_format = MimeType(image_format)

        super().__init__(**kwargs)
github sentinel-hub / sentinelhub-py / sentinelhub / geo_utils.py View on Github external
def get_utm_crs(lng, lat, source_crs=CRS.WGS84):
    """ Get CRS for UTM zone in which (lat, lng) is contained.

    :param lng: longitude
    :type lng: float
    :param lat: latitude
    :type lat: float
    :param source_crs: source CRS
    :type source_crs: constants.CRS
    :return: CRS of the zone containing the lat,lon point
    :rtype: constants.CRS
    """
    if source_crs is not CRS.WGS84:
        lng, lat = transform_point((lng, lat), source_crs, CRS.WGS84)
    return CRS.get_utm_from_wgs84(lng, lat)