snappy - ProductUtils.copyBand usage

Hi, I am trying to add a band to an existing product, but I keep getting this error:

RuntimeError: java.lang.IllegalArgumentException: raf == null!

I think I am probably using ProductUtils.copyBand() incorrectly.

I have an unwrapped interferogram derived from a TanDEM-X CoSSC pair (there is also the possibility this is an issue related to S1tbx interferometry). I wish to use the phaseToHeight operator, then add the resulting height band to the original product.

My code is like this:

from snappy import ProductIO, HashMap, GPF, ProductUtils
product = ProductIO.readProduct('interferogram.dim')
params = HashMap()
height = GPF.createProduct('phaseToHeight', params, product)
band = list(height.getBandNames())[0]  # Get name of the band I want to copy
ProductUtils.copyBand(band, height, product, False)
ProductIO.writeProduct(product, 'target', 'BEAM-DIMAP')

Specifying a string for the target band name has not changed the error.

Can anybody see what I am doing wrong?

Thanks for all advice!
Harry

Solved (I think)ā€¦

by changing the fourth argument copySourceImage - to True.

But if someone could still try to explain simply what this argument does Iā€™d appreciate that!

I just wanted to reply that you should change the parameter to True and then I read you second post.

This parameter indicates if also the source image (that data) shall be copied. If set to false only the metadata of the band, like name, description, wavelength, etc. is copied.
Then a new source for the data is required. This can be set manually. By default, it tries to read the data. But there is no file associated.
So setting to False is correct here.

1 Like