Orthorectification¶
Orthorectification using DEM and camera model input.
- class orthority.ortho.Ortho(src_file, dem_file, camera, crs=None, dem_band=1)¶
Bases:
objectOrthorectifier.
Uses a supplied DEM and camera model to correct a source image for sensor and terrain distortion. The camera model, and a portion of the DEM corresponding to the ortho bounds are stored internally.
- Parameters:
src_file (str | PathLike | OpenFile | rio.DatasetReader) – Source image to be orthorectified. Can be a path or URI string, an
OpenFileobject in binary mode ('rb'), or a dataset reader.dem_file (str | PathLike | OpenFile | rio.DatasetReader) – DEM file covering the source image. Can be a path or URI string, an
OpenFileobject in binary mode ('rb'), or a dataset reader.camera (Camera) – Source image camera model.
crs (str | CRS | None) – CRS of the
cameraworld coordinates, and ortho image, as an EPSG, proj4 or WKT string, orCRSobject. If set toNone(the default), the CRS will be read from the source image if possible. If the source image is not projected in the world / ortho CRS,crsshould be supplied.dem_band (int) – Index of the DEM band to use (1-based).
- property camera: Camera | FrameCamera¶
Source image camera model.
- process(ortho_file, resolution=None, interp=cubic, dem_interp=cubic, per_band=False, write_mask=None, dtype=None, compress=None, build_ovw=True, creation_options=None, driver=gtiff, overwrite=False, progress=False)¶
Orthorectify the source image.
The source image is read and processed band-by-band, or all bands at once, depending on the value of
per_band. If necessary, the portion of the DEM stored internally is reprojected to the world / ortho CRS and ortho resolution. Using the camera model and DEM, the ortho image is remapped from the source image tile-by-tile. Up to N ortho tiles are processed concurrently, where N is the number of CPUs.Note
An occlusion masking option will be added in a future release.
- Parameters:
ortho_file (str | PathLike | OpenFile) – Ortho image file to create. Can be a path or URI string, or an
OpenFileobject in binary mode ('wb').resolution (tuple[float, float]) – Ortho image pixel (x, y) size in units of the world / ortho CRS. If set to
None(the default), an approximate ground sampling distance is used as the resolution.interp (str | Interp) – Interpolation method for remapping the source to ortho image.
dem_interp (str | Interp) – Interpolation method for reprojecting the DEM.
per_band (bool) – Remap the source to ortho image all bands at once (
False), or band-by-band (True).Falseis faster but requires more memory.write_mask (bool | None) – Mask valid ortho pixels with an internal mask (
True), or with a nodata value based ondtype(False). An internal mask helps remove nodata noise caused by lossy compression. If set toNone(the default), the mask will be written when JPEG compression is used.dtype (str) – Ortho image data type (
uint8,uint16,int16,float32orfloat64). If set toNone(the default), the source image data type is used.compress (str | Compress | None) – Ortho image compression type (
jpeg,deflateorlzw).deflateandlzwcan be used with anydtype, andjpegwith the uint8dtype. With supporting Rasterio builds,jpegcan also be used with uint16, in which case the ortho is 12 bit JPEG compressed. Ifcompressis set toNone(the default),jpegis used for the uint8dtype, anddeflateotherwise.build_ovw (bool) – Whether to build overviews for the ortho image.
creation_options (dict | None) – Ortho image creation options as dictionary of
name: valuepairs. If supplied,compressis ignored. See the GDAL docs for details.overwrite (bool) – Whether to overwrite the ortho image if it exists.
progress (bool | dict) – Whether to display a progress bar monitoring the portion of ortho tiles written. Can be set to a dictionary of arguments for a custom tqdm bar.
- Return type:
None