collocate
collocate#
- collocate(master_meta: dict, slave_arr: typing.Union[numpy.ma.core.MaskedArray, numpy.ndarray], slave_meta: dict, resampling: rasterio.enums.Resampling = Resampling.nearest) -> (typing.Union[numpy.ma.core.MaskedArray, numpy.ndarray], <class 'dict'>)[source]#
Collocate two georeferenced arrays: forces the slave raster to be exactly georeferenced onto the master raster by reprojection.
>>> master_path = "path/to/master.tif" >>> slave_path = "path/to/slave.tif" >>> col_path = "path/to/collocated.tif" >>> # Just open the master data >>> with rasterio.open(master_path) as master_dst: >>> # Read slave >>> slave, slave_meta = read(slave_path) >>> # Collocate the slave to the master >>> col_arr, col_meta = collocate(master_dst.meta, >>> slave, >>> slave_meta, >>> Resampling.bilinear) >>> # Write it >>> write(col_arr, col_path, col_meta)