How to use the sentinelhub.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 / tests / test_geo_utils.py View on Github external
def test_utm33N_wgs84(self):
        lng, lat = geo_utils.to_wgs84(541995.694062, 4888006.132887, CRS.UTM_33N)
        expected_lng = 15.525078
        expected_lat = 44.1440478
        self.assertAlmostEqual(lng, expected_lng, delta=1E-6, msg='Expected {}, got {}'.format(str(expected_lng),
                                                                                               str(lng)))
        self.assertAlmostEqual(lat, expected_lat, delta=1E-6, msg='Expected {}, got {}'.format(str(expected_lat),
                                                                                               str(lat)))
github sentinel-hub / sentinel2-cloud-detector / tests / test_cloud_detector.py View on Github external
def setUpClass(cls):
        super().setUpClass()

        bbox1 = BBox([-90.9216499, 14.4190528, -90.8186531, 14.5520163], crs=CRS.WGS84)  # From examples
        bbox2 = BBox([46.16, -16.15, 46.51, -15.58], crs=CRS.WGS84)  # From sentinelhub-py examples
        cls.custom_url_params = {
            CustomUrlParam.SHOWLOGO: True,
            CustomUrlParam.TRANSPARENT: False,
            CustomUrlParam.EVALSCRIPT: 'return [B01]',
            CustomUrlParam.ATMFILTER: 'DOS1'
        }

        cls.wms_request = WmsRequest(layer='S2-DOS1', bbox=bbox1, time=('2017-12-01', '2017-12-31'), width=60,
                                     height=None, image_format=MimeType.TIFF, custom_url_params=cls.custom_url_params,
                                     instance_id=cls.CONFIG.instance_id)
        cls.wcs_request = WcsRequest(layer='S2-ATMCOR', bbox=bbox2, time='2016-07-18T07:14:04',
                                     resx='100m', resy='100m', image_format=MimeType.PNG, data_folder='.')

        cls.test_cases = [
            TestCaseContainer('WMS', CloudMaskRequest(cls.wms_request, threshold=0.6, average_over=2, dilation_size=5),
github sentinel-hub / sentinelhub-py / tests / test_constants.py View on Github external
def test_utm(self):
        known_values = (
            (13, 46, '32633'),
            (13, 0, '32633'),
            (13, -45, '32733'),
            (13, 0, '32633'),
            (13, -0.0001, '32733'),
            (13, -46, '32733')
        )
        for known_val in known_values:
            lng, lat, epsg = known_val
            with self.subTest(msg=epsg):
                crs = CRS.get_utm_from_wgs84(lng, lat)
                self.assertEqual(epsg, crs.value,
                                 msg="Expected {}, got {} for lng={},lat={}".format(epsg, crs.value, str(lng),
                                                                                    str(lat)))
github sentinel-hub / eo-learn / core / eolearn / core / eodata.py View on Github external
:param is_zipped: `True` if file is zipped and `False` otherwise
        :type is_zipped: bool
        :return: Correctly loaded BBox object
        :rtype: sentinelhub.BBox
        """
        warnings.warn("Bounding box of your EOPatch is saved in old format which in the future won't be supported "
                      "anymore. Please save bounding box again, you can overwrite the existing one", DeprecationWarning,
                      stacklevel=4)

        with gzip.open(path) if is_zipped else open(path, 'rb') as pickle_file:
            crs_cnt = -1
            for _, arg, _ in pickletools.genops(pickle_file):
                if arg == 'sentinelhub.constants CRS':
                    crs_cnt = 2
                if crs_cnt == 0:
                    return sentinelhub.BBox(tuple(bbox), sentinelhub.CRS(arg))
                crs_cnt -= 1

        raise ValueError('Failed to correctly load BBox object, try downgrading sentinelhub package to <=2.4.7')