[rasterio] Allow WarpedVRT to take DatasetWriter - #16156
[rasterio] Allow WarpedVRT to take DatasetWriter#16156jack-volantautonomy wants to merge 1 commit into
Conversation
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
|
I'm not familiar with Cc @thomas-maschler as original author. |
|
I will have to check if a |
|
@thomas-maschler you okay to take a look into this now? |
|
@jack-volantautonomy, thanks for the reminder. Two things: The signature should use However, class WarpedVRTReaderBase(DatasetReaderBase):
src_dataset: DatasetReaderBase
src_crs: CRS
src_transform: Affine | None
resampling: Resampling
tolerance: float
src_nodata: float | None
dst_nodata: float | None
working_dtype: DTypeLike | None
warp_extras: dict[str, _GDALOption]
@overload
@deprecated(
"Source datasets opened in modes other than 'r' emit a "
"RasterioDeprecationWarning and will be disallowed in a future rasterio "
"release; reopen the dataset read-only before wrapping it."
)
def __init__(
self,
src_dataset: DatasetWriterBase,
src_crs: CRSInput | None = None,
crs: CRSInput | None = None,
resampling: Resampling = ...,
tolerance: float = 0.125,
src_nodata: float | None = ...,
nodata: float | None = ...,
width: int | None = None,
height: int | None = None,
src_transform: Affine | None = None,
transform: Affine | None = None,
init_dest_nodata: bool = True,
src_alpha: int = 0,
dst_alpha: int = 0,
add_alpha: bool = False,
warp_mem_limit: int = 0,
dtype: DTypeLike | None = None,
**warp_extras: _GDALOption,
) -> None: ...
@overload
def __init__(
self,
src_dataset: DatasetReaderBase,
src_crs: CRSInput | None = None,
crs: CRSInput | None = None,
resampling: Resampling = ...,
tolerance: float = 0.125,
src_nodata: float | None = ...,
nodata: float | None = ...,
width: int | None = None,
height: int | None = None,
src_transform: Affine | None = None,
transform: Affine | None = None,
init_dest_nodata: bool = True,
src_alpha: int = 0,
dst_alpha: int = 0,
add_alpha: bool = False,
warp_mem_limit: int = 0,
dtype: DTypeLike | None = None,
**warp_extras: _GDALOption,
) -> None: ...
``` |
The aim of this PR is to change the typing so that the src dataset provided to
WarpedVRTcan take arasterio.io.DatasetWritertoo. This is because a DatasetWriter also has the read methods required on it so is a suitable parameter type.Not sure if this is the most correct fix and if we should make use of protocols instead but should do the job and might just be the fix we need.