Select all source bands - Snappy


#1

Hi.
I’m implementing a multilook with snappy.
In the parameters definition:

params = HashMap() params.put('nRgLooks', 4) params.put('nAzLooks', 1) params.put('outputIntensity', 'true') params.put('grSquarePixel', 'true')

I would like to select all the bands without naming them (Like in snap-desktop, if no bands are selected, then by default all bands are selected.).

How can I do it?

Thanks for your attention.


#2

Isn’t it working with just these parameters? By looking at the code I would think that all bands are used if the parameter sourceBands is not given.
What is the output you get?


#3

I’ve made a mistake.
I forgot to change outputIntensity to false.
Now I get the output with all bands.
Sorry, next time I’ll take more attettion before posting.


#4

Hi Marco,

Do you see what is wrong in my code by any chance? (the input image is a sentinel 2 SAFE file, the code is working when I select one band but not two or more)

HashMap = snappy.jpy.get_type('java.util.HashMap')
snappy.GPF.getDefaultInstance().getOperatorSpiRegistry().loadOperatorSpis() 
parameters = HashMap()
parameters.put('sourceBands', 'sun_azimuth','sun_zenith') 
geometry_bands = GPF.createProduct('BandSelect', parameters, source_image)   

the error message is
File “D:\projects\code_repository\SAFIY2\trunk\Snap_band_selections.py”, line 45, in band_selection
parameters.put(‘sourceBands’, ‘sun_azimuth’,‘sun_zenith’)
RuntimeError: no matching Java method overloads found

Thank you

Chloe


#5

It must be the parameter name and a single parameter value. Instead of providing two names create one string with both names separated by comma.

parameters.put(‘sourceBands’, ‘sun_azimuth,sun_zenith’)


#6

It works, thanks a lot! :slight_smile:

Chloe