collocate#
- collocate(reference_meta: dict, other_arr: ~typing.Union[~numpy.ndarray, ~numpy.ma.core.MaskedArray], other_meta: dict, resampling: ~rasterio.enums.Resampling = Resampling.nearest) -> (typing.Union[numpy.ndarray, numpy.ma.core.MaskedArray], <class 'dict'>)[source]#
Collocate two georeferenced arrays: forces the other raster to be exactly georeferenced onto the reference raster by reprojection.
>>> reference_path = "path/to/reference.tif" >>> other_path = "path/to/other.tif" >>> col_path = "path/to/collocated.tif" >>> # Just open the master data >>> with rasterio.open(reference_path) as reference_dst: >>> # Read other >>> other, other_meta = read(other_path) >>> # Collocate the other to the reference >>> col_arr, col_meta = collocate(reference_dst.meta, >>> other, >>> other_meta, >>> Resampling.bilinear) >>> # Write it >>> write(col_arr, col_path, col_meta)