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.

Use it like OTB SuperImpose.

>>> 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)
Parameters
  • master_meta (dict) – Master metadata

  • slave_arr (np.ma.masked_array) – Slave array to be collocated

  • slave_meta (dict) – Slave metadata

  • resampling (Resampling) – Resampling method

Returns

Collocated array and its metadata

Return type

np.ma.masked_array, dict