How to use the sentinelhub.CRS.ogc_string 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 / eo-learn / io / eolearn / io / geopedia.py View on Github external
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 _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 / local_io.py View on Github external
if feature_type.is_time_dependent():
            array_sub = self._get_dates_subset(array_sub, eopatch.timestamp)
        else:
            # add temporal dimension
            array_sub = np.expand_dims(array_sub, axis=0)

        if not feature_type.is_spatial():
            # add height and width dimensions
            array_sub = np.expand_dims(np.expand_dims(array_sub, axis=1), axis=1)

        time_dim, height, width, band_dim = array_sub.shape

        index = time_dim * band_dim
        dst_transform = rasterio.transform.from_bounds(*eopatch.bbox, width=width, height=height)
        dst_crs = {'init': CRS.ogc_string(eopatch.bbox.crs)}

        image_dtype = array_sub.dtype if self.image_dtype is None else self.image_dtype
        if image_dtype == np.int64:
            image_dtype = np.int32
            warnings.warn('Data from feature {} cannot be exported to tiff with dtype numpy.int64. Will export as '
                          'numpy.int32 instead'.format((feature_type, feature_name)))

        # Write it out to a file
        with rasterio.open(self._get_file_path(filename, create_dir=True), 'w', driver='GTiff',
                           width=width, height=height,
                           count=index,
                           dtype=image_dtype, nodata=self.no_data_value,
                           transform=dst_transform, crs=dst_crs) as dst:
            output_array = array_sub.astype(image_dtype)
            output_array = np.moveaxis(output_array, -1, 1).reshape(index, height, width)
            dst.write(output_array)