I am currently implementing a processor for SNAP in Python.
At the beginning of my computations I cut the source product (as not all data is relevant) and I also want to add a new band with additional data.
The additional data is loaded as tiff and converted to a numpy array. It has the same dimensions as the sub_product
Here the relevant code:
# get subset: SubsetOp = snappy.jpy.get_type('org.esa.snap.core.gpf.common.SubsetOp') op = SubsetOp() op.setSourceProduct(source_product) op.setRegion(snappy.Rectangle(range, range, range - range, range - range)) sub_product = op.getTargetProduct() writer = snappy.ProductIO.getProductWriter('BEAM-DIMAP') sub_product.setProductWriter(writer) # add band: self.ref_band_org = sub_product.addBand('ref_image', snappy.ProductData.TYPE_UINT8) self.ref_band_org.writePixels(0, 0, width, height, ref_image)
(ref_image is a numpy array of size width x height)
This is working correctly if I run this as a python script.
But when building and importing in SNAP (as processor) I get the following error:
java.lang.RuntimeException: Error in Python interpreter:
Type: <class ‘RuntimeError’>
Value: java.io.FileNotFoundException: ref_image.hdr (Access is denied)
Is there another (better) way to add a band to a product?
Is there perhaps already a problem when creating the sub-product?
Thanks for any help!