eodal.utils.reprojection module¶
Functions for reprojecting vector and raster data from one spatial coordinate reference system into another one.
Copyright (C) 2022 Samuel Wildhaber and Lukas Valentin Graf
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
- eodal.utils.reprojection.UTMZone¶
alias of
Point
- eodal.utils.reprojection.check_aoi_geoms(in_dataset: Path | GeoDataFrame, full_bounding_box_only: bool, fname_raster: Path | None = None, raster_crs: int | CRS | None = None) GeoDataFrame[source]¶
Checks the provided vector file. If necessary it reprojects the vector data in the reference system of the provided raster data. If the full bounding box shall be used (e.g., the hull encompassing all provided vector geometries) it only returns this geometry (of type Polygon).
Note
Does not check for spatial intersects, overlaps, etc.
- Parameters:
in_file_aoi – vector file (e.g., ESRI shapefile or geojson) defining geometry/ies for which to extract raster data.
fname_raster – raster file to which to map the vector features. Can be ignored if a
raster_crsis availablefull_bounding_box_only – if set to False, will only extract the data for those geometry/ies defined in in_file_aoi. If set to False, returns the data for the full extent (hull) of all features (geometries) in in_file_aoi.
raster_crs – spatial reference system of the raster as EPSG code or
CRSobject. Can be ignored iffname_satis available.
- Returns:
GeoDataFrame with one up to many vector geometries
- eodal.utils.reprojection.infer_utm_zone(shape: Polygon | MultiPolygon) int[source]¶
Returns the EPSG code of the UTM zone a geometry with geographic coordinates lies in (i.e., its centroid)
- Parameters:
shape – geometry in geographic coordinates (WGS84) for which to check the corresponding UTM zone
- eodal.utils.reprojection.reproject_raster_dataset(raster: Path | ndarray, **kwargs) Tuple[Path | ndarray, Affine][source]¶
Re-projects a raster dataset into another spatial coordinate reference system by calling
rasterio.warp.reproject.- Parameters:
raster – either a file-path to a raster dataset or a numpy array containing band data to reproject
kwargs – kwargs required by
rasterio.warp.reproject. See rasterio’s docs for more information.
- Returns:
tuple containing the reprojected raster dataset (file-path or array) and the
Affinetransformation parameters of the reprojected dataset