eodal.utils.geometry module

Vector geometry operations.

Copyright (C) 2022/2023 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.geometry.adopt_vector_features_to_mask(band_df: DataFrame, vector_features: GeoDataFrame | GeoSeries | Path) tuple[GeoDataFrame, tuple[int, int], int | float][source]

Adopt the vector features used for clipping and/or masking data to the spatial resolution of the band with the coarsest spatial resolution. This is necessary to avoid artifacts (namely different spatial extents) in the data caused by the spatial subsetting with different pixel sizes.

Parameters:
  • band_df – DataFrame containing the band metadata.

  • vector_features – vector features to be used for masking.

Returns:

Updated vector features, shape of the resulting mask and spatial resolution of the band with the coarsest spatial resolution.

eodal.utils.geometry.box_from_transform(transform: list[float] | tuple, shape: list[int] | tuple[int, int]) Polygon[source]

Get a shapely box geometry from a transform vector and raster shape.

..versionadd:: 0.3.0

Parameters:
  • transform – affine-like transform parameters.

  • shape – raster shape (nrows, ncols).

Returns:

resulting geometry as shapely.geometry.box object.

eodal.utils.geometry.box_to_geojson(gdf: GeoDataFrame | Polygon) str[source]

Casts the bounding box of a GeoDataFrame to GeoJson

Parameters:

gdf – Non-empty GeoDataFrame or shapely rectangular Polygon in geographic coordinates

Returns:

total_bounds of gpd in GeoJson notation

eodal.utils.geometry.prepare_gdf(metadata_list: list[dict]) GeoDataFrame[source]

Convert list of metadata dictionaries to a GeoDataFrame.

..versionadd:: 0.3.0

Parameters:

metadata_list – list of metadata entries as dictionaries.

Returns:

resulting GeoDataFrame sorted by sensing time.