satellitetools.common.raster

Functions for raster data handling.

@author: Olli Nevalainen (Finnish Meteorological Institute)

Functions

mask_raster(→ Tuple[numpy.ndarray, dict])

Mask raster data with area of interest geometry.

resample_raster(→ Tuple[numpy.ndarray, dict])

Resample raster data to target ground sample distance.

reproject_data_to_profile(→ numpy.ndarray)

Reproject raster data to target profile.

Module Contents

satellitetools.common.raster.mask_raster(raster: rasterio.io.MemoryFile | os.PathLike, aoi_geometry: shapely.geometry.Polygon | shapely.geometry.MultiPolygon, no_data: float | int) Tuple[numpy.ndarray, dict][source]

Mask raster data with area of interest geometry.

Parameters:

raster: Union[MemoryFile, os.PathLike]

Raster data.

aoi_geometry: Polygon

Area of interest geometry.

no_data: Union[float, int]

No data value.

Returns:

Tuple[np.ndarray, dict]

Tuple of masked data and metadata.

satellitetools.common.raster.resample_raster(raster: rasterio.io.MemoryFile | os.PathLike, target_gsd: float, resampling_method: rasterio.enums.Resampling, target_height: int | None = None, target_width: int | None = None) Tuple[numpy.ndarray, dict][source]

Resample raster data to target ground sample distance.

Parameters:

raster: Union[MemoryFile, os.PathLike]

Raster data.

target_gsd: float

Target ground sample distance.

resampling_method: Resampling

Resampling method.

target_height: Optional[int]

Target height.

target_width: Optional[int]

Target width.

Returns:

Tuple[np.ndarray, dict]

Tuple of resampled data and metadata.

satellitetools.common.raster.reproject_data_to_profile(src_data: numpy.ndarray, src_profile: dict, target_profile: dict, resampling: rasterio.enums.Resampling) numpy.ndarray[source]

Reproject raster data to target profile.

Parameters:

src_data: np.ndarray

Source data.

src_profile: dict

Source profile.

target_profile: dict

Target profile.

resampling: Resampling

Resampling method.

Returns:

np.ndarray

Reprojected data.