OS:
Ubuntu 18.04
Environment Used:
Anaconda environment
Library versions:
pyroSAR: version 0.11.1 from conda-forge
SNAP: 8.0
Objective:
I wanted to reproject (to South LAEA) and apply speckle filtering to a couple of Sentinel SAR images that I have acquired. However I am unable to do so.
Code:
from pathlib import Path
from pyroSAR.snap import geocode
outdir = './outdir'
# South Lambert Equal Area Projection (ESRI:102020)
out_proj = "+proj=laea +lat_0=-90 +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs"
sar_zips = [ str(Path.cwd() / i) for i in Path('./data').iterdir() if i.suffix == ".zip"]
geocode(infile=sar_zips[0], outdir=outdir, t_srs=out_proj, speckleFilter="Lee")
This snippet outputs
searching for new POE files
https://qc.sentinel1.eo.esa.int/api/v1/?product_type=AUX_POEORB&sentinel1__mission=S1B&validity_start__gte=2019-08-19T07:52:49&validity_stop__lte=2019-08-21T07:52:49
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-15-10d2a2932d21> in <module>
----> 1 geocode(infile=sar_zips, outdir=outdir, t_srs=out_proj, speckleFilter="Lee")
~/anaconda3/envs/sar/lib/python3.6/site-packages/pyroSAR/snap/util.py in geocode(infile, outdir, t_srs, tr, polarizations, shapefile, scaling, geocoding_type, removeS1BorderNoise, removeS1BorderNoiseMethod, removeS1ThermalNoise, offset, allow_RES_OSV, demName, externalDEMFile, externalDEMNoDataValue, externalDEMApplyEGM, terrainFlattening, basename_extensions, test, export_extra, groupsize, cleanup, gpt_exceptions, gpt_args, returnWF, nodataValueAtSea, demResamplingMethod, imgResamplingMethod, speckleFilter, refarea)
384
385 try:
--> 386 t_srs = crsConvert(t_srs, 'epsg')
387 except TypeError:
388 raise RuntimeError("format of parameter 't_srs' not recognized")
~/anaconda3/envs/sar/lib/python3.6/site-packages/spatialist/auxil.py in crsConvert(crsIn, crsOut)
77 return srs.ExportToProj4()
78 elif crsOut == 'epsg':
---> 79 srs.AutoIdentifyEPSG()
80 return int(srs.GetAuthorityCode(None))
81 elif crsOut == 'opengis':
~/anaconda3/envs/sar/lib/python3.6/site-packages/osgeo/osr.py in AutoIdentifyEPSG(self, *args)
564 def AutoIdentifyEPSG(self, *args):
565 """AutoIdentifyEPSG(SpatialReference self) -> OGRErr"""
--> 566 return _osr.SpatialReference_AutoIdentifyEPSG(self, *args)
567
568
RuntimeError: OGR Error: Unsupported SRS
Edit: I tried using osr and importing the wkt representation of South LAEA
wkt = """PROJCS["South_Pole_Lambert_Azimuthal_Equal_Area",GEOGCS["GCS_WGS_1984",DATUM["WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Lambert_Azimuthal_Equal_Area"],PARAMETER["False_Easting",0],PARAMETER["False_Northing",0],PARAMETER["Central_Meridian",0],PARAMETER["Latitude_Of_Origin",-90],UNIT["Meter",1],AUTHORITY["EPSG","102020"]]"""
out_proj2 = osr.SpatialReference(wkt)
geocode(
infile=sar_zips[0],
outdir=outdir,
t_srs=out_proj2,
scaling="linear",
speckleFilter="Refined Lee",
)
This worked till the Terrain Correction part, but failed for a similar reason.
searching for new POE files
https://qc.sentinel1.eo.esa.int/api/v1/?product_type=AUX_POEORB&sentinel1__mission=S1A&validity_start__gte=2020-03-16T22:55:06&validity_stop__lte=2020-03-18T22:55:06
unpacking scene
removing border noise..
border noise removal not necessary for IPF version 3.2
executing node sequences..
ThermalNoiseRemoval
Apply-Orbit-File
Calibration
Terrain-Flattening
Speckle-Filter
Terrain-Correction
Executing processing graph
No code "EPSG:102020" from authority "European Petroleum Survey Group" found for object of type "CoordinateReferenceSystem".
done.
INFO: org.esa.snap.core.gpf.operators.tooladapter.ToolAdapterIO: Initializing external tool adapters
INFO: org.esa.s2tbx.dataio.gdal.GDALVersion: Incompatible GDAL 3.1.4 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: Terrain-Correction] No code "EPSG:102020" from authority "European Petroleum Survey Group" found for object of type "CoordinateReferenceSystem".
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.<init>(GraphContext.java:85)
at org.esa.snap.core.gpf.graph.GraphContext.<init>(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.Launcher1159904018.main(Unknown Source)
Caused by: org.esa.snap.core.gpf.OperatorException: No code "EPSG:102020" from authority "European Petroleum Survey Group" found for object of type "CoordinateReferenceSystem".
at org.esa.snap.engine_utilities.gpf.OperatorUtils.catchOperatorException(OperatorUtils.java:440)
at org.esa.s1tbx.sar.gpf.geometric.RangeDopplerGeocodingOp.initialize(RangeDopplerGeocodingOp.java:349)
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: org.esa.snap.core.gpf.OperatorException: No code "EPSG:102020" from authority "European Petroleum Survey Group" found for object of type "CoordinateReferenceSystem".
at org.esa.s1tbx.sar.gpf.geometric.RangeDopplerGeocodingOp.createTargetProduct(RangeDopplerGeocodingOp.java:564)
at org.esa.s1tbx.sar.gpf.geometric.RangeDopplerGeocodingOp.initialize(RangeDopplerGeocodingOp.java:306)
... 33 more
Caused by: org.opengis.referencing.NoSuchAuthorityCodeException: No code "EPSG:102020" from authority "European Petroleum Survey Group" found for object of type "CoordinateReferenceSystem".
at org.geotools.referencing.factory.AbstractAuthorityFactory.noSuchAuthorityCode(AbstractAuthorityFactory.java:875)
at org.geotools.referencing.factory.epsg.DirectEpsgFactory.createCoordinateReferenceSystem(DirectEpsgFactory.java:2239)
at org.geotools.referencing.factory.BufferedAuthorityFactory.createCoordinateReferenceSystem(BufferedAuthorityFactory.java:732)
at org.geotools.referencing.factory.AuthorityFactoryAdapter.createCoordinateReferenceSystem(AuthorityFactoryAdapter.java:780)
at org.geotools.referencing.factory.BufferedAuthorityFactory.createCoordinateReferenceSystem(BufferedAuthorityFactory.java:732)
at org.geotools.referencing.factory.AuthorityFactoryAdapter.createCoordinateReferenceSystem(AuthorityFactoryAdapter.java:780)
at org.geotools.referencing.factory.FallbackAuthorityFactory.createCoordinateReferenceSystem(FallbackAuthorityFactory.java:625)
at org.geotools.referencing.factory.AuthorityFactoryAdapter.createCoordinateReferenceSystem(AuthorityFactoryAdapter.java:780)
at org.geotools.referencing.factory.ThreadedAuthorityFactory.createCoordinateReferenceSystem(ThreadedAuthorityFactory.java:636)
at org.geotools.referencing.DefaultAuthorityFactory.createCoordinateReferenceSystem(DefaultAuthorityFactory.java:177)
at org.geotools.referencing.CRS.decode(CRS.java:517)
at org.esa.s1tbx.commons.CRSGeoCodingHandler.getCRS(CRSGeoCodingHandler.java:173)
at org.esa.s1tbx.commons.CRSGeoCodingHandler.<init>(CRSGeoCodingHandler.java:55)
at org.esa.s1tbx.sar.gpf.geometric.RangeDopplerGeocodingOp.createTargetProduct(RangeDopplerGeocodingOp.java:530)
... 34 more
Error: [NodeId: Terrain-Correction] No code "EPSG:102020" from authority "European Petroleum Survey Group" found for object of type "CoordinateReferenceSystem".
[S1A_EW_GRDH_1SSH_20200317T225506_20200317T225606_031721_03A873_CB43_tmp5.xml] failed with return code 1
failed: ./outdir/S1A__EW___A_20200317T225506_HH_NR_Orb_TF_Spk_TC/S1A__EW___A_20200317T225506_HH_NR_Orb_TF_Spk_TC_proc.xml
How can I correctly reproject my SAR files to South LAEA using pyroSAR?
bug