Hi all! Recently I started developing a plugin for SNAP in Python. SNAP offers many options for standard datasets. In some SNAP applications a DEM is required and can be selected from a predefined list (e.g. for the Range Doppler Terrain Correction plugin: Radar>Range Doppler Terrain Correction>Processing Parameters). This raised two questions regarding the implementation of my plugin:
1a) How do I create a drop-down menu in the -info.xml file?
1b) How do I obtain the actual DEM in the _op.py file as a source variable (e.g.
org.esa.snap.core.datamodel.Product[name=SRTM])? This SRTM DEM should be downloaded by SNAP internally after selection in the Processing Parameter menu.
is what you mean. Is this correct? That would mean I could get the values via context.getParameter(‘optionList’) in the initialize function within the Python class, but what about the value for each element, list data type etc. Could you give an example of how this looks in the info.xml file?
Regarding the java code and its classes. For acquiring a DEM I believe that I need use the following line of code (but then in Python):
ElevationModel dem = DEMFactory.createElevationModel(demName, demResamplingMethod);
Considering that line, the following remains unclear to me:
Can I use demName = “SRTM 3Sec”? will this automatically point to an internal handle for the SRTM download?
For the resampling method I require the ResamplingFactory class, how do I import this class in Python?
Can I import DEMFactory.createElevationModel via snappy? If so, could you give me an example line?
Do I need to replace the ElevationModel type, or can I leave it out in Python?
<description>Algorithm to be used</description>
This would result in a parameter where the user can select between split and mono, and split will be the default selection.
You can then get the value by
Regarding the elevation handling:
When you retrieve values from the dem you get via the DEMFactory the dem will be downloaded. But not the whole dataset only the tiles which are necessary.
Yes, ‘SRTM 3Sec’ should be usable. You can see what’s possible when you open the GUI for the ‘Raster\DEM Tools\Add Elevation Band’. The name is what is written before the braces.
To get the unknown classes you need to use jpy.get_type().
Most common classes are preloaded in __init__.py of snappy. There you can find examples of usages of this method.
In these two posts are also some examples: