Temporal Fusion

The temporal_fusion method performs temporal fusion of geotiff files by grouping and merging them based on their acquisition dates. This process helps create more temporally consistent and spatially complete datasets since for some larger areas, the full extend is only captured over multiple days.

This method recursively scans the input_dir, detects .tif files, extracts their timestamps and band information, and organizes them into groups according to the specified range_type. The timestamp is aquired from the file path and if multiple timestamps area found, the oldest one is choosen. Currently implemented strategies are:

  • TemporalFusionType.CONNECTED: Groups images into continuous daily intervals (no date gaps).
  • TemporalFusionType.WEEKLY: Groups images into weekly intervals.
  • TemporalFusionType.MONTHLY: Groups images into monthly intervals.
  • TemporalFusionType.QUARTERLY: Groups images into quarterly intervals.
  • TemporalFusionType.YEARLY: Groups images into yearly intervals.

The fused outputs are saved in the specified output_dir, retaining band-specific structure and preserving original metadata (e.g., scale factors, offsets). The output name will follow this naming convention: <start date>_<name of the latest file, including the timestamp>.tif

Utilizes a NVIDIA GPU if available. If input_dir and output_dir are the same, the source files are getting deleted.

Fusion Method¤

The fusion mthod defines how multiple pixels in time for the samegeolocation are combined to a single resulting pixel.

  • TemporalFusionMethod.NEWEST: Selects the most recent valid pixel value.
  • TemporalFusionMethod.MEAN: Calculates the mean of all valid pixels.
  • TemporalFusionMethod.MIN: Selects the lowest valid pixel value.
  • TemporalFusionMethod.MAX: Selects the highest valid pixel value.

Parameters¤

Name Type Description
input_dir str Input directory path. Can contain subfolders. Either the file or the directory should contain a date string. The date string can be in any of these formats: yyyymmddThhmmss,yyydddhhmmss, yyyymmdd,yyyyddd
output_dir str The output directory will hold the fused images. The output file will be named with the time range fused. _.tif
fusion_type TemporalFusionType Temporal fusion method to be used.
fusion_method TemporalFusionMethod Specifies the method how the resulting pixels are calculated.
num_processes int To optimize and speed up the masking process, you can leverage parallel processing by defining the number of processes to use. For example, setting the number of processes to 5 allows for grouped time ranges to be fused simultaneously. Default is 1.

Example¤

Python
from sipt.fusion import temporal_fusion, TemporalFusionType, TemporalFusionMethod

temporal_fusion("./src", "./processed", TemporalFusionType.MONTHLY, TemporalFusionMethod.MEAN, 4)