eodal.utils.sentinel2 module¶
Sentinel-2 specific helper functions to interact with datasets organized in .SAFE structure.
Copyright (C) 2022 Lukas Valentin Graf
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
- eodal.utils.sentinel2.get_S2_acquistion_date_from_safe(dot_safe_name: str | Path) date[source]¶
Determines the image acquisition date of a dataset in .SAFE format based on the file naming
- Parameters:
dot_safe_name – name of the .SAFE dataset
- Returns:
image acquistion date
- eodal.utils.sentinel2.get_S2_acquistion_time_from_safe(dot_safe_name: str | Path) date[source]¶
Determines the image acquisition time of a dataset in .SAFE format based on the file naming
- Parameters:
dot_safe_name – name of the .SAFE dataset
- Returns:
image acquistion time (full timestamp)
- eodal.utils.sentinel2.get_S2_bandfiles(in_dir: Path, resolution: int | None = None, is_L2A: bool | None = True) List[Path][source]¶
returns all JPEG-2000 files (*.jp2) found in a dataset directory (.SAFE).
Todo
This seems to be a duplicate of
get_S2_bandfiles_with_res- Parameters:
search_dir – directory containing the JPEG2000 band files
resolution – select only spectral bands with a certain spatial resolution. Works currently on Sentinel-2 Level-2A data, only.
- Return files:
list of Sentinel-2 single band files
- eodal.utils.sentinel2.get_S2_bandfiles_with_res(in_dir: Path, band_selection: List[Tuple[str, int | float]], is_l2a: bool | None = True) DataFrame[source]¶
Returns the file-paths to the jp2 files with the spectral band data from a .SAFE Sentinel-2 dataset. Supports .SAFE datasets in L1C and L2A processing level.
- Parameters:
in_dir – Directory where the search_string is applied. Here - for Sentinel-2 - the it is the .SAFE directory of S2 rawdata files.
band_selection – list of tuples. Each tuple contains the name of Sentinel-2 band and its spatial resolution in meters.
is_l2a – if True (default), assumes that the data is in Sentinel-2 L2A processing level. If False, assumes L1C processing level.
- Returns:
pandas dataframe of jp2 files
- eodal.utils.sentinel2.get_S2_platform_from_safe(dot_safe_name: str | Path) str[source]¶
Determines the platform (e.g., S2A) from the dataset in .SAFE format based on the file naming
- Parameters:
dot_safe_name – name of the .SAFE dataset
- Returns:
platform name
- eodal.utils.sentinel2.get_S2_processing_baseline_from_safe(dot_safe_name: str | Path) int[source]¶
Determines the PDGS processing baseline of a dataset in .SAFE format based on the file naming
- Parameters:
dot_safe_name – name of the .SAFE dataset
- Returns:
PDGS baseline (e.g., N0400 -> 400)
- eodal.utils.sentinel2.get_S2_processing_level(dot_safe_name: str | Path) ProcessingLevels[source]¶
Determines the processing level of a dataset in .SAFE format based on the file naming
- Parameters:
dot_safe_name – name of the .SAFE dataset
- Returns:
processing level of the dataset
- eodal.utils.sentinel2.get_S2_sclfile(in_dir: Path, from_bandstack: bool | None = False, in_file_bandstack: Path | None = None) Path[source]¶
return the path to the S2 SCL (scene classification file). The method either searches for the SCL file in .SAFE structure (default, returning SCL file in 20m spatial resolution) or the resampled SCL file in case a
eodal.operational.resamplingderived band-stack was passed.- Parameters:
in_dir – either .SAFE directory (default use case) or the the directory containing the band-stacked geoTiff files (must have a sub-directory where the SCL files are stored)
from_bandstack – if False (Default) assumes the data to be in .SAFE format. If True the data must be band-stacked resampled geoTiffs derived from eodal’s processing pipeline
in_file_bandstack – file name of the bandstack for which to search the SCL file. Must be passed if
from_bandstack=True
- Returns scl_file:
SCL file-path
- eodal.utils.sentinel2.get_S2_tci(in_dir: Path, is_L2A: bool | None = True) Path[source]¶
Returns path to S2 TCI (quicklook) img (10m resolution). Works for both Sentinel-2 processing levels (‘L2A’ and ‘L1C’).
- Parameters:
in_dir – .SAFE folder which contains Sentinel-2 data
is_L2A – if False, it is assumed that the data is organized in L1C .SAFE folder structure. The default is True.
- Returns file_tci:
file path to the quicklook image