Snappy Python BandMaths, Linear to DB

Hello everyone,

I am working with Snappy Python. I am trying to preprocess a Sentinel 1 GRD, IW product. Following are the steps I am taking for Preprocessing:
a. Subset
b. Radiometric Calibration
c. Speckle Filtering
d. Terrain Correction
e. BandMaths RVI(Radar Vegetation Index) Calculations
f. LinearToFromdB.

Now finally when I try to read the pixels, from the final processed Image for histogram and other uses I get the following error:

band = linear_to_db.getBand(“Sigma0_VH_db”)
w = band.getRasterWidth()
h = band.getRasterHeight()

print(f"Width: {w}, Height: {h}")
band_data = np.zeros(w*h, np.float32)
band.readPixels(0, 0, w, h, band_data)

Error message:
RuntimeError: org.esa.snap.core.gpf.OperatorException: java.lang.NullPointerException

The same problem does not occur if I do not convert the LinearToFromdB. That is if I ignore the last step. Also if I do BandMaths (for RVI) calculation after LinearToFromdB I do not get this error.

Would appreciate any help. I did not get any error in the preprocessing steps.

  1. But as per my very little understanding of Sentinel 1, conversion to dB is a good idea but what about RVI?
  2. Should the BandMaths (for RVI) calculation be done before or after LinearToFromdB in Snappy?
  3. Is there something wrong with my process?

One issue of the Java-Python bridge is the incomplete error message propagation.
Depending only on
RuntimeError: org.esa.snap.core.gpf.OperatorException: java.lang.NullPointerException
it is hard to tell what the error is.

Some suggestions:

  • Save the final product to disk by using ProductIO.writeProduct(…) and work with the processed data.
  • You are loading the whole band. This might cause memory issues. Have you tried to load it in chunks? Maybe only 10 lines at once?