How to use the sentinelhub.CRS.POP_WEB 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_opensearch.py View on Github external
def test_get_area_dates(self):
        bbox = BBox([1059111.463919402, 4732980.791418114, 1061557.4488245277, 4735426.776323237], crs=CRS.POP_WEB)
        dates = get_area_dates(bbox, ('2016-01-23', '2016-11-24'), maxcc=0.7)
        self.assertTrue(isinstance(dates, list), msg="Expected a list, got {}".format(type(dates)))
        self.assertEqual(len(dates), 22, "Expected a list of length 22, got length {}".format(len(dates)))
github sentinel-hub / sentinelhub-py / tests / test_geometry.py View on Github external
def test_bbox_eq(self):
        bbox1 = BBox([46.07, 13.23, 46.24, 13.57], CRS.WGS84)
        bbox2 = BBox(((46.24, 13.57), (46.07, 13.23)), 4326)
        bbox3 = BBox([46.07, 13.23, 46.24, 13.57], CRS.POP_WEB)
        bbox4 = BBox([46.07, 13.23, 46.24, 13.58], CRS.WGS84)
        self.assertEqual(bbox1, bbox2, "Bounding boxes {} and {} should be the same".format(repr(bbox1), repr(bbox2)))
        self.assertNotEqual(bbox1, bbox3, "Bounding boxes {} and {} should not be the same".format(repr(bbox1),
                                                                                                   repr(bbox3)))
        self.assertNotEqual(bbox1, bbox4, "Bounding boxes {} and {} should not be the same".format(repr(bbox1),
                                                                                                   repr(bbox4)))
github sentinel-hub / sentinelhub-py / tests / test_ogc.py View on Github external
def setUpClass(cls):
        super().setUpClass()

        wgs84_bbox = BBox(bbox=(-5.23, 48.0, -5.03, 48.17), crs=CRS.WGS84)
        wgs84_bbox_2 = BBox(bbox=(21.3, 64.0, 22.0, 64.5), crs=CRS.WGS84)
        wgs84_bbox_3 = BBox(bbox=(-72.0, -70.4, -71.8, -70.2), crs=CRS.WGS84)
        wgs84_bbox_4 = BBox(bbox=(-72.0, -66.4, -71.8, -66.2), crs=CRS.WGS84)
        pop_web_bbox = BBox(bbox=(1292344.0, 5195920.0, 1310615.0, 5214191.0), crs=CRS.POP_WEB)
        geometry_wkt_pop_web = 'POLYGON((1292344.0 5205055.5, 1301479.5 5195920.0, 1310615.0 5205055.5, ' \
                               '1301479.5 5214191.0, 1292344.0 5205055.5))'
        geometry_wkt_wgs84 = 'POLYGON((-5.13 48, -5.23 48.09, -5.13 48.17, -5.03 48.08, -5.13 48))'
        img_width = 100
        img_height = 100
        resx = '53m'
        resy = '78m'
        expected_date = datetime.datetime.strptime('2017-10-07T11:20:58', '%Y-%m-%dT%H:%M:%S')

        cls.test_cases = [
            cls.OgcTestCase('generalWmsTest',
                            OgcRequest(data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF_d32f, bbox=wgs84_bbox,
                                       layer='BANDS-S2-L1C', maxcc=0.5, size_x=img_width, size_y=img_height,
                                       time=(datetime.date(year=2017, month=1, day=5),
                                             datetime.date(year=2017, month=12, day=16)),
                                       service_type=ServiceType.WMS, time_difference=datetime.timedelta(days=10)),
github sentinel-hub / sentinelhub-py / tests / test_geopedia.py View on Github external
def setUpClass(cls):
        super().setUpClass()

        bbox = BBox(bbox=[(13520759, 437326), (13522689, 438602)], crs=CRS.POP_WEB)
        cls.image_field_name = 'Masks'

        cls.gpd_request = GeopediaImageRequest(layer=1749, bbox=bbox, image_field_name=cls.image_field_name,
                                               image_format=MimeType.PNG, data_folder=cls.OUTPUT_FOLDER)
        cls.image_list = cls.gpd_request.get_data(save_data=True)
github sentinel-hub / eo-learn / visualization / eolearn / visualization / eopatch_visualization.py View on Github external
def plot_raster(self, feature_type, feature_name):
        """ Makes visualization for raster data (except for FeatureType.DATA)

        :param feature_type: type of eopatch feature
        :type feature_type: FeatureType
        :param feature_name: name of eopatch feature
        :type feature_name: str
        :return: visualization
        :rtype: holoviews/geoviews/bokeh
        """
        crs = self.eopatch.bbox.crs
        crs = CRS.POP_WEB if crs is CRS.WGS84 else crs
        data_da = array_to_dataframe(self.eopatch, (feature_type, feature_name), crs=crs)
        data_min = data_da.values.min()
        data_max = data_da.values.max()
        data_levels = len(np.unique(data_da))
        data_levels = 11 if data_levels > 11 else data_levels
        data_da = data_da.where(data_da > 0).fillna(-1)
        vis = data_da.hvplot(x='x', y='y',
                             crs=ccrs.epsg(int(crs.value))).opts(clim=(data_min, data_max),
                                                                 clipping_colors={'min': 'transparent'},
                                                                 color_levels=data_levels)
        return vis
github sentinel-hub / eo-learn / io / eolearn / io / geopedia.py View on Github external
def _reproject(self, eopatch, src_raster):
        """
        Reprojects the raster data from Geopedia's CRS (POP_WEB) to EOPatch's CRS.
        """
        height, width = src_raster.shape

        dst_raster = np.ones((height, width), dtype=self.raster_dtype)

        src_bbox = transform_bbox(eopatch.bbox, CRS.POP_WEB)
        src_transform = rasterio.transform.from_bounds(*src_bbox, width=width, height=height)

        dst_bbox = eopatch.bbox
        dst_transform = rasterio.transform.from_bounds(*dst_bbox, width=width, height=height)

        rasterio.warp.reproject(src_raster, dst_raster,
                                src_transform=src_transform, src_crs={'init': CRS.ogc_string(CRS.POP_WEB)},
                                src_nodata=0,
                                dst_transform=dst_transform, dst_crs={'init': CRS.ogc_string(eopatch.bbox.crs)},
                                dst_nodata=self.no_data_val)

        return dst_raster
github sentinel-hub / eo-learn / io / eolearn / io / geopedia.py View on Github external
def _get_wms_request(self, bbox, size_x, size_y):
        """
        Returns WMS request.
        """
        bbox_3857 = transform_bbox(bbox, CRS.POP_WEB)

        return GeopediaWmsRequest(layer=self.layer,
                                  theme=self.theme,
                                  bbox=bbox_3857,
                                  width=size_x,
                                  height=size_y,
                                  image_format=self.image_format,
                                  custom_url_params={CustomUrlParam.TRANSPARENT: True})
github sentinel-hub / eo-learn / visualization / eolearn / visualization / eopatch_visualization.py View on Github external
def plot_data(self, feature_name):
        """ Plots the FeatureType.DATA of eopatch.

        :param feature_name: name of the eopatch feature
        :type feature_name: str
        :return: visualization
        :rtype: holoview/geoviews/bokeh
        """
        crs = self.eopatch.bbox.crs
        crs = CRS.POP_WEB if crs is CRS.WGS84 else crs
        data_da = array_to_dataframe(self.eopatch, (FeatureType.DATA, feature_name), crs=crs)
        if self.mask:
            data_da = self.mask_data(data_da)
        timestamps = self.eopatch.timestamp
        crs = self.eopatch.bbox.crs
        if not self.rgb:
            return data_da.hvplot(x='x', y='y', crs=ccrs.epsg(int(crs.value)))
        data_rgb = self.eopatch_da_to_rgb(data_da, feature_name, crs)
        rgb_dict = {timestamp_: self.plot_rgb_one(data_rgb, timestamp_) for timestamp_ in timestamps}

        return hv.HoloMap(rgb_dict, kdims=['time'])