Raster Mosaic

Hi,

I tried to use SNAP GPT to make a large raster from a subset but was not able to. The following GDAL commands did work successfully:

gdal_merge.py *.tif -o ~/tmp/GIMP_DEM.tif
gdal_translate -of netCDF GIMP_DEM.tif GIMP_DEM.nc

I tried this in SNAP first with the Merge operator, using variations of:

gpt Merge -SmasterProduct=gimpdem0_0_v1.1.tif -SsourceProducts=gimpdem0_1_v1.1.tif -SsourceProducts=gimpdem0_2_v1.1.tif  -t test.nc

But get a variety of error messages. I’m not sure if I’m supposed to be using -Ssource or -SmasterProduct, or even if Merge is the right operator.

I’ve also tried with the Mosaic operator:

gpt -e Mosaic gimpdem0_0_v1.1.tif gimpdem0_1_v1.1.tif gimpdem0_2_v1.1.tif -t test.nc

results in:

INFO: org.esa.snap.python.gpf.PyOperatorSpi: Python operator 'py_ndvi_op' registered (Python module: 'ndvi_op', class: 'NdviOp', root: '/Users/kdm/.snap/system/modules/com-acme-snap-examples-snap-engine-python-operator.jar')
INFO: org.esa.snap.core.gpf.operators.tooladapter.ToolAdapterIO: Initializing external tool adapters
INFO: org.esa.s2tbx.dataio.gdal.activator.GDALDistributionInstaller: No distribution folder found on Macintosh.
INFO: org.hsqldb.persist.Logger: dataFileCache open start
org.esa.snap.core.gpf.OperatorException
	at org.esa.snap.core.gpf.common.MosaicOp.createTargetProduct(MosaicOp.java:418)
	at org.esa.snap.core.gpf.common.MosaicOp.initialize(MosaicOp.java:143)
	at org.esa.snap.core.gpf.internal.OperatorContext.initializeOperator(OperatorContext.java:486)
	at org.esa.snap.core.gpf.internal.OperatorContext.getTargetProduct(OperatorContext.java:273)
	at org.esa.snap.core.gpf.Operator.getTargetProduct(Operator.java:387)
	at org.esa.snap.core.gpf.main.CommandLineTool.runOperator(CommandLineTool.java:306)
	at org.esa.snap.core.gpf.main.CommandLineTool.runGraphOrOperator(CommandLineTool.java:284)
	at org.esa.snap.core.gpf.main.CommandLineTool.run(CommandLineTool.java:188)
	at org.esa.snap.core.gpf.main.CommandLineTool.run(CommandLineTool.java:121)
	at org.esa.snap.core.gpf.main.GPT.run(GPT.java:54)
	at org.esa.snap.core.gpf.main.GPT.main(GPT.java:34)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.esa.snap.runtime.Launcher.lambda$run$14(Launcher.java:55)
	at org.esa.snap.runtime.Engine.runClientCode(Engine.java:189)
	at org.esa.snap.runtime.Launcher.run(Launcher.java:51)
	at org.esa.snap.runtime.Launcher.main(Launcher.java:31)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.exe4j.runtime.LauncherEngine.launch(LauncherEngine.java:65)
	at com.install4j.runtime.launcher.UnixLauncher.main(UnixLauncher.java:57)
Caused by: java.lang.NullPointerException
	at org.esa.snap.core.gpf.common.MosaicOp.addTargetBands(MosaicOp.java:423)
	at org.esa.snap.core.gpf.common.MosaicOp.createTargetProduct(MosaicOp.java:414)
	... 24 more

Error: org.esa.snap.core.gpf.OperatorException

The exception is thrown because no variable is defined.
The mosaic operator is one of those operators which can not directly be invoked from the command line.
You need to create graph for it. The error message should be better with the next version.

The netcdf you have created with gdal with stereographic projection cannot be read because the SNAP support for projections witin netcdf files is very sparse.
It might be better if you stay in tif format.

1 Like

Now with the tif, there is, unfortunately, another issue.
The data is now loaded in SNAP and the projection is also read. At least it is shown on the world map. Probably a bit shifted when I comparing with the content in QGIS.

But now the tiff data can’t be loaded. I’ve noticed that this issue is already in our issue tracker.
https://senbox.atlassian.net/browse/SITBX-378

We need to update a library in order to get support for this 16bit compression.

I can use another data type int the TIFF - do you know what does work? 32 bit float? unsigned something-or-other? Let me know and I’ll regenerate the product.

32 bit float and LZW compression should actually work and also 16bit. What’s not working is the PREDICTOR_HORIZONTAL_DIFFERENCING. Honestly, at the moment I don’t know what this is. :flushed:
In this case only 8 bit seems to be supported.

OK. Not sure this will be useful if limited to 255 values. Please let me know when this bug is fixed and I’ll send the latest DEM at that point.

Thanks,

-k.

Hi Marco,

Is there a format I can write the DEM to that will work for SNAP?

Honestly, I’m not sure. Maybe ENVI hdr/img files will work.

Hi Marco,

I had created the TIF file with

gdal_merge.py *.tif -o ~/tmp/GIMP_DEM.tif -co COMPRESS=LZW -co BIGTIFF=YES -co TILED=YES -co PREDICTOR=2

Maybe the PREDICTOR option was causing a problem, based on your comment above. I’ve regenerated the TIF file without the PREDICTOR option. I’ve also created at ENVI version with:

gdal_merge.py *.tif -o ~/tmp/GIMP_DEM.bil -of ENVI

I’ll send a link to the files.