Hey there,
is there an operator for just changing the name of a Band. Is it possible to get a Band seperatly as variable in some kind of format?
Hey there,
is there an operator for just changing the name of a Band. Is it possible to get a Band seperatly as variable in some kind of format?
Are you working with SNAP Desktop? To change the name of a band you could simply right-click on it -> Properties and enter the desired band name in the properties table.
About getting a band separately, you could use subset or Band select for example.
I am using snappy.
Yes, of course, I hadn’t pay attention to the category of the post, sorry.
To change the name, you could use for example:
myProduct.getBand(‘currentName’).setName(‘newName’)
To get a band you can just use the previous function:
myProduct.getBand(‘currentName’)
or
myProduct.getBandAt(0)
You can also use the subset operator to tailor your data to a single band. The result can be written by ProductIO.writeProduct(…) or the WriteOp.
I wrote a function with which i take a band from a L1C product and subset it with ‘Landseamask’. For following working steps i need to set the name of that band with a function argument for example to default.
I tried the myProduct.getBand(‘currentName’).setName(‘newName’) command.
It kind of works but I get the error message: RuntimeError: java.lang.IllegalArgumentException: The Product ‘S2B_MSIL1C_20170929T102009_N0205_R065_T33UVU_20170929T102007’ already contains a raster data node with the name ‘savi1111before’.
I used it after i wrote a product.
band_1_subset_vector=GPF.createProduct(‘Land-Sea-Mask’,parameters,band_with_vector_1)
band_1_subset_vector.getBand(band_name).setName(new_band_name)
band_name and new_band name are arguments of the function. (select_band(input_product,band_name,new_band_name,outputfolder,outputname):
Is it possible that savi1111before already exists? Maybe not as a band, but maybe as a mask? Do you add a shapefile to the product with this name?
It finally worked fine in the end it was a tiny spelling mistake of a band name.
Thank you!