johntruckenbrodt / pyroSAR

framework for large-scale SAR satellite data processing
MIT License
508 stars 112 forks source link

new Copernicus DEM download option #239

Open johntruckenbrodt opened 1 year ago

johntruckenbrodt commented 1 year ago

The data can now be downloaded from Copernicus without authentication: https://sentinel.esa.int/web/sentinel/-/copernicus-dem-new-direct-data-download-access

This option should be added to function pyroSAR.auxdata.dem_autoload.

MarkusZehner commented 7 months ago

Maybe of interest: cubo can get Cop GLO 30 from Planetary Computer, but I don't know if that requires an access token. The export is in UTM coordinates by default.

import os
import cubo
from rasterio.enums import Resampling

def load_dem_data(dem_path, lat, lon, edge_size, resolution):
    if not os.path.exists(dem_path):
        print('Downloading DEM')
        dem = cubo.create(
            lat=lat,  # Central latitude of the cube
            lon=lon,  # Central longitude of the cube
            collection="cop-dem-glo-30",  # Name of the STAC collection
            # bands=["B02","B03","B04"],
            bands=["data"],  # Bands to retrieve
            start_date="2000-01-01",  # Start date of the cube
            end_date="2024-01-06",  # End date of the cube
            edge_size=edge_size,  # Edge size of the cube (px)
            resolution=resolution,  # Pixel size of the cube (m)
            stackstac_kw={'resampling': Resampling.cubic},  # kwargs passed to stackstac
        )
        if "time" in dem.dims:
            dem = dem.mean(dim='time')
        dem.rio.write_crs(dem.epsg.values, inplace=True)
        dem.isel(band=0).rio.to_raster(dem_path)
    else:
        print('DEM exists')
johntruckenbrodt commented 7 months ago

Thanks @MarkusZehner. Using cubo for this would be overkill in pyroSAR but it is good to know how others do it and what other sources exist. As long as there are authentication-free sources I prefer sticking to them though.