Landsat preprocessing

remote_sensing_processor.landsat(inputs, output_path=None, crs=None, cloud_mask=True, pansharpen=True, keep_pan_band=False, resample='gradient_search', clip=None, t='k', normalize=False, write_stac=True)[source]

Preprocess Landsat imagery.

Parameters:
  • inputs (string or list of strings or STAC Item or list of STAC Items) – Path to archive / directory or list of paths to archives / directories or a STAC Item or list of STAC Items (e.g., from Planetary Computer).

  • output_path (string (optional)) – Path to output directory. If not set, then will write to the same directory as archive. Must be set if the inputs are remote STAC Items.

  • crs (any (optional)) – CRS in which output data should be or same to get CRS from the first archive.

  • cloud_mask (bool (default = True)) – Is cloud masking needed.

  • pansharpen (bool (default = True)) – Is pansharpening needed. RSP uses Brovey transform for pansharpening Landsat 7, 8 and 9.

  • keep_pan_band (bool (default = False)) – Keep a pansharpening band or delete it. The pansharpening band has the same wavelengths as optical bands, so it does not contain any additional information to other bands. Affects only Landsat 7, 8 and 9.

  • resample (resampling method from satpy as a string (default = 'gradient_search')) – Resampling method that will be used to upscale bands that cannot be upscaled in pansharpening operation. You can read more about resampling methods here. Affects only Landsat 7, 8 and 9.

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

  • t (string ('k' or 'c', default = 'k')) – Convert thermal bands to kelvins or celsius (no fahrenheit lol).

  • normalize (bool (default = False)) – Is min-max normalization to 0-1 range needed.

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

Returns:

List of paths where preprocessed Landsat products are saved.

Return type:

list of pathlib.Paths

Examples

>>> import remote_sensing_processor as rsp
>>> from glob import glob
>>> landsat_imgs = glob("/home/rsp_test/landsat/*.tar")
>>> print(landsat_imgs)
['/home/rsp_test/landsat/LC08_L1TP_160023_20210825_20210901_02_T1.tar',
 '/home/rsp_test/landsat/LT05_L1TP_160023_20110814_20200820_02_T1.tar',
 '/home/rsp_test/landsat/LE07_L1TP_159023_20210826_20210921_02_T1.tar',
 '/home/rsp_test/landsat/LT05_L1TP_162023_20110812_20200820_02_T1.tar',
 '/home/rsp_test/landsat/LM05_L1TP_161023_19930803_20211018_02_T2.tar']
>>> output_landsats = rsp.landsat(landsat_imgs)
Preprocessing of /home/rsp_test/landsat/LC08_L1TP_160023_20210825_20210901_02_T1.tar completed
Preprocessing of /home/rsp_test/landsat/LT05_L1TP_160023_20110814_20200820_02_T1.tar completed
Preprocessing of /home/rsp_test/landsat/LE07_L1TP_159023_20210826_20210921_02_T1.tar completed
Preprocessing of /home/rsp_test/landsat/LT05_L1TP_162023_20110812_20200820_02_T1.tar completed
Preprocessing of /home/rsp_test/landsat/LM05_L1TP_161023_19930803_20211018_02_T2.tar completed
>>> print(output_landsats)
['/home/rsp_test/landsat/LC08_L1TP_160023_20210825_20210901_02_T1/LC08_L1TP_160023_20210825_20210901_02_T1.json',
 '/home/rsp_test/landsat/LT05_L1TP_160023_20110814_20200820_02_T1/LT05_L1TP_160023_20110814_20200820_02_T1.json',
 '/home/rsp_test/landsat/LE07_L1TP_159023_20210826_20210921_02_T1/LE07_L1TP_159023_20210826_20210921_02_T1.json',
 '/home/rsp_test/landsat/LT05_L1TP_162023_20110812_20200820_02_T1/LT05_L1TP_162023_20110812_20200820_02_T1.json',
 '/home/rsp_test/landsat/LM05_L1TP_161023_19930803_20211018_02_T2/LM05_L1TP_161023_19930803_20211018_02_T2.json']