Raster processing

remote_sensing_processor.process(input_path, output_path=None, fill_nodata=False, fill_distance=250, clip=None, crs=None, nodata=None, reference_raster=None, resample='average', dtype=None, write_stac=True)[source]

Processes a single raster. Can clip, reproject, match, fill nodata and change data type.

Parameters:
  • input_path (string or STAC Item) – Path to input file, directory or STAC dataset or a STAC Item (e.g., from Planetary Computer).

  • output_path (string (optional)) – Path to an output file, directory, or STAC dataset. If not set, then will overwrite the input files. Must be set if input is a remote STAC Item.

  • fill_nodata (bool (default = False)) – Is filling the gaps in the raster needed.

  • fill_distance (int (default = 250)) – Fill distance for fill_nodata function.

  • clip (string (optional)) – Path to a vector file to be used to crop the image.

  • crs (string (optional)) – CRS in which output data should be.

  • nodata (int or float (default = None)) – Nodata value. If not set, then is read from inputs.

  • reference_raster (string or STAC Item (optional)) – Reference raster is needed to bring output mosaic raster to the same resolution and projection as another data source. It is useful when you need to use data from different sources together.

  • resample (resampling method from rasterio as a string (default = 'average')) – Resampling method that will be used to reproject and reshape to a reference raster shape. You can read more about resampling methods here. Use ‘nearest’ if you want to keep only the same values that exist in the input raster.

  • dtype (dtype definition as a string (optional)) – Requested output data type.

  • write_stac (bool (default = True)) – If True, then output metadata is saved to a STAC file.

Returns:

Path where output raster is saved.

Return type:

pathlib.Path

Examples

>>> import remote_sensing_processor as rsp
>>> # Fill gaps in a raster
>>> rsp.process(
...     input_path="/home/rsp_test/sentinel_B1.tif",
...     output_path="/home/rsp_test/sentinel_B1_filled.tif",
...     fill_nodata=True,
...     fill_distance=500,
... )
'/home/rsp_test/sentinel_B1_filled.json'
>>> # Clip and reproject Sentinel-2 dataset
>>> rsp.process(
...     input_path="/home/rsp_test/sentinels/Sentinel1/meta.json",
...     clip="/home/rsp_test/site_border.gpkg",
...     crs="EPSG:4269",
... )
'/home/rsp_test/sentinels/Sentinel1/meta.json'
>>> # Match a raster with a reference raster
>>> rsp.process(
...     input_path="/home/rsp_test/DEM.tif",
...     output_path="/home/rsp_test/DEM_matched.tif",
...     reference_raster="/home/rsp_test/sentinel_B1.tif",
... )
'/home/rsp_test/DEM_matched.json'