[rasterio] Accept WarpedVRT and __geo_interface__ geometries#16092
Open
thomas-maschler wants to merge 2 commits into
Open
[rasterio] Accept WarpedVRT and __geo_interface__ geometries#16092thomas-maschler wants to merge 2 commits into
thomas-maschler wants to merge 2 commits into
Conversation
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
This comment has been minimized.
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.
Contributor
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
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:
fixes: torchgeo/torchgeo#3906