johntruckenbrodt / pyroSAR

framework for large-scale SAR satellite data processing
MIT License
499 stars 111 forks source link

geocode function fails due to GDAL version error #125

Closed dilipsai1 closed 3 years ago

dilipsai1 commented 3 years ago

Hi Team,

I am getting an error while executing the below step: Code: from pyroSAR.snap import geocode

the target pixel resolution in meters resolution = 20

for scene in selection_proc: geocode(infile=scene, outdir=outdir, tr=resolution, scaling='db', shapefile=site)

Error:

executing node sequences.. Subset ThermalNoiseRemoval Executing processing graph java.lang.NullPointerException done. INFO: org.esa.snap.core.gpf.operators.tooladapter.ToolAdapterIO: Initializing external tool adapters INFO: org.esa.s2tbx.dataio.gdal.GDALVersion: Incompatible GDAL 3.2.1 found on system. Internal GDAL 3.0.0 from distribution will be used. INFO: org.esa.s2tbx.dataio.gdal.GDALVersion: Internal GDAL 3.0.0 set to be used by SNAP. INFO: org.esa.snap.core.util.EngineVersionCheckActivator: Please check regularly for new updates for the best SNAP experience. INFO: org.esa.s2tbx.dataio.gdal.GDALVersion: Internal GDAL 3.0.0 set to be used by SNAP. INFO: org.hsqldb.persist.Logger: dataFileCache open start org.esa.snap.core.gpf.graph.GraphException: [NodeId: ThermalNoiseRemoval] java.lang.NullPointerException at org.esa.snap.core.gpf.graph.NodeContext.initTargetProduct(NodeContext.java:79) at org.esa.snap.core.gpf.graph.GraphContext.initNodeContext(GraphContext.java:199) at org.esa.snap.core.gpf.graph.GraphContext.initNodeContext(GraphContext.java:182) at org.esa.snap.core.gpf.graph.GraphContext.initOutput(GraphContext.java:166) at org.esa.snap.core.gpf.graph.GraphContext.(GraphContext.java:85) at org.esa.snap.core.gpf.graph.GraphContext.(GraphContext.java:58) at org.esa.snap.core.gpf.graph.GraphProcessor.executeGraph(GraphProcessor.java:118) at org.esa.snap.core.gpf.main.DefaultCommandLineContext.executeGraph(DefaultCommandLineContext.java:86) at org.esa.snap.core.gpf.main.CommandLineTool.executeGraph(CommandLineTool.java:547) at org.esa.snap.core.gpf.main.CommandLineTool.runGraph(CommandLineTool.java:391) at org.esa.snap.core.gpf.main.CommandLineTool.runGraphOrOperator(CommandLineTool.java:287) 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$0(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:84) at com.install4j.runtime.launcher.UnixLauncher.start(UnixLauncher.java:66) at install4j.org.esa.snap.runtime.Launcher_gpt.main(Unknown Source) Caused by: org.esa.snap.core.gpf.OperatorException: java.lang.NullPointerException at org.esa.snap.engine_utilities.gpf.OperatorUtils.catchOperatorException(OperatorUtils.java:440) at org.esa.s1tbx.calibration.gpf.Sentinel1RemoveThermalNoiseOp.initialize(Sentinel1RemoveThermalNoiseOp.java:165) at org.esa.snap.core.gpf.internal.OperatorContext.initializeOperator(OperatorContext.java:528) at org.esa.snap.core.gpf.internal.OperatorContext.getTargetProduct(OperatorContext.java:298) at org.esa.snap.core.gpf.Operator.getTargetProduct(Operator.java:385) at org.esa.snap.core.gpf.graph.NodeContext.initTargetProduct(NodeContext.java:77) ... 29 more Caused by: java.lang.NullPointerException at org.esa.s1tbx.calibration.gpf.Sentinel1RemoveThermalNoiseOp.getProductType(Sentinel1RemoveThermalNoiseOp.java:179) at org.esa.s1tbx.calibration.gpf.Sentinel1RemoveThermalNoiseOp.initialize(Sentinel1RemoveThermalNoiseOp.java:140) ... 33 more

Error: [NodeId: ThermalNoiseRemoval] java.lang.NullPointerException

I have tried uninstalling GDAL verison but unable to install GDAL 2.1 which is required in my conda envrionment. By default when I am installing pyrosar, GDAL 3.2.1 is getting installed.

gdal 3.2.1 py39h409cc32_0 conda-forge python 3.9.1 hffdb5ce_2_cpython conda-forge snap 8.0.0 py39_2 terradue

johntruckenbrodt commented 3 years ago

Hi @dilipsai1. Thanks for reporting this! I am getting the same error. This has also been reported in the STEP forum here. I expect this to be fixed soon in SNAP so there is no point in limiting the GDAL version in the pyroSAR code.
I suggest you try to reinstall SNAP or create a new environment where you first install GDAL in a lower version (but at least 2.4) and then pyroSAR (which will then make use of the previously installed GDAL).

johntruckenbrodt commented 3 years ago

Oh, and I see that you are installing SNAP as conda package over the terradue channel. Good to know they are now offering version 8. I have worked with this before but am not sure whether it is easy to update. If not you might have to wait a few days for the new conda package version after the SNAP update has been released.

maawoo commented 3 years ago

Hi John! You probably already have it your radar but this seems to be related to #113 with a possible fix by #123. I'm getting the same problem as mentioned by @dilipsai1 but the processing works fine when no shapefile is specified (looks like a shapefile is also specified above: shapefile=site). So doesn't seem to be a GDAL problem, but a problem related to metadata not being copied over by the Subset-Node, which then causes problems with the Calibration-Node. Here is also an old topic from the STEP forum about this.

johntruckenbrodt commented 3 years ago

Hi @maawoo. You are right. I just tried different GDAL versions with the fix offered in #123 and this indeed fixes the problem. I'll merge the PR in a minute.