terrain flattening with the default srtmgl1 hgt option works fine, but whenever I specify an external dem, I get a nullpointer exception. I remember reading in some other post that the combination of regrid=true (default) + external dem is not supported, is that true?
Any tips on using an external dem with terrain flattening?
the DEM must be projected in geographic coordinates (lat/lon) and stored as a GeoTiff.
And of course, it must coarsely match the area of your SAR image.
However, gpt Terrain-Flattening -h still shows the reGridMethod option:
gpt Terrain-flattening -h
INFO: org.esa.snap.core.gpf.operators.tooladapter.ToolAdapterIO: Initializing external tool adapters
SEVERE: org.esa.s2tbx.dataio.gdal.activator.GDALDistributionInstaller: The environment variable LD_LIBRARY_PATH does not contain the current folder '.'. Its value is '/usr/local/lib'.
Usage:
gpt Terrain-flattening [options]
Description:
Terrain Flattening
Source Options:
-Ssource=<file> Sets source 'source' to <filepath>.
This is a mandatory source.
Parameter Options:
-PadditionalOverlap=<double> The additional overlap percentage
Valid interval is [0, 1].
Default value is '0.1'.
-PdemName=<string> The digital elevation model.
Default value is 'SRTM 1Sec HGT'.
-PdemResamplingMethod=<string> Sets parameter 'demResamplingMethod' to <string>.
Default value is 'BILINEAR_INTERPOLATION'.
-PexternalDEMFile=<file> Sets parameter 'externalDEMFile' to <file>.
-PexternalDEMNoDataValue=<double> Sets parameter 'externalDEMNoDataValue' to <double>.
Default value is '0'.
-PoutputSimulatedImage=<boolean> Sets parameter 'outputSimulatedImage' to <boolean>.
Default value is 'false'.
-PoversamplingMultiple=<double> The oversampling factor
Valid interval is [1, 4].
Default value is '1.5'.
-PreGridMethod=<boolean> Sets parameter 'reGridMethod' to <boolean>.
Default value is 'true'.
-PsourceBands=<string,string,string,...> The list of source bands.
Graph XML Format:
<graph id="someGraphId">
<version>1.0</version>
<node id="someNodeId">
<operator>Terrain-Flattening</operator>
<sources>
<source>${source}</source>
</sources>
<parameters>
<sourceBands>string,string,string,...</sourceBands>
<demName>string</demName>
<demResamplingMethod>string</demResamplingMethod>
<externalDEMFile>file</externalDEMFile>
<externalDEMNoDataValue>double</externalDEMNoDataValue>
<outputSimulatedImage>boolean</outputSimulatedImage>
<additionalOverlap>double</additionalOverlap>
<oversamplingMultiple>double</oversamplingMultiple>
<reGridMethod>boolean</reGridMethod>
</parameters>
</node>
</graph>
Has anyone ever got this working? If so, could you please comment, so I know al my trials are not in vain…
Or maybe someone could just try, for validation’s sake…?
I’m still trying to get Terrain-Flattening working with an external dem. My dem is a geotiff, it matches the scene footprint with overlap, but I still get a nullpointer exception whatever I try.
Are there any more restrictions to the dem (format)? It does work with Terrain-Correction (with the same dem)…
Any idea how to proceed here? We’d really like to get this working and be able to use a better and higher resolution dem for the terrain flattening. Is there a way to debug this, or to get a more informative backtrace? Should I file a bug in the s1tbx github?
the problem has been resolved in SNAP v7. I used a 10m DEM with WGS84 and integer heights and SNAP was able to use it in the Radiometric Terrain Flattening
It seems to work in some runs and make errors in others starting with
Problem reading DEM: null
…and ending …
Error: javax.imageio.IIOException: 16-bit samples are not supported for Horizontal differencing Predictor
So this error might be related to compressed DEM files or similar old errors…
The DEM file must be uncompressed TIFF. Your’s is COMPRESSION=DEFLATE.
Use gdal_translate to convert to an uncompressed tiff (the default)?
Side note: This issue with compressed TIFFs and DEMs originally popped up when I installed S2TBX years ago. With only S1TBX installed I believe I could use compressed TIFFs.
The funny detail is, that more than half of the single scenes still get terrain-flattening working, just some of the files from one day are failing. But I will test with an uncompressed dem … let’s see.
Still fails in the same way as with a compressed DEM. Something else is wrong!
Here is the output of the failing gpt run:
snap/bin/gpt conda/sen2mosaic/lib/python3.7/site-packages/sen1mosaic-0.2-py3.7.egg/sen1mosaic/…/cfg/3_terrain_correction_db.xml -x -Pinputfile=/data/incoming/sat/S1B_IW_GRDH_1SDV_20190811T154022_20190811T154050_017540_020FD1_5F6D_processed_cal_mtl_1t.dim -Poutputfile=/data/incoming/sat/S1_processed_20190811_154022_154050_017540_020FD1 -Pextent=500,500,11712,9576
INFO: org.esa.snap.core.gpf.operators.tooladapter.ToolAdapterIO: Initializing external tool adapters
SEVERE: org.esa.s2tbx.dataio.gdal.activator.GDALDistributionInstaller: The environment variable LD_LIBRARY_PATH is not set. It must contain the current folder ‘.’.
Executing processing graph
INFO: org.hsqldb.persist.Logger: dataFileCache open start
…java.lang.NullPointerException
java.lang.NullPointerException
java.lang.NullPointerException
java.lang.NullPointerException
java.lang.NullPointerException
90% done.
org.esa.snap.core.gpf.OperatorException: java.lang.NullPointerException
at org.esa.snap.core.gpf.graph.GraphProcessor$GPFImagingListener.errorOccurred(GraphProcessor.java:363)
at com.sun.media.jai.util.SunTileScheduler.sendExceptionToListener(SunTileScheduler.java:1646)
at com.sun.media.jai.util.SunTileScheduler.scheduleTile(SunTileScheduler.java:921)
at javax.media.jai.OpImage.getTile(OpImage.java:1129)
at javax.media.jai.PlanarImage.cobbleFloat(PlanarImage.java:3254)
at javax.media.jai.PlanarImage.getData(PlanarImage.java:2181)
at com.bc.ceres.glevel.MultiLevelImage.getData(MultiLevelImage.java:64)
at org.esa.snap.core.datamodel.Band.readRasterData(Band.java:311)
at org.esa.snap.core.dataio.ProductSubsetBuilder.readBandRasterDataRegion(ProductSubsetBuilder.java:328)
at org.esa.snap.core.dataio.ProductSubsetBuilder.readBandRasterDataImpl(ProductSubsetBuilder.java:297)
at org.esa.snap.core.dataio.AbstractProductReader.readBandRasterData(AbstractProductReader.java:250)
at org.esa.snap.core.gpf.common.SubsetOp.computeTile(SubsetOp.java:270)
at org.esa.snap.core.gpf.internal.OperatorImage.computeRect(OperatorImage.java:80)
at javax.media.jai.SourcelessOpImage.computeTile(SourcelessOpImage.java:137)
at com.sun.media.jai.util.SunTileScheduler.scheduleTile(SunTileScheduler.java:904)
at javax.media.jai.OpImage.getTile(OpImage.java:1129)
at javax.media.jai.PlanarImage.cobbleFloat(PlanarImage.java:3254)
at javax.media.jai.PlanarImage.getData(PlanarImage.java:2181)
at com.bc.ceres.glevel.MultiLevelImage.getData(MultiLevelImage.java:64)
at org.esa.snap.core.gpf.internal.OperatorContext.getSourceTile(OperatorContext.java:407)
at org.esa.snap.core.gpf.internal.OperatorContext.getSourceTile(OperatorContext.java:393)
at org.esa.snap.core.gpf.Operator.getSourceTile(Operator.java:461)
at org.esa.s1tbx.sar.gpf.geometric.RangeDopplerGeocodingOp.getPixelValue(RangeDopplerGeocodingOp.java:1229)
at org.esa.s1tbx.sar.gpf.geometric.RangeDopplerGeocodingOp.computeTileStack(RangeDopplerGeocodingOp.java:1039)
at org.esa.snap.core.gpf.internal.OperatorImageTileStack.computeRect(OperatorImageTileStack.java:116)
at org.esa.snap.core.gpf.internal.OperatorImageTileStack.computeTile(OperatorImageTileStack.java:85)
at com.sun.media.jai.util.SunTileScheduler.scheduleTile(SunTileScheduler.java:904)
at javax.media.jai.OpImage.getTile(OpImage.java:1129)
at javax.media.jai.PlanarImage.getData(PlanarImage.java:2085)
at com.bc.ceres.glevel.MultiLevelImage.getData(MultiLevelImage.java:64)
at org.esa.snap.core.gpf.internal.OperatorContext.getSourceTile(OperatorContext.java:407)
at org.esa.snap.core.gpf.internal.OperatorContext.getSourceTile(OperatorContext.java:393)
at org.esa.snap.core.gpf.Operator.getSourceTile(Operator.java:461)
at org.esa.snap.raster.gpf.LinearTodBOp.computeTile(LinearTodBOp.java:116)
at org.esa.snap.core.gpf.internal.OperatorImage.computeRect(OperatorImage.java:80)
at javax.media.jai.SourcelessOpImage.computeTile(SourcelessOpImage.java:137)
at com.sun.media.jai.util.SunTileScheduler.scheduleTile(SunTileScheduler.java:904)
at javax.media.jai.OpImage.getTile(OpImage.java:1129)
at javax.media.jai.PlanarImage.getData(PlanarImage.java:2085)
at com.bc.ceres.glevel.MultiLevelImage.getData(MultiLevelImage.java:64)
at org.esa.snap.core.gpf.internal.OperatorContext.getSourceTile(OperatorContext.java:407)
at org.esa.snap.core.gpf.internal.OperatorContext.getSourceTile(OperatorContext.java:393)
at org.esa.snap.core.gpf.internal.OperatorImage.computeRect(OperatorImage.java:73)
at javax.media.jai.SourcelessOpImage.computeTile(SourcelessOpImage.java:137)
at com.sun.media.jai.util.SunTileScheduler.scheduleTile(SunTileScheduler.java:904)
at javax.media.jai.OpImage.getTile(OpImage.java:1129)
at com.sun.media.jai.util.RequestJob.compute(SunTileScheduler.java:247)
at com.sun.media.jai.util.WorkerThread.run(SunTileScheduler.java:468)
Caused by: org.esa.snap.core.gpf.OperatorException: java.lang.NullPointerException
at org.esa.snap.engine_utilities.gpf.OperatorUtils.catchOperatorException(OperatorUtils.java:432)
at org.esa.s1tbx.sar.gpf.geometric.TerrainFlatteningOp.computeTileStack(TerrainFlatteningOp.java:497)
at org.esa.snap.core.gpf.internal.OperatorImageTileStack.computeRect(OperatorImageTileStack.java:116)
at org.esa.snap.core.gpf.internal.OperatorImageTileStack.computeTile(OperatorImageTileStack.java:85)
at com.sun.media.jai.util.SunTileScheduler.scheduleTile(SunTileScheduler.java:904)
… 45 more
Caused by: org.esa.snap.core.gpf.OperatorException: java.lang.NullPointerException
at org.esa.snap.engine_utilities.gpf.OperatorUtils.catchOperatorException(OperatorUtils.java:432)
at org.esa.s1tbx.sar.gpf.geometric.TerrainFlatteningOp.generateSimulatedImage(TerrainFlatteningOp.java:764)
at org.esa.s1tbx.sar.gpf.geometric.TerrainFlatteningOp.computeTileStack(TerrainFlatteningOp.java:483)
… 48 more
Caused by: java.lang.NullPointerException
at org.esa.s1tbx.sar.gpf.geometric.TerrainFlatteningOp.generateSimulatedImage(TerrainFlatteningOp.java:528)
… 49 more