Module export
All functions here are automatically loaded with from sits import export.
export.Sits_ds
- class sits.export.Sits_ds(nc_path=None)
Bases:
objectThis class aims to convert xarray objects (Dataset or DataArray) to animated formats. It provides functionality to convert xarray objects to GIF or video formats. Optional features include time frequency regularization through pixel interpolation and smooth frame transitions using blender mode.
- ds
time series (‘time’, ‘y’, ‘x’)
- Type:
xr.Dataset
- da
time series (‘time’, ‘band’, ‘y’, ‘x’)
- Type:
xr.Dataarray
- Parameters:
nc_path (str, optional) – netcdf filename to import into xarray object. Defaults to None.
Example
>>> geo_dc = Sits_ds(netcdf_file)
- blender(steps_between=5)
Generates intermediate blended frames between consecutive images to achieve smooth transitions in animated GIFs.
- Parameters:
steps_between (int, optional) – number of intermediate blended frames to generate between each pair of images. Defaults to 5.
- Returns:
Dataset with regular time steps.
- Return type:
Sits_ds.ds (xr.Dataset)
Example
>>> geo_dc.time_interp() >>> geo_dc.blender()
- export2gif(imgfile=None, fps=8, robust=True, keep_bands=['B04', 'B03', 'B02'], **kwargs)
Creates satellite timelapse, and exports it as animated GIF file.
- Parameters:
imgfile (string, optional) – GIF file path.
fps (int, optional) – frames per second
robust (bool, optional) – calculate vmin and vmax from the 2nd and 98th percentiles of the data. Defaults to True.
keep_bands (list, optional) – bands to keep (1 or 3 bands for gif export).
- Returns:
IPython.display.Imageifimgfileis None.- Return type:
Sits_ds.gif
Example
>>> geo_dc.export2gif(imgfile='myTimeSeries.gif')
- export2vid(output_path: str, keep_bands: list, fps: int = 10, colormap: str = 'viridis', vmin=None, vmax=None, square=False, watermark_text=None, watermark_loc='bottom right', watermark_param=None, square_param=None)
Export EO time series to video, supporting RGB and monoband with colormap.
- Parameters:
output_path (str) – output filename. The video format is determined by the file extension, if supported by the ImageIO library.
keep_bands (list) – list of band names/indices to retain. (requires 1-3 bands)
fps (int, optional) – Defaults to 10.
colormap (str, optional) – Defaults to “viridis”.
vmin (float, optional) – minimum value for band contrast. Defaults to None.
vmax (float, optional) – maximum value for band contrast. Defaults to None.
square (bool, optional) – resizes frames to square format (see Sits_ds.__pad_to_square()). Defaults to False.
watermark_text (str, optional) – watermark text. Defaults to None.
watermark_loc (str, optional) – position of watermark text. Choices: ‘top left’, ‘top right’, ‘bottom left’, ‘bottom right’. Defaults to ‘bottom right’.
watermark_param (**kwargs, optional) – see Sits_ds.__add_watermark().
square_param (**kwargs, optional) – see Sits_ds.__pad_to_square().
- time_interp(method='slinear', nb_period=100)
Transforms the input
Sits_ds.ds(xr.Dataset) into a regular time-step datacube. This function resamples or interpolates the input Dataset to create a uniformly spaced time dimension. It is particularly useful for preparing data for animations, temporal analysis, or numerical modeling where consistent temporal intervals are required.- Parameters:
method (str, optional) – interpolation method to use. Defaults to ‘slinear’.
nb_period (int, optional) – number of output dates. Defaults to 100
- Returns:
Dataset with regular time steps
- Return type:
Sits_ds.ds (xr.Dataset)
Example
>>> geo_dc = Sits_ds(netcdf_file) >>> geo_dc.time_interp()