PatchGeoref#
- class rapidtools.data_sources.orthomosaic_reader.PatchGeoref(transform: Affine, crs: CRS, width: int, height: int)[source]#
Bases:
objectNative georeferencing of an image patch read from a raster.
A patch’s WGS84 bounding box is only an envelope: for a projected or rotated raster the patch edges are not lines of constant latitude and longitude, so mapping pixels through that envelope stretches and skews the result. This record keeps the exact pixel-to-CRS affine transform of the window that was read so masks drawn on the patch can be vectorized in the raster’s own grid and then reprojected.
- Variables:
Example
>>> from rasterio.crs import CRS >>> from rasterio.transform import Affine >>> georef = PatchGeoref(Affine(0.5, 0, 500000, 0, -0.5, 4100000), ... CRS.from_epsg(32611), 100, 100) >>> georef.transform_for(50, 50).a 1.0 >>> PatchGeoref.from_dict(georef.to_dict()) == georef True
Methods
Rebuild the record from
to_dict()output.Return a JSON-friendly representation (see
from_dict()).Return the affine transform for a resampled copy of the patch.
- transform_for(width: int, height: int) Affine[source]#
Return the affine transform for a resampled copy of the patch.
- Parameters:
width – Width in pixels of the array being georeferenced.
height – Height in pixels of the array being georeferenced.
- Returns:
Affine –
transformrescaled so the array still covers the same ground footprint.