ExportProductAction

Hello, Would somebody like to share an example fo the use of ExportProductAction in code for python, I need this option for my code, I will appreciate your help.

Why do you want to us the Action? It is located in a GUI module and this is not put on the class path for snappy. So you can’t use it.
But if you want to store a product you should just use ProductIO.writeProduct(…)
And if you want to ask the user for the location you better use Python libraries.

Would you like to share a use of Write the product with LinearTodB (Sigma_db)band?

Writing a product does not depend on its content. It is always the same.
Line 30 gives you an example:

if (ifInDb):
parameters.put(‘outputImageScaleInDb’, ifInDb)

     SubsetOp = snappy.jpy.get_type('org.esa.snap.core.gpf.common.SubsetOp')
     product = GPF.createProduct('Terrain-Correction', parameters, source)         
     '''
     bandNames=[]
     bandNames= product.getBandNames()                   
     bandNames[0]= bandNames[0]+'_db'  
     bandNames[1]= bandNames[1]+'_db'  
     bandNames[2]= bandNames[2]+'_db'   
     bandNames[3]= bandNames[3]+'_db' 
     '''
     op = SubsetOp()             
     op.setSourceProduct(product)
     sub_product = op.getTargetProduct()               
     mym= createProgressMonitor()
     ProductIO.writeProduct(sub_product, opath+sub_product.getName()+"snappy_line2db_output.dim", "BEAM-DIMAP",mym)
output = GPF.createProduct('Terrain-Correction', parameters, source)


ProductIO.writeProduct(out, opath+out.getName()+“output.dim”, “BEAM-DIMAP”,mym)

Thanks ,I have work it out !
But I cannot rename the bands. SO, if I create a stack, the band name is a problem!
Besides, 2 writeProduct can be time-consuming!
The best way is create a *_dB band in one product.That is the key question?
Could you help me with it ?

Renaming a band is actually simple.

band = product.getBand(“BandName”)
band.setName(“newBandName”)

adding a band is also simple, e.g.

band = product.addBand(“name”, ProductData.TYPE_FLOAT)

Thank you very much! However ,I have follow it . Add Band method works well!
but rename method did not!
band = product.getBand(“BandName”)
band.setName(“newBandName”)

product = GPF.createProduct(‘Terrain-Correction’, parameters, source)
band = product.getBand(“Sigma0_VH”)
band.setName(“Sigma0_VH_db”)
ProductIO.writeProduct(…)

ProductIO.writeProduct
RuntimeError: org.esa.snap.core.gpf.OperatorException: java.lang.NullPointerException

I am sure that the product’s band is not empty–Sigma0_VH_db!

Without renaming the band it works?