I am having trouble with creating the Subset Sentinel-2, but I assume the Topic is entirely the same so I would like to ask the question in here.
I have tried to run The snappy example from GitHub
But got this error:
python snappy_subset.py /workdir/S2A_MSIL2A_20200515T045701_N0214_R119_T44PLU_20200515T093525.zip "POLYGON((79.6500 12.3000,79.7500 12.3000,79.7500 12.2000,79.6500 12.2000,79.6500 12.3000))"
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 '.'.
INFO: org.esa.snap.core.util.EngineVersionCheckActivator: Please check regularly for new updates for the best SNAP experience.
Reading...
INFO: org.esa.s2tbx.dataio.s2.ortho.S2OrthoProductReaderPlugIn: Building product reader - EPSG:32644
WARNING: org.esa.s2tbx.dataio.metadata.GenericXmlMetadata: Metadata: the path to element [metadata_level] does not exist
WARNING: org.esa.s2tbx.dataio.metadata.GenericXmlMetadata: Metadata: the path to element [bandid] does not exist
WARNING: org.esa.s2tbx.dataio.metadata.GenericXmlMetadata: Metadata: the path to element [bandid] does not exist
WARNING: org.esa.s2tbx.dataio.metadata.GenericXmlMetadata: Metadata: the path to element [bandid] does not exist
WARNING: org.esa.s2tbx.dataio.metadata.GenericXmlMetadata: Metadata: the path to element [bandid] does not exist
WARNING: org.esa.s2tbx.dataio.metadata.GenericXmlMetadata: Metadata: the path to element [bandid] does not exist
INFO: org.hsqldb.persist.Logger: dataFileCache open start
WARNING: org.esa.s2tbx.dataio.s2.ortho.Sentinel2OrthoProductReader: Warning: missing file /workdir/S2A_MSIL2A_20200515T045701_N0214_R119_T44PLU_20200515T093525.zip/S2A_MSIL2A_20200515T045701_N0214_R119_T44PLU_20200515T093525.SAFE/GRANULE/L2A_T44PLU_A025570_20200515T051007/QI_DATA/L2A_T44PLU_20200515T045701_DDV_20m.jp2
WARNING: org.esa.s2tbx.dataio.s2.ortho.Sentinel2OrthoProductReader: Warning: no image files found for band quality_dense_dark_vegetation
Traceback (most recent call last):
File "snappy_subset.py", line 27, in <module>
sub_product = op.getTargetProduct()
RuntimeError: java.lang.NullPointerException
It is possible that this error is also related to s2tbx.GDALInstaller error as I have tried to use gpt tool with same Sentinel-2 product and WKT geoRegion and got this error instead:
gpt Subset -Ssource=/workdir/S2A_MSIL2A_20200515T045701_N0214_R119_T44PLU_20200515T093525.zip -PcopyMetadata=true -PgeoRegion="POLYGON((79.6500 12.3000,79.7500 12.3000,79.7500 12.2000,79.6500 12.2000,79.6500 12.3000))"
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 '.'.
INFO: org.esa.snap.core.util.EngineVersionCheckActivator: Please check regularly for new updates for the best SNAP experience.
INFO: org.esa.s2tbx.dataio.s2.ortho.S2OrthoProductReaderPlugIn: Building product reader - EPSG:32644
WARNING: org.esa.s2tbx.dataio.metadata.GenericXmlMetadata: Metadata: the path to element [metadata_level] does not exist
WARNING: org.esa.s2tbx.dataio.metadata.GenericXmlMetadata: Metadata: the path to element [bandid] does not exist
WARNING: org.esa.s2tbx.dataio.metadata.GenericXmlMetadata: Metadata: the path to element [bandid] does not exist
WARNING: org.esa.s2tbx.dataio.metadata.GenericXmlMetadata: Metadata: the path to element [bandid] does not exist
WARNING: org.esa.s2tbx.dataio.metadata.GenericXmlMetadata: Metadata: the path to element [bandid] does not exist
WARNING: org.esa.s2tbx.dataio.metadata.GenericXmlMetadata: Metadata: the path to element [bandid] does not exist
INFO: org.hsqldb.persist.Logger: dataFileCache open start
WARNING: org.esa.s2tbx.dataio.s2.ortho.Sentinel2OrthoProductReader: Warning: missing file /workdir/S2A_MSIL2A_20200515T045701_N0214_R119_T44PLU_20200515T093525.zip/S2A_MSIL2A_20200515T045701_N0214_R119_T44PLU_20200515T093525.SAFE/GRANULE/L2A_T44PLU_A025570_20200515T051007/QI_DATA/L2A_T44PLU_20200515T045701_DDV_20m.jp2
WARNING: org.esa.s2tbx.dataio.s2.ortho.Sentinel2OrthoProductReader: Warning: no image files found for band quality_dense_dark_vegetation
java.lang.NullPointerException
at org.esa.snap.core.gpf.common.SubsetOp.initialize(SubsetOp.java:210)
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$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:65)
at com.install4j.runtime.launcher.UnixLauncher.main(UnixLauncher.java:57)
Error: java.lang.NullPointerException
@marpet if you have a moment, would you be willing to look into it with me? I noticed that the last commit to snappy_subset.py example has failed jenkins tests.
This is where I got so far:
If I run the code line by line in Jupyter Lab, I can open the product and work with it. The code always hangs on the same line
sub_product = op.getTargetProduct()
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-19-03cefc25ad88> in <module>
----> 1 sub_product = op.getTargetProduct()
RuntimeError: java.lang.NullPointerException
Most strangely, if I resample the product first
product = ProductIO.readProduct(file)
parameters = HashMap()
parameters.put('targetResolution',10)
result = snappy.GPF.createProduct('Resample', parameters, product)
op = SubsetOp()
op.setSourceProduct(result )
op.setGeoRegion(geom)
op.setCopyMetadata(True)
sub_product = op.getTargetProduct()
Everything just works! Can anyone make sense of it? Thanks for any help.