Rasterio compatibility#
cugeo-raster uses familiar Rasterio conventions for opening datasets, selecting bands and windows, describing grids and writing files. An existing Rasterio workflow can reuse those concepts, but changing its imports does not establish that its inputs, operations and output behavior are supported.
Rasterio shapes the ordinary Python API. GDAL defines reference pixel values, georeferencing, metadata, nodata and errors. cugeo-raster implements its own native execution paths; neither Rasterio nor GDAL is a runtime fallback.
Output allocation selects memory and execution#
Rasterio’s ordinary reads return NumPy arrays. With a CUDA-enabled build, an
allocating cugeo-raster file read returns CuPy on the current CUDA device and
stream. With a host-only build, an ordinary read with no out, context,
stream or device codec requested returns a NumPy array. Supplying a NumPy
out selects a supported host TIFF read; supplying a compatible CUDA array
selects a supported GPU read.
Caller-owned output keeps its object identity, shape and strides. CHW axes do not imply planar storage: strides can describe interleaved or padded memory. The decoder may need intermediate buffers to produce the requested output. The memory-layout explanation describes that distinction.
Changing the reader does not move downstream NumPy calculations to the GPU. The application chooses device operations and any transfers between NumPy, CuPy, PyTorch or another array library. The PyTorch how-to shows a read into a tensor the application allocated.
Validity and resampling need explicit choices#
Rasterio supports NumPy masked arrays
as well as separate valid-data masks.
cugeo-raster keeps pixels and masks separate: masked=True and MaskedArray
output are unsupported. read_masks() returns per-band validity;
dataset_mask() combines validity according to its dataset rules. Zero mask
values mean invalid and nonzero values mean valid. This is the opposite
polarity to a NumPy masked array’s mask, where true means invalid.
See Rasterio’s mask explanation
and the cugeo-raster validity tutorial.
out_shape requests a different sampling grid. cugeo-raster implements
nearest and bilinear sampling within each route’s limits. Matching a Rasterio
resampling enum does not establish identical read-filter behavior: fractional,
clipped, boundless and reduced-resolution reads have specific sampling rules
and documented differences. The
sampling reference
defines these cases. Resizing also requires an adjusted affine transform,
as shown in Read and resize a raster window.
GPU completion follows the selected stream#
A host read completes before returning. An ordinary GPU read orders its output
before subsequent work on the selected CUDA stream; returning an array does
not necessarily mean the CPU has observed completion. A consumer on another
stream needs an explicit dependency. Omitting stream selects CuPy’s current
stream, which can differ from another framework’s current stream.
The application retains borrowed contexts, streams and allocations through their required lifetimes. Streams and receipts explains completion and how to inspect transfers, temporary storage and waits.
Supported scope is narrower than GDAL’s#
Support depends on file format, compression, dtype, band count, layout and requested host or device output. A supported TIFF container does not establish that a particular GPU codec can decode its pixels. Python extras provide dependencies; optional native features must also be enabled in the library. The capability matrix owns the supported profiles and qualification boundaries.
Writers accept supported profile fields and creation keywords, including an explicit grid and band meaning. A copied Rasterio profile can contain options the selected cugeo-raster writer cannot represent. Derived data also needs its own dtype, nodata and band metadata; source scale and offset may not apply. The writer reference defines creation options, window mutations, mask persistence and publication behavior.
Unsupported requests raise explicit errors. Applications can retain another reader or writer for the remaining stages, with any handoff and transfer performed by application code. Comparing pixels, validity, grid metadata and band meaning establishes whether replacing a stage preserves the workflow’s results. End-to-end measurements, including transfers and writing, establish whether the replacement improves its performance.