s2d2.handler.sentinel2
Module Contents
Functions
|
given a dataframe with a filename within, create a dictionary with scene |
|
|
|
|
|
|
|
|
|
Create spatial metadata of a Sentinel-2, so no downloading is needed. |
|
The Sentinel-2 imagery are placed within a folder structure, where one |
|
|
|
get meta information of the Sentinel-2 file name |
|
the filename of the Sentinel-2 imagery has info about its date and tile |
|
the .SAFE file has info about orbit and sensor |
|
|
|
|
|
|
|
|
|
|
|
|
- s2d2.handler.sentinel2.get_s2_dict(s2_df)[source]
given a dataframe with a filename within, create a dictionary with scene and satellite specific metadata.
- Parameters:
s2_df (pd.dataframe) – metadata and general multi spectral information about the MSI instrument that is onboard Sentinel-2
- Returns:
s2_dict – dictionary with scene specific meta data, giving the following information: * ‘COSPAR’ : string
id of the satellite
- ’NORAD’string
id of the satellite
- ’instruments’{‘MSI’}
specific instrument
- ’launch_date’: string, e.g.:’+2015-06-23’
date when the satellite was launched into orbit
- ’orbit’: string
specifies the type of orbit
- ’full_path’: string
the location where the root folder is situated
- ’MTD_DS_path’: string
the location where metadata about the datastrip is present
- ’MTD_TL_path’: string
the location where metadata about the tile is situated
- ’QI_DATA_path’: string
the location where metadata about detector readings are present
- ’IMG_DATA_path’: string
the location where the imagery is present
- ’date’: string, e.g.: ‘+2019-10-25’
date of acquisition
- ’tile_code’: string, e.g.: ‘05VMG’
MGRS tile coding
- ’relative_orbit’: integer, {x ∈ ℕ}
orbit from which the imagery were taken
- Return type:
dictionary
Notes
The metadata is scattered over a folder structure for Sentinel-2, it has typically the following set-up:
* S2X_MSIL1C_20XX... <- path is given in s2_dict["full_path"] ├ AUX_DATA ├ DATASTRIP │ └ DS_XXX_XXXX... <- path is given in s2_dict["MTD_DS_path"] │ └ QI_DATA │ └ MTD_DS.xml <- metadata about the data-strip ├ GRANULE │ └ L1C_TXXXX_XXXX... <- path is given in s2_dict["MTD_TL_path"] │ ├ AUX_DATA │ ├ IMG_DATA │ │ ├ TXXX_X..XXX.jp2 │ │ └ TXXX_X..XXX.jp2 │ ├ QI_DATA │ └ MTD_TL.xml <- metadata about the tile ├ HTML ├ rep_info ├ manifest.safe ├ INSPIRE.xml └ MTD_MSIL1C.xml <- metadata about the product
The following acronyms are used:
AUX : auxiliary
COSPAR : committee on space research international designator
DS : datastrip
IMG : imagery
L1C : product specification,i.e.: level 1, processing step C
MGRS : military grid reference system
MTD : metadata
MSI : multi spectral instrument
NORAD : north american aerospace defense satellite catalog number
TL : tile
QI : quality information
s2 : Sentinel-2
See also
- s2d2.handler.sentinel2.get_generic_s2_raster(tile_code, spac=10, tile_path=None)[source]
Create spatial metadata of a Sentinel-2, so no downloading is needed.
- Parameters:
tile_code (string) – mgrs tile coding, which is also given in the filename (“TXXXXX”)
spac (integer, {10,20,60}, unit=m) – pixel spacing of the raster
tile_path (string) – path to the MGRS tiling file
- Returns:
tuple – georeference transform of an image, including shape
pyproj.crs.crs.CRS – coordinate reference system (CRS)
Notes
- The tile structure is a follows “AABCC”
“AA” utm zone number, starting from the East, with steps of 8 degrees
“B” latitude zone, starting from the South, with steps of 6 degrees
- The following acronyms are used:
CRS : coordinate reference system
MGRS : US military grid reference system
s2 : Sentinel-2
- s2d2.handler.sentinel2.get_s2_image_locations(fname, s2_df)[source]
The Sentinel-2 imagery are placed within a folder structure, where one folder has an ever changing name. Fortunately this function finds the path from the metadata
- Parameters:
fname (string) – path string to the Sentinel-2 folder
s2_df (pandas.dataframe) – index of the bands of interest
- Returns:
s2_df_new (pandas.dataframe) – dataframe series with relative folder and file locations of the bands
datastrip_id (string) – folder name of the metadata
Examples
>>> import os >>> from s2d2.handler.sentinel2 import get_s2_image_locations >>> fpath = '/Users/Data/' >>> sname = 'S2A_MSIL1C_20200923T163311_N0209_R140_T15MXV_20200923T200821.SAFE' >>> fname = 'MTD_MSIL1C.xml' >>> full_path = os.path.join(fpath, sname, fname) >>> im_paths, datastrip_id = get_s2_image_locations(full_path) >>> im_paths ['GRANULE/L1C_T15MXV_A027450_20200923T163313/IMG_DATA/T15MXV_20200923T163311_B01', 'GRANULE/L1C_T15MXV_A027450_20200923T163313/IMG_DATA/T15MXV_20200923T163311_B02'] >>> datastrip_id 'S2A_OPER_MSI_L1C_DS_VGS1_20200923T200821_S20200923T163313_N02.09'
- s2d2.handler.sentinel2.meta_s2string(s2_str)[source]
get meta information of the Sentinel-2 file name
- Parameters:
s2_str (string) – filename of the L1C data
- Returns:
s2_date (datetime, unit=days) – date the acquisition
s2_orbit (string) – relative orbit “RXXX”
s2_tile (string) – tile code “TXXXXX”
Examples
>>> from s2d2.handler.sentinel2 import get_s2_image_locations, meta_s2string >>> s2_str = 'S2A_MSIL1C_20200923T163311_N0209_R140_T15MXV_20200923T200821.SAFE' >>> s2_date, s2_orbit, s2_tile = meta_s2string(s2_str) >>> s2_date.strftime("+%Y-%m-%d") '+2020-09-23' >>> s2_orbit 'R140' >>> s2_tile 'T15MXV'
- s2d2.handler.sentinel2.meta_s2_band_string(s2_str)[source]
the filename of the Sentinel-2 imagery has info about its date and tile
- Parameters:
s2_str (string) – filename of the L1C data
- Returns:
s2_date (datetime, unit=days) – date the acquisition
s2_tile (string) – tile code “TXXXXX”
- s2d2.handler.sentinel2.meta_s2_safe_string(s2_str)[source]
the .SAFE file has info about orbit and sensor
- Parameters:
s2_str (string) – filename of the L1C data
- Returns:
s2_date (datetime, unit=days) – date the acquisition
s2_orbit (string) – relative orbit “RXXX”
s2_tile (string) – tile code “TXXXXX”
- s2d2.handler.sentinel2.get_utmzone_from_tile_code(tile_code)[source]
- Parameters:
tile_code (string, e.g.: '05VMG') – MGRS tile coding
- Returns:
utmzone – code used to denote the number of the projection column of UTM
- Return type:
integer
Notes
- The tile structure is a follows “AABCC”
“AA” utm zone number, starting from the East, with steps of 8 degrees
“B” latitude zone, starting from the South, with steps of 6 degrees
The following acronyms are used:
CRS : coordinate reference system
MGRS : US military grid reference system
UTM : universal transverse mercator
WGS : world geodetic system
- s2d2.handler.sentinel2.get_epsg_from_mgrs_tile(tile_code)[source]
- Parameters:
tile_code (string, e.g.: '05VMG') – MGRS tile coding
- Returns:
epsg – code used to denote a certain database entry
- Return type:
integer
See also
dhdt.generic.get_utmzone_from_mgrs_tile,dhdt.generic.get_crs_from_mgrs_tileNotes
- The tile structure is a follows “AABCC”
“AA” utm zone number, starting from the East, with steps of 8 degrees
“B” latitude zone, starting from the South, with steps of 6 degrees
The following acronyms are used:
CRS : coordinate reference system
EPSG : european petroleum survey group (a coordinate refenence database)
MGRS : US military grid reference system
UTM : universal transverse mercator
WGS : world geodetic system
- s2d2.handler.sentinel2.get_crs_from_mgrs_tile(tile_code)[source]
- Parameters:
tile_code (string) – US Military Grid Reference System (MGRS) tile code
- Returns:
crs – target projection system
- Return type:
osgeo.osr.SpatialReference
See also
get_utmzone_from_mgrs_tile,get_utmzone_from_mgrs_tileNotes
- The tile structure is a follows “AABCC”
“AA” utm zone number, starting from the East, with steps of 8 degrees
“B” latitude zone, starting from the South, with steps of 6 degrees