Sen2cor DEM parameters

It is not currently possible to set a local DEM as for sen2cor v2.4.0.

A workaround that is working in my case is to replace the SRTM tiles with your local DEM, in the folder you have set in the L2A_GIP file as ‘DEM_Directory’. This is made possible because ‘gdalwarp’ command is used to clip and resize DEM to the extent and resolution of the granule processed in sen2cor.
You can also store many local DEM datasets in different folders, and specify the one you would like to use with the ‘DEM_Directory’ parameter in sen2cor L2A_GIP configuration file.

In order to generate your local DEM it in the right way, you should be careful about the following issues:

  • file name must be exactly the same used by SRTM tiles (e.g. ‘srtm_39_04.tif’)
  • coordinate reference system must be WGS84 (EPSG:4326)
  • the geographic extent must be the same of the SRTM tile you are replacing
  • format should be GeoTIFF
  • DataType should be Int16
  • ‘nodata’ values should be set to ‘-32768’
  • resolution can be the one you prefer, the best option is to keep the one of your local DEM
  • DEM unit is set can be set in the L2A_GIP configuration file, the default used for SRTM is in meters

As example, I report the command I used to generate my local DEM to replace the SRTM tile ‘srtm_39_04.tif’ from a 20 m DEM with a different CRS using GDAL:

gdalwarp -of GTiff -ot Int16 -r bilinear -s_srs “+proj=utm +zone=32 +datum=WGS84” -t_srs “+proj=latlong +datum=WGS84” -te 9.9995833 39.9995833 14.9995833 44.9995833 -tr 0.000185185185185 -0.000185185185185 -srcnodata -32768 -dstnodata -32768 -co ‘BIGTIFF=YES’ /media/workspace/dem20.tif /media/workspace/srtm_39_04.tif

Please be aware that if you are not replacing the SRTM file with a proper local DEM file, the resulting Sentinel-2 L2A from sen2cor may be uncorrect.
You can also have a look at the differences between the many DEM datasets used in the atmospheric correction process, which are located in the ‘AUX_DATA’ of the resulting L2A granule.
From my experience, local DEM higher spatial resolution can in some cases return a L2A product with some artifact, depending on the spatial resolution and accuracy of the local DEM you are using.

6 Likes