Skip to content

[rasterio] Accept WarpedVRT and __geo_interface__ geometries#16092

Open
thomas-maschler wants to merge 2 commits into
python:mainfrom
thomas-maschler:rasterio/widen-dataset-and-geometry-types
Open

[rasterio] Accept WarpedVRT and __geo_interface__ geometries#16092
thomas-maschler wants to merge 2 commits into
python:mainfrom
thomas-maschler:rasterio/widen-dataset-and-geometry-types

Conversation

@thomas-maschler

Copy link
Copy Markdown

Widen dataset parameters from the concrete DatasetReader to the shared DatasetReaderBase so any readable dataset (including WarpedVRT) is accepted, matching the runtime duck-typed contract:

  • merge.merge and stack.stack sources
  • features.geometry_window and features.dataset_features
  • mask.mask and mask.raster_geometry_mask
  • sample.sample_gen
  • the AnyDataset alias (now DatasetReaderBase | MemoryFile)

Introduce a shared Geometry alias in _typing (a GeoJSON-like Mapping or any object implementing geo_interface, e.g. shapely geometries) and use it wherever the runtime unwraps geo_interface:

  • features.rasterize, geometry_mask, bounds, is_valid_geom, geometry_window
  • mask.mask and mask.raster_geometry_mask shapes
  • warp.transform_geom and _warp._transform_geom

fixes: torchgeo/torchgeo#3906

Widen dataset parameters from the concrete DatasetReader to the shared
DatasetReaderBase so any readable dataset (including WarpedVRT) is
accepted, matching the runtime duck-typed contract:
- merge.merge and stack.stack sources
- features.geometry_window and features.dataset_features
- mask.mask and mask.raster_geometry_mask
- sample.sample_gen
- the AnyDataset alias (now DatasetReaderBase | MemoryFile)

Introduce a shared Geometry alias in _typing (a GeoJSON-like Mapping or
any object implementing __geo_interface__, e.g. shapely geometries) and
use it wherever the runtime unwraps __geo_interface__:
- features.rasterize, geometry_mask, bounds, is_valid_geom, geometry_window
- mask.mask and mask.raster_geometry_mask shapes
- warp.transform_geom and _warp._transform_geom
@github-actions

This comment has been minimized.

`Geometry` now lives in the blanket-allowlisted `rasterio._typing` module
and is only re-exported from `rasterio.features`, so stubtest no longer
flags `rasterio.features.Geometry` and the allowlist entry was unused.
@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant