Sen2cor DEM parameters

Hello all,
I am currently processing L1C datasets to get L2A level product, I would like now to implement local DEM within my process and I’d like to know what parameters are requested for a local DEM (file format, nodats values etc ) .
HAd a look at the sen2core manual but nothing much if you want to implement your own DEm.
Regards

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

Hello Federico ,
Thanks for the reply, I wil ltry to go trough all the steps you mentioned and test sen2core with my local DEM.
Regards

Hey Federico

Your approach seams pretty cool, thanks for sharing! I tried to use it for my local DEM as well but I somehow failed :smirk:.

gdalwarp -of GTiff -ot Int16 -r bilinear -s_srs "+proj=utm +zone=32 +datum=WGS84" -t_srs "+proj=latlong +datum=WGS84" -te 4.9995833 44.9995833 9.9995833 49.9995833 -tr 0.0000925925925 -0.0000925925925 -srcnodata -32768 -dstnodata -32768 -co BIGTIFF=YES DEM_NE_Switz10.tif srtm_38_03.tif

Unfortunately the output comes with values from -32768 to 32767 (when i open it in ArcMap, Original local DEM is from 405 to 2837 m) and is blank or black when I open it in SNAP respectively. Do you reckon that this is due to the extent of the original DEM (only a small area in Switzerland)? I’m sorry I’m pretty new to Sen2cor and SNAP. Any help is very much appreciated!

Cheers
Ben

Dear @Benja,

apart from being black, which are the pixel values you get in the output DEM?
Did you set the parameter ‘-srcnodata’ (source raster no data value) consistent with the actual no data value of the input raster? You can check it using:

gdalinfo DEM_NE_Switz10.tif

I do not know which is the behaviour of the generation of the output file outside the extent of the input file, actually is should be set to no data.

Federico

Ciao @FedericoF

Thanks a lot for the quick reply. Gdalinfo fails to compute values from the output, no valid pixels are found in sampling. No data values of the output are consistent with the ones of the input raster. Only difference I see is the data type = generic in the input and compression=LWZ, data type stays generic (contrary to the original srtm DEM), might that be the reason for the failure?
Regarding the values outside the extent I was assuming the same behaviour.

Ben

Hello,
I am not sure if this question is relevant to this thread but regarding areas of the World not covered by SRTM how can we proceed in using our own DEM in Sen2cor?

Thank you!

have you seen these topics?

2 Likes

Hello,

I have, thank you! it’s not what I am looking for, past month i’ve been around this issue without being able to solve it. Disguised my DEM as a SRTM as quoted below but didn’t work. So suspect it has to do with the fact that SRTM does not cover all the globe.

So my question is, what does Sen2cor use in the latitudes not covered by the SRTM mission? and is it possible to change the code in a way to use a local DEM?

My goal is to correct the topographic issues meaning the shadow so that’s why I need to use a high resolution dem.

I’m new to SNAP so I’m sorry if this question doesn’t make sense. In case there is no way around Sen2cor my question would be is there a way to run the correction through SNAP and using the local dem?

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

Thank you!

Dear @SofiaB,

here I have described a procedure to generate a DEM compatible with Sen2Cor v2.4.0 using your own DEM:

I have not tested on laterSen2Cor versions, but you might have a try.

Federico

1 Like

Hello,
Thank you, tested and works for areas covered by SRTM. But for areas where there is actually no SRTM it doesn’t work. Hence my question regarding what Sen2cor uses for these latitudes not covered by SRTM.

Thank you again!

Dear @SofiaB,

unfortunately I do not know a workaround to deal with geographic areas not covered by SRTM.
Maybe some of the Sen2Cor development team may answer this issue.

May I ask you the Sen2Cor version used to successfully test the procedure?

Federico

Dear @FedericoF,

I hope they can answer, thank you.

I used the latest version of Sen2cor - 2.8

Best wishes

Sofia