Terrain Data Processors
Find, merge, and regrid the source raster tiles (Copernicus GLO-30 DEM, ESA WorldCover land cover) that clip to a scene's extents, plus the buffer mask derived from them.
Tile processors
s2gos_generator.processors.terrain_data.base_processor.BaseTileProcessor
Bases: ABC
Base class for tile-based data processors (DEM, LandCover, etc.).
Initialize the base tile processor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset
|
Dataset
|
Dataset containing the data tiles. |
required |
Attributes
data_type
abstractmethod
property
Data type to cast the data to (e.g., 'uint8'), or None for no casting.
data_variable_name
abstractmethod
property
Name of the data variable in the processed dataset.
default_fill_value
abstractmethod
property
Default fill value for NaN values.
default_interpolation_method
abstractmethod
property
Default interpolation method for regridding.
use_context_manager
abstractmethod
property
Whether to use context manager when opening data arrays.
Functions
s2gos_generator.processors.terrain_data.dem.DEMProcessor
Bases: BaseTileProcessor
Finds, merges, and processes Copernicus GLO-30 DEM tiles for a given AOI.
Initialize the DEM processor.
Attributes
data_type
property
Data type to cast the data to (DEM data stays as float).
data_variable_name
property
Name of the data variable in the processed dataset.
default_fill_value
property
Default fill value for NaN values in DEM data.
default_interpolation_method
property
Default interpolation method for DEM regridding.
use_context_manager
property
DEM processor uses context manager for file opening.
Functions
generate_dem
generate_dem(
aoi_polygon: Polygon,
output_path: UPath,
fillna_value: Optional[float] = 0.0,
target_resolution_m: Optional[float] = None,
center_lat: Optional[float] = None,
center_lon: Optional[float] = None,
aoi_size_km: Optional[float] = None,
flatten_dem: bool = False,
) -> xr.Dataset
Generate DEM data for the AOI.
s2gos_generator.processors.terrain_data.landcover.LandCoverProcessor
Bases: BaseTileProcessor
Finds, merges, and processes ESA WorldCover land cover tiles for a given AOI.
Initialize the land cover processor.
Attributes
data_variable_name
property
Name of the data variable in the processed dataset.
default_fill_value
property
Default fill value for NaN values in landcover data.
default_interpolation_method
property
Default interpolation method for land cover regridding.
use_context_manager
property
Landcover processor uses direct assignment for file opening.
Functions
generate_landcover
generate_landcover(
aoi_polygon: Polygon,
output_path: UPath,
target_resolution_m: float = 10.0,
center_lat: Optional[float] = None,
center_lon: Optional[float] = None,
aoi_size_km: Optional[float] = None,
) -> xr.Dataset
Generate landcover data for the AOI with configurable resolution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
aoi_polygon
|
Polygon
|
Area of interest polygon |
required |
output_path
|
UPath
|
Path where to save the processed landcover data |
required |
target_resolution_m
|
float
|
Target resolution in meters (default: 10.0 for native WorldCover) |
10.0
|
center_lat
|
Optional[float]
|
Center latitude for projection (required for non-native resolution) |
None
|
center_lon
|
Optional[float]
|
Center longitude for projection (required for non-native resolution) |
None
|
aoi_size_km
|
Optional[float]
|
Size of the AOI in kilometers (required for non-native resolution) |
None
|
Returns:
| Type | Description |
|---|---|
Dataset
|
Processed landcover dataset |
Regridding & masks
s2gos_generator.processors.terrain_data.datautil.regrid_to_projection
regrid_to_projection(
dataset: Dataset,
target_resolution_m: float,
center_lat: float,
center_lon: float,
aoi_size_km: float,
interpolation_method: str = "linear",
fillna_value: Optional[float] = None,
data_variable: Optional[str] = None,
) -> xr.Dataset
Regrid dataset to target resolution using oblique mercator projection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset
|
Dataset
|
Input xarray Dataset with lat/lon coordinates |
required |
target_resolution_m
|
float
|
Target resolution in meters |
required |
center_lat
|
float
|
Center latitude for projection |
required |
center_lon
|
float
|
Center longitude for projection |
required |
aoi_size_km
|
float
|
Area of interest size in kilometers |
required |
interpolation_method
|
str
|
Interpolation method ("linear", "nearest", etc.) |
'linear'
|
fillna_value
|
Optional[float]
|
Value to fill NaN values with (optional) |
None
|
data_variable
|
Optional[str]
|
Specific data variable to process for fillna (optional) |
None
|
Returns:
| Type | Description |
|---|---|
Dataset
|
Regridded xarray Dataset with oblique mercator coordinates |
Raises:
| Type | Description |
|---|---|
RegridError
|
If regridding operation fails |
s2gos_generator.processors.terrain_data.masks.generate_buffer_mask
Generates a square buffer mask texture with center hole for target area.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mask_size
|
int
|
Total size of the mask in pixels (buffer area) |
required |
target_size
|
int
|
Size of the center hole in pixels (target area) |
required |
output_path
|
UPath
|
UPath where the mask will be saved |
required |
Returns:
| Type | Description |
|---|---|
UPath
|
Path to the generated mask file |