def _band_math(self, product, name, expression): GPF.getDefaultInstance().getOperatorSpiRegistry().loadOperatorSpis() HashMap = jpy.get_type('java.util.HashMap') BandDescriptor = jpy.get_type( 'org.esa.snap.core.gpf.common.BandMathsOp$BandDescriptor') targetBand = BandDescriptor() targetBand.name = name targetBand.type = 'float32' targetBand.expression = expression bands = jpy.array( 'org.esa.snap.core.gpf.common.BandMathsOp$BandDescriptor', 1) bands[0] = targetBand parameters = HashMap() parameters.put('targetBands', bands) productMap = HashMap() if isinstance(product, list): for ind in range(len(product)): print('p{}'.format(ind + 1)) productMap.put('p{}'.format(ind + 1), product[ind]) result = GPF.createProduct('BandMaths', parameters, productMap) else: result = GPF.createProduct('BandMaths', parameters, product) return result
def classify(prepros_folder): for file in os.listdir(prepros_folder): ### Folder, date & timestamp classification = rootpath + "\\classification" scene_name = str(prepros_folder.split("\\")[X])[:32] # [X] element of filepath, change this to match scene name. [:32] first caracters of element print("scene_name:", scene_name) output_folder = os.path.join(classification, scene_name) print("output_folder:", output_folder) polarization = str(file)[46:48] # polarization from filename if not os.path.exists(output_folder): os.mkdir(output_folder) GPF.getDefaultInstance().getOperatorSpiRegistry().loadOperatorSpis() HashMap = snappy.jpy.get_type('java.util.HashMap') gc.enable() sentinel_1 = ProductIO.readProduct(os.path.join(prepros_folder, file)) res = [20, 50] # parameters for CFAR for r in res: resolution = r gd_window = resolution * 12.0 bg_window = resolution * 37.0 # AdaptiveThresholding (Constant False Alarm Rate CFAR) parameters = HashMap() parameters.put('targetWindowSizeInMeter', resolution) parameters.put('guardWindowSizeInMeter', gd_window) parameters.put('backgroundWindowSizeInMeter', bg_window) parameters.put('pfa', 6.0) target_1 = GPF.createProduct("AdaptiveThresholding", parameters, sentinel_1) parameters = None # Subset (extracting classification band) parameters = HashMap() parameters.put('bandNames', 'Sigma0_' + polarization + '_ship_bit_msk') outfile = output_folder + "\\" + scene_name + "_" + polarization + "_cfar_" + str(resolution) + "m" target_2 = GPF.createProduct("Subset", parameters, target_1) ProductIO.writeProduct(target_2, outfile, 'GeoTIFF-BigTIFF', pm) # Classification to vector ds = gdal.Open(str(outfile + ".tif")) rasterband = ds.GetRasterBand(1) dst_layername = outfile + "_Iceberg_outline" drv = ogr.GetDriverByName("GeoJSON") dst_ds = drv.CreateDataSource(dst_layername + ".geojson") dest_srs = ogr.osr.SpatialReference() dest_srs.ImportFromEPSG(4326) dst_layer = dst_ds.CreateLayer(dst_layername, dest_srs) gdal.Polygonize(rasterband, rasterband, dst_layer, -1, [], callback=None) # (input, mask, dest_layer,,,)
def preprocesado(): ##Aplicar correccion orbital global product global product_calibrated global HashMap print(product) parameters = HashMap() GPF.getDefaultInstance().getOperatorSpiRegistry().loadOperatorSpis() parameters.put('orbitType', 'Sentinel Precise (Auto Download)') parameters.put('polyDegree', '3') parameters.put('continueOnFail', 'false') apply_orbit_file = GPF.createProduct('Apply-Orbit-File', parameters, product) ##Recortar la imagen r = shapefile.Reader(archivo_shape) g = [] for s in r.shapes(): g.append(pygeoif.geometry.as_shape(s)) m = pygeoif.MultiPoint(g) wkt = str(m.wkt).replace("MULTIPOINT", "POLYGON(") + ")" #Usar el shapefile para cortar la imagen SubsetOp = snappy.jpy.get_type('org.esa.snap.core.gpf.common.SubsetOp') bounding_wkt = wkt geometry = WKTReader().read(bounding_wkt) HashMap = snappy.jpy.get_type('java.util.HashMap') GPF.getDefaultInstance().getOperatorSpiRegistry().loadOperatorSpis() parameters = HashMap() parameters.put('copyMetadata', True) parameters.put('geoRegion', geometry) product_subset = snappy.GPF.createProduct('Subset', parameters, apply_orbit_file) #Mostrar las dimensiones de la imagen width = product_subset.getSceneRasterWidth() print("Width: {} px".format(width)) height = product_subset.getSceneRasterHeight() print("Height: {} px".format(height)) band_names = product_subset.getBandNames() print("Band names: {}".format(", ".join(band_names))) band = product_subset.getBand(band_names[0]) print(band.getRasterSize()) #plotBand(product_subset, "Intensity_VV", 0, 100000) ##Aplicar la calibracion de la imagen parameters = HashMap() parameters.put('outputSigmaBand', True) parameters.put('sourceBands', 'Intensity_VV') parameters.put('selectedPolarisations', "VV") parameters.put('outputImageScaleInDb', False) product_calibrated = GPF.createProduct("Calibration", parameters, product_subset) #plotBand(product_calibrated, "Sigma0_VV", 0, 1) print("PREPROCESAMIENTO HECHO EXITOSAMENTE")
def process_date(prod_list, out_dir, orbit, area_of_int, ref_raster, polarizations): """products is a list of products of the same orbit (ASCENDING/DESCENDING) and date (STATE_VECTOR_TIME[0:11]). Returns product subset for a given polarizaton""" if len(prod_list) > 1: # 0 Slice assembly param_sliceass = hashp() param_sliceass.put('selectedPolarisations', 'VH,VV') product = GPF.createProduct("SliceAssembly", param_sliceass, prod_list) else: product = prod_list[0] # 1 Apply orbit file param = hashp() product = GPF.createProduct("Apply-Orbit-File", param, product) # 2 Radiometric calibration param = hashp() param.put('outputSigmaBand', True) param.put('sourceBands', getBandNames(product, 'Intensity_')) param.put('selectedPolarisations', 'VH,VV') param.put('outputImageScaleInDb', False) product = GPF.createProduct("Calibration", param, product) # 3 Terrain correction param = hashp() param.put('demResamplingMethod', 'NEAREST_NEIGHBOUR') param.put('imgResamplingMethod', 'NEAREST_NEIGHBOUR') param.put('applyRadiometricNormalization', True) param.put('demName', 'SRTM 3Sec') param.put('pixelSpacingInMeter', 10.0) param.put('sourceBands', getBandNames(product, 'Sigma0_')) param.put('mapProjection', 'WGS84(DD)') product = GPF.createProduct("Terrain-Correction", param, product) # 4 Subset if area_of_int is not None: param = hashp() param.put('geoRegion', area_of_int) param.put('outputImageScaleInDb', False) param.put('sourceBandNames', getBandNames(product, 'Sigma0_')) product = GPF.createProduct("Subset", param, product) out_name = out_dir + 'S1_' + orbit + '_' + product.getName()[24:32] + '_' write_product(product, out_name, ConcisePM(System.out))
def subset(product, borderRectInGeoCoor): from snappy import jpy from snappy import ProductIO from snappy import GPF from snappy import HashMap xmin = borderRectInGeoCoor[0] ymin = borderRectInGeoCoor[1] xmax = borderRectInGeoCoor[2] ymax = borderRectInGeoCoor[3] p1 = '%s %s' % (xmin, ymin) p2 = '%s %s' % (xmin, ymax) p3 = '%s %s' % (xmax, ymax) p4 = '%s %s' % (xmax, ymin) wkt = "POLYGON((%s, %s, %s, %s, %s))" % (p1, p2, p3, p4, p1) WKTReader = jpy.get_type('com.vividsolutions.jts.io.WKTReader') geom = WKTReader().read(wkt) HashMap = jpy.get_type('java.util.HashMap') GPF.getDefaultInstance().getOperatorSpiRegistry().loadOperatorSpis() parameters = HashMap() parameters.put('copyMetadata', True) parameters.put('geoRegion', geom) parameters.put('outputImageScaleInDb', False) subset = GPF.createProduct('Subset', parameters, product) return subset
def do_mosaic(source): parameters = HashMap() parameters.put('pixelSize', 200.0) parameters.put('resamplingMethod', 'BILINEAR_INTERPOLATION') parameters.put('mapProjection', "AUTO:42001") parameters.put('variables', 'Sigma0_HH') output = GPF.createProduct('SAR-Mosaic', parameters, source)
def topsarSplit(product): if debug >= 2: print(cyan + "applyingOrbitFile() : " + bold + green + "Run to SNAP... " + endC ) # Instance de GPF GPF.getDefaultInstance().getOperatorSpiRegistry().loadOperatorSpis() # Def operateur SNAP operator = 'TOPSAR-Split' # Set des parametres parameters = HashMap() op_spi = GPF.getDefaultInstance().getOperatorSpiRegistry().getOperatorSpi(operator) op_params = op_spi.getOperatorDescriptor().getParameterDescriptors() for param in op_params: if debug >= 2: print(cyan + "topsarSplit() : " + bold + green + str(param.getName()) + " : " + str(param.getDefaultValue()) + endC) parameters.put(param.getName(), param.getDefaultValue()) parameters.put('subswath', 'IW1') parameters.put('selectedPolarisations', 'VV') if debug >= 2: print(parameters) # Get snappy Operators result = GPF.createProduct(operator, parameters, product) if debug >= 2: print(cyan + "topsarSplit() : " + bold + green + "Done... " + endC) return result
def band_maths(self, expression): """ Perform a SNAP GPF BandMath operation on the product, excluding non-vegetation and non-soil pixels. Args: expression: The band maths expression to execute """ print("\tBandMaths, product={}".format(self.product.getName())) BandDescriptor = jpy.get_type( 'org.esa.snap.core.gpf.common.BandMathsOp$BandDescriptor') band = BandDescriptor() band.name = 'band_maths' band.type = 'float32' band.expression = expression band.noDataValue = np.nan bands = jpy.array( 'org.esa.snap.core.gpf.common.BandMathsOp$BandDescriptor', 1) bands[0] = band HashMap = jpy.get_type('java.util.HashMap') parameters = HashMap() parameters.put('targetBands', bands) self.product = GPF.createProduct('BandMaths', parameters, self.product) return self.product
def calibration(product): parameters = HashMap() parameters.put('outputSigmaBand', True) parameters.put('sourcebands', 'Intensity_VV') parameters.put('selectedPolarisations', "VV") parameters.put('outputImageScaleInDb', False) return GPF.createProduct("Calibration", parameters, product)
def terrainCorrection(product): parameters = HashMap() parameters.put('demName', 'SRTM 3Sec') parameters.put('pixelSpacingInMeter', 10.0) parameters.put('sourceBands', 'Sigma0_VV') return GPF.createProduct("Terrain-Correction", parameters, product)
def apply_orbit_file(self, write_intermediate=False): parameters = self.HashMap() dataproduct = GPF.createProduct("Apply-Orbit-File", parameters, self.dataproduct_r) self.operations_list.append('ApplyOrbit') SF_filepath = "" # Get a progressMonitor object monitor = self.createProgressMonitor() if write_intermediate: # Write data product with BEAM-DIM format to given file path # ProductIO.writeProduct(Product product, String filePath, String formatName) SF_filepath = Path(self.working_dir, self.name_with_safe + "_ORB") print('Writing out Orbit File corrected product') ProductIO.writeProduct(dataproduct, str(SF_filepath), 'BEAM-DIMAP', monitor) # Set start time and loop counter finish_time = datetime.datetime.now() # for calculation elapsed_time = finish_time - self.start_time print(elapsed_time.strftime("%H:%M:%S")) if os.path.exists(SF_filepath + ".dim"): print("Completed applying orbit file:", SF_filepath) else: print("Completed applying orbit file: data product saved to in-memory") self.intermediate_product = dataproduct
def terrain_flattening(terflt): parameters = HashMap() parameters.put('demName', 'SRTM 1Sec HGT') parameters.put('demResamplingMethod', 'BICUBIC_INTERPOLATION') parameters.put('reGridMethod', True) parameters.put('sourceBands', 'Beta0_' + polarization) return GPF.createProduct('Terrain-Flattening', parameters, terflt)
def goldstein_phasefiltering(product): parameters.put("Adaptive Filter Exponent in(0,1]:", 1.0) parameters.put("FFT Size", 64) parameters.put("Window Size", 3) parameters.put("Use coherence mask", False) parameters.put("Coherence Threshold in[0,1]:", 0.2) return GPF.createProduct("GoldsteinPhaseFiltering", parameters, product)
def terrain_correction(src, projection): parameters = HashMap() parameters.put("demName", "SRTM 1Sec HGT") # ~25 to 30m parameters.put("externalDEMNoDataValue", 0.0) parameters.put("externalDEMApplyEGM", True) parameters.put("demResamplingMethod", "BICUBIC_INTERPOLATION") parameters.put("imgResamplingMethod", "BICUBIC_INTERPOLATION") parameters.put("pixelSpacingInMeter", 10.0) parameters.put("pixelSpacingInDegree", 8.983152841195215E-5) parameters.put("mapProjection", projection) parameters.put("alignToStandardGrid", False) parameters.put("standardGridOriginX", 0.0) parameters.put("standardGridOriginY", 0.0) parameters.put("nodataValueAtSea", True) parameters.put("saveDEM", False) parameters.put("saveLatLon", False) parameters.put("saveIncidenceAngleFromEllipsoid", False) parameters.put("saveLocalIncidenceAngle", False) parameters.put("saveSelectedSourceBand", True) parameters.put("outputComplex", False) parameters.put("applyRadiometricNormalization", False) parameters.put("saveSigmaNought", False) parameters.put("saveGammaNought", False) parameters.put("saveBetaNought", False) parameters.put("incidenceAngleForSigma0", "Use projected local incidence angle from DEM") parameters.put("incidenceAngleForGamma0", "Use projected local incidence angle from DEM") parameters.put("auxFile", "Latest Auxiliary File") return GPF.createProduct("Terrain-Correction", parameters, src)
def topophase_removal(product): parameters.put("Orbit Interpolation Degree", 3) parameters.put("Digital Elevation Model", "SRTM 1Sec HGT (Auto Download)") parameters.put("Tile Extension[%]", 100) parameters.put("Output topographic phase band", True) parameters.put("Output elevation band", False) return GPF.createProduct("TopoPhaseRemoval", parameters, product)
def do_subset_band(source, wkt): print('\tSubsetting...') parameters = HashMap() parameters.put('geoRegion', wkt) #parameters.put('outputImageScaleInDb', True) output = GPF.createProduct('Subset', parameters, source) return output
def resample(DIR, band, resolution): """ resamples a band of a SENTINEL product to a given target resolution :param DIR: base directory of Sentinel2 directory tree :param band: band name (e.g. B4) :param resolution: target resolution in meter (e.g 10) :return: resampled band """ from snappy import GPF GPF.getDefaultInstance().getOperatorSpiRegistry().loadOperatorSpis() HashMap = jpy.get_type('java.util.HashMap') BandDescriptor = jpy.get_type( 'org.esa.snap.core.gpf.common.BandMathsOp$BandDescriptor') parameters = HashMap() parameters.put('targetResolution', resolution) parameters.put('upsampling', 'Bicubic') parameters.put('downsampling', 'Mean') parameters.put('flagDownsampling', 'FlagMedianAnd') parameters.put('resampleOnPyramidLevels', True) product = ProductIO.readProduct(DIR) product = GPF.createProduct('Resample', parameters, product) rsp_band = product.getBand(band) return rsp_band
def goldsteinPhasefiltering(product): if debug >= 2: print(cyan + "goldsteinPhasefiltering() : " + bold + green + "Run to SNAP... " + endC) # Instance de GPF GPF.getDefaultInstance().getOperatorSpiRegistry().loadOperatorSpis() # Def operateur SNAP operator = 'GoldsteinPhaseFiltering' # Set des parametres parameters = HashMap() parameters.put("Adaptive Filter Exponent in(0,1]:", 1.0) parameters.put("FFT Size", 64) parameters.put("Window Size", 3) parameters.put("Use coherence mask", False) parameters.put("Coherence Threshold in[0,1]:", 0.2) if debug >= 2: print(parameters) # Get snappy Operators result = GPF.createProduct(operator, parameters, product) if debug >= 2: print(cyan + "goldsteinPhasefiltering() : " + bold + green + "Done... " + endC) return result
def interferogram(product): if debug >= 2: print(cyan + "interferogram() : " + bold + green + "Run to SNAP... " + endC) # Instance de GPF GPF.getDefaultInstance().getOperatorSpiRegistry().loadOperatorSpis() # Def operateur SNAP operator = 'Interferogram' # Set des parametres parameters = HashMap() parameters.put("Subtract flat-earth phase", True) parameters.put("Degree of \"Flat Earth\" polynomial", 5) parameters.put("Number of \"Flat Earth\" estimation points", 501) parameters.put("Orbit interpolation degree", 3) parameters.put("Include coherence estimation", True) parameters.put("Square Pixel", False) parameters.put("Independent Window Sizes", False) parameters.put("Coherence Azimuth Window Size", 10) parameters.put("Coherence Range Window Size", 10) if debug >= 2: print(parameters) # Get snappy Operators result = GPF.createProduct(operator, parameters, product) if debug >= 2: print(cyan + "interferogram() : " + bold + green + "Done... " + endC) return result
def dem_extract(in_prod, xpix, ypix, bandname="altitude"): """Run the S3 SNOW DEM tool. Args: inprod (java.lang.Object): snappy java object: SNAP image product xpix (float): x position in product to query ypix (float): y position in product to query bandname (str): DEM band name in product Returns: slope_vals (dictionnary): values from all bands at the given x,y""" # Initialise a HashMap parameters = HashMap() parameters.put("elevationBandName", bandname) parameters.put("copyElevationBand", "true") # Run slope operator s3snow_slope = GPF.createProduct("SlopeCalculation", parameters, in_prod) # Initialise dictionnary to store data slope_vals = {} # Get all bands for band in list(s3snow_slope.getBandNames()): currentband = s3snow_slope.getBand(band) currentband.loadRasterData() slope_vals[band] = currentband.getPixelFloat(xpix, ypix) return slope_vals
def TOPSAR_Split(inFile, subswath, firstBurstIndex, lastBurstIndex, polarizations): parameters = sc.TOPSAR_Split_config(subswath, firstBurstIndex, lastBurstIndex, polarizations) TOPSAR_Split_Out = GPF.createProduct("TOPSAR-Split", parameters, inFile) logger.info("Finished Process: TOPSAR Split") return TOPSAR_Split_Out
def backGeocoding(product): if debug >= 2: print(cyan + "backGeocoding() : " + bold + green + "Run to SNAP... " + endC) # Instance de GPF GPF.getDefaultInstance().getOperatorSpiRegistry().loadOperatorSpis() # Def operateur SNAP operator = 'Back-Geocoding' # Set des parametres parameters = HashMap() parameters.put("Digital Elevation Model", "SRTM 1Sec HGT (Auto Download)") parameters.put("DEM Resampling Method", "BICUBIC_INTERPOLATION") parameters.put("Resampling Type", "BISINC_5_POINT_INTERPOLATION") parameters.put("Mask out areas with no elevation", True) parameters.put("Output Deramp and Demod Phase", False) if debug >= 2: print(parameters) # Get snappy Operators result = GPF.createProduct(operator, parameters, product) if debug >= 2: print(cyan + "backGeocoding() : " + bold + green + "Done... " + endC) return result
def convertProduct(self, product, sensor="OLCI"): """ Return OLCI *snappy.Product* data product object with units converted to reflectance :type product: *snappy.Product* :param product: In-memory OLCI L1 data product :param type: str :param sensor: name of product sensor (default "OLCI") :return: :product_processed: *snappy.Product* In-memory OLCI L1 data product with units converted to reflectance """ HashMap = jpy.get_type('java.util.HashMap') params = HashMap() params.put("sensor", sensor) params.put("conversionMode", "RAD_TO_REFL") params.put("copyNonSpectralBands", "true") product_processed = GPF.createProduct("Rad2Refl", params, product) return product_processed
def open_subset(self, geo_extent, copymetadata="true"): """ Create a subset of a given SNAP product. From a given set of coordinates defining a region of interest create a subset product containing all the bands from the original product. Args: inprod: ESA SNAP product object geo_extent (wkt): BoundingBox in WKT format copymetadata (bool): Copy all bands to subset product Returns: (self.product): ESA SNAP product object """ # Empty HashMap parameters = HashMap() # Subset parameters geo = WKTReader().read(geo_extent) parameters.put("geoRegion", geo) parameters.put("subSamplingX", "1") parameters.put("subSamplingY", "1") parameters.put("copyMetadata", copymetadata) # Create subset using operator prod_subset = GPF.createProduct("Subset", parameters, self.product) # Update product self.product = prod_subset # Close dataset prod_subset = None
def read_terrain_corrected_product(path_to_dim): print(path_to_dim) dataproduct_r = ProductIO.readProduct(path_to_dim) # will the computed band show up? for band in dataproduct_r.getBandNames(): print(band) print('WRITING OUT TO GEOTIFF!!') sigma0_ortho_bands = ["Sigma0_VH_use_local_inci_angle_from_dem", "Sigma0_VV_use_local_inci_angle_from_dem"] convertComputedBandToBand(dataproduct_r.getBand(sigma0_ortho_bands[0])) convertComputedBandToBand(dataproduct_r.getBand(sigma0_ortho_bands[1])) HashMap = jpy.get_type('java.util.HashMap') sub_parameters = HashMap() sub_parameters.put('bandNames', ",".join(sigma0_ortho_bands)) # Should eventually look at using a local SRTM 1Sec DEM (instead of auto downloading) subset = GPF.createProduct("Subset", sub_parameters, dataproduct_r) final_output_name = Path(Path(path_to_dim).parent, "test") print('writing out final result') # Get a progressMonitor object # monitor = self.createProgressMonitor() # print('WRITING OUT PRODUCT') ProductIO.writeProduct(subset, str(final_output_name), 'BEAM-DIMAP')
def TOPSAR_split_s(product): parameters = HashMap() parameters.put('subswath', 'IW1') parameters.put('selectedPolarisations', 'VV') parameters.put('firstBurstIndex', 3) parameters.put('lastBurstIndex', 6) return GPF.createProduct('TOPSAR-Split', parameters, product)
def topsarDeburst(product): if debug >= 2: print(cyan + "topsarDeburst() : " + bold + green + "Run to SNAP... " + endC) # Instance de GPF GPF.getDefaultInstance().getOperatorSpiRegistry().loadOperatorSpis() # Def operateur SNAP operator = 'TOPSAR-Deburst' # Set des parametres parameters = HashMap() parameters.put("Polarisations", "VV") if debug >= 2: print(parameters) # Get snappy Operators result = GPF.createProduct(operator, parameters, product) if debug >= 2: print(cyan + "topsarDeburst() : " + bold + green + "Done... " + endC) return result
def topophaseRemoval(product): if debug >= 2: print(cyan + "topophaseRemoval() : " + bold + green + "Run to SNAP... " + endC) # Instance de GPF GPF.getDefaultInstance().getOperatorSpiRegistry().loadOperatorSpis() # Def operateur SNAP operator = 'TopoPhaseRemoval' # Set des parametres parameters = HashMap() parameters.put("Orbit Interpolation Degree", 3) parameters.put("Digital Elevation Model", "SRTM 1Sec HGT (Auto Download)") parameters.put("Tile Extension[%]", 100) parameters.put("Output topographic phase band", True) parameters.put("Output elevation band", False) if debug >= 2: print(parameters) # Get snappy Operators result = GPF.createProduct(operator, parameters, product) if debug >= 2: print(cyan + "topophaseRemoval() : " + bold + green + "Done... " + endC) return result
def back_geocoding(product): parameters = HashMap() parameters.put("Digital Elevation Model", "SRTM 1Sec HGT") parameters.put("DEM Resampling Method", "BICUBIC_INTERPOLATION") parameters.put("Resampling Type", "BISINC_5_POINT_INTERPOLATION") parameters.put("Mask out areas with no elevation", True) parameters.put("Output Deramp and Demod Phase", True) return GPF.createProduct("Back-Geocoding", parameters, product)
def radiometricCalibration(subset): parameters = HashMap() parameters.put('auxFile', 'Latest Auxiliary File') parameters.put('outputSigmaBand', True) parameters.put('selectedPolarisations', 'VV') calibrate = GPF.createProduct('Calibration', parameters, subset) list(calibrate.getBandNames()) return calibrate
targetBand1.type = 'float32' targetBand1.expression = '(radiance_10 - radiance_7) / (radiance_10 + radiance_7)' targetBand2 = BandDescriptor() targetBand2.name = 'band_2' targetBand2.type = 'float32' targetBand2.expression = '(radiance_9 - radiance_6) / (radiance_9 + radiance_6)' targetBands = jpy.array('org.esa.snap.core.gpf.common.BandMathsOp$BandDescriptor', 2) targetBands[0] = targetBand1 targetBands[1] = targetBand2 parameters = HashMap() parameters.put('targetBands', targetBands) result = GPF.createProduct('BandMaths', parameters, product) print("Writing...") ProductIO.writeProduct(result, 'snappy_bmaths_output.dim', 'BEAM-DIMAP') print("Done.") """ Please note: the next major version of snappy/jpy will be more pythonic in the sense that implicit data type conversions are performed. The 'parameters' from above variable could then be given as a Python dict object: parameters = { 'targetBands': [ {