Hi, I’m trying to use the SNAP API in one of my own Java programs, but when trying to open a product (Sentinel-1 SLC) using ProductIO, I end up with a Null pointer. I suspect that the reader for the file format cannot be found?
I have a succesful build of the SNAP engine and desktop, as well as the S1 Toolbox. The file opens just fine in the desktop build, but not using my own code. Do I have to do anything special to initialize a product reader mechanism? My code is as follows:
I want to use the snap java api in an external java program.
Is there any example how to use ?
My goal is to have an .nc file locally and with the help of my java program to extract the data form this file.
Is this possible?
Thank you for information. I manage to use snap in external Java program.
Do you know if there is any examples/ documentation in java to retrieve from a file based on latitude and longitude some sensor data (like NO2)?
File was downloaded from Esa https://s5phub.copernicus.eu/dhus/#/home
For doing this you have mainly two options.
You can invoke the PixEx operator. You can invoke it via API or by using the gpt command line or from the Desktop app.
For API usage you can have a look at the test snap-engine/PixExOpTest.java (github.com)
You can also use directly the Product API.
There is no specific example for your use case but there are two examples which show what needs to be done. In the repository snap-examples/snap-engine-examples (github.com) you find two classes.
One, the GeoCodingEx, shows how to retrieve for a geo-position the pixel position.
And in the NdviSimpleMain you can see how pixel values from a band can be read.
Beside readPixels methods there are also getPixel(s) methods. But to use those you need to load the raster data first. For example by using loadRasterData() first.