private Interpolation getResampling(Band band) { int resampleType = getResampleType(); if (!ProductData.isFloatingPointType(band.getDataType())) { resampleType = Interpolation.INTERP_NEAREST; } return Interpolation.getInstance(resampleType); }
public int getHighestElemSize() { int highestElemSize = 0; for (Band band : srcProduct.getBands()) { if (writer.shouldWrite(band)) { int elemSize = ProductData.getElemSize(band.getDataType()); if (elemSize > highestElemSize) { highestElemSize = elemSize; } } } return highestElemSize; }
private void generateProductLists( Set<String> selectedProductFiles, List<TileMetadata>tileMetadataList) throws IOException{ for (TileMetadata tileMetadata : tileMetadataList) { TileComponent tileComponent = tileMetadata.getTileComponent(); for (int filesIndex = 0; filesIndex < tileComponent.getNumOfTiles(); filesIndex++) { String filePath = null; for (String filePaths : selectedProductFiles) { if (filePaths.contains(tileComponent.getTileNames()[filesIndex])) { filePath = filePaths; } } Product p = ProductIO.readProduct(Paths.get(productDirectory.getBasePath()).resolve(filePath).toFile()); this.bandDataType = p.getBandAt(0).getDataType(); if (tileComponent.getBandID().equals("P")) { this.tilesPanchromatic.put(p, tileComponent.getTileNames()[filesIndex]); } else { this.tilesMultiSpectral.put(p, tileComponent.getTileNames()[filesIndex]); if (this.numMultiSpectralBands ==0) { this.numMultiSpectralBands = p.getNumBands(); } } } } }
private void writeUnwrappedBandHeader(final Product sourceProduct) throws IOException { Band phaseBand = null; for (Band band : sourceProduct.getBands()) { if (band.getUnit()!= null && band.getUnit().contains(Unit.PHASE)) { phaseBand = band; break; } } if(phaseBand == null) { throw new IOException("SNAPHU writer requires a wrapped phase band"); } String bandName = UNWRAPPED_PREFIX + phaseBand.getName() + SNAPHU_HEADER_EXTENSION; File unwrappedHeaderFile = new File(_outputDir, bandName); Band newBand = new Band(UNWRAPPED_PREFIX+phaseBand.getName(), phaseBand.getDataType(), phaseBand.getRasterWidth(), phaseBand.getRasterHeight()); newBand.setDescription("Unwrapped "+phaseBand.getDescription()); EnviHeader.createPhysicalFile(unwrappedHeaderFile, newBand, newBand.getRasterWidth(), newBand.getRasterHeight(), 0); }
/** * Add the user selected bands to target product. * * @throws OperatorException The exceptions. */ private void addSelectedBands() throws OperatorException { final Band[] sourceBands = OperatorUtils.getSourceBands(sourceProduct, sourceBandNames, false); for (Band srcBand : sourceBands) { final String srcBandName = srcBand.getName(); final String unit = srcBand.getUnit(); if (unit == null) { throw new OperatorException("band " + srcBandName + " requires a unit"); } final Band targetBand = new Band(srcBandName, srcBand.getDataType(), sourceImageWidth, sourceImageHeight); targetBand.setNoDataValueUsed(true); targetBand.setNoDataValue(srcBand.getNoDataValue()); targetBand.setUnit(unit); targetProduct.addBand(targetBand); bandWindFieldRecord.put(srcBandName, SynchronizedList.decorate(new ArrayList<>())); } }
/** * Copies the named band from the source product to the target product. * * @param sourceBandName the name of the band to be copied. * @param sourceProduct the source product. * @param targetBandName the name of the band copied. * @param targetProduct the target product. * @return the copy of the band, or <code>null</code> if the sourceProduct does not contain a band with the given name. */ private Band copyBandScl(String sourceBandName, Product sourceProduct, String targetBandName, Product targetProduct) { Guardian.assertNotNull("sourceProduct", sourceProduct); Guardian.assertNotNull("targetProduct", targetProduct); if (sourceBandName == null || sourceBandName.length() == 0) { return null; } final Band sourceBand = sourceProduct.getBand(sourceBandName); if (sourceBand == null) { return null; } Band targetBand = new Band(targetBandName, sourceBand.getDataType(), targetProduct.getSceneRasterWidth(), targetProduct.getSceneRasterHeight()); ProductUtils.copyRasterDataNodeProperties(sourceBand, targetBand); targetProduct.addBand(targetBand); return targetBand; }
String bandName = prefix + "_Reflectance_" + bandId; Band targetBand = new Band(bandName, srcBand.getDataType(), srcBand.getRasterWidth(), srcBand.getRasterHeight()); product.addBand(targetBand); ProductUtils.copyGeoCoding(srcBand, targetBand);
Band targetBand = new Band(bandName, srcBand.getDataType(), srcBand.getRasterWidth(), srcBand.getRasterHeight()); product.addBand(targetBand); ProductUtils.copyGeoCoding(srcBand, targetBand);
private void addAOTImage(Product product, String pathString) { Band srcBand = getTifBand(pathString, 1); if (srcBand == null) { logger.warning(String.format("Image %s not added", pathString)); return; } MuscateMetadata.Geoposition geoposition = getGeoposition(srcBand.getRasterWidth(), srcBand.getRasterHeight()); if (geoposition == null) { logger.warning(String.format("Unrecognized geometry of image %s, it will not be added to the product %s.", pathString, product.getName())); return; } String bandName = "AOT_" + geoposition.id; Band targetBand = new Band(bandName, srcBand.getDataType(), srcBand.getRasterWidth(), srcBand.getRasterHeight()); product.addBand(targetBand); ProductUtils.copyGeoCoding(srcBand, targetBand); targetBand.setNoDataValue(metadata.getAOTNoDataValue()); targetBand.setNoDataValueUsed(true); targetBand.setScalingFactor(1.0d / metadata.getAOTQuantificationValue()); targetBand.setScalingOffset(0.0d); targetBand.setSampleCoding(srcBand.getSampleCoding()); targetBand.setImageInfo(srcBand.getImageInfo()); targetBand.setDescription(String.format("Aerosol Optical Thickness at %.0fm resolution", geoposition.xDim)); targetBand.setSourceImage(srcBand.getSourceImage()); }
Band targetBand = new Band(bandName, srcBand.getDataType(), srcBand.getRasterWidth(), srcBand.getRasterHeight()); product.addBand(targetBand); ProductUtils.copyGeoCoding(srcBand, targetBand);
Band targetBand = new Band(bandName, srcBand.getDataType(), srcBand.getRasterWidth(), srcBand.getRasterHeight()); product.addBand(targetBand); ProductUtils.copyGeoCoding(srcBand, targetBand);
private void addWVCImage(Product product, String pathString) { Band srcBand = getTifBand(pathString, 0); if (srcBand == null) { logger.warning(String.format("Image %s not added", pathString)); return; } MuscateMetadata.Geoposition geoposition = getGeoposition(srcBand.getRasterWidth(), srcBand.getRasterHeight()); if (geoposition == null) { logger.warning(String.format("Unrecognized geometry of image %s, it will not be added to the product %s.", pathString, product.getName())); return; } String bandName = "WVC_" + geoposition.id; Band targetBand = new Band(bandName, srcBand.getDataType(), srcBand.getRasterWidth(), srcBand.getRasterHeight()); product.addBand(targetBand); ProductUtils.copyGeoCoding(srcBand, targetBand); targetBand.setNoDataValue(metadata.getWVCNoDataValue()); targetBand.setNoDataValueUsed(true); targetBand.setScalingFactor(1.0d / metadata.getWVCQuantificationValue()); targetBand.setScalingOffset(0.0d); targetBand.setUnit("cm"); //TODO verify targetBand.setSampleCoding(srcBand.getSampleCoding()); targetBand.setImageInfo(srcBand.getImageInfo()); targetBand.setDescription(String.format("Water vapor content at %.0fm resolution in %s", geoposition.xDim, targetBand.getUnit())); targetBand.setSourceImage(srcBand.getSourceImage()); }
Band targetBand = new Band(bandName, srcBand.getDataType(), srcBand.getRasterWidth(), srcBand.getRasterHeight()); product.addBand(targetBand); ProductUtils.copyGeoCoding(srcBand, targetBand);
Band targetBand = new Band(bandName, srcBand.getDataType(), srcBand.getRasterWidth(), srcBand.getRasterHeight()); product.addBand(targetBand); ProductUtils.copyGeoCoding(srcBand, targetBand);
private Band addBand(final Product product, String name, final int w, final int h, final ImageIOFile img, final int bandIndex, final String unit) throws IOException { File bandFile = getFile(img.getName()); ProductReader reader = geotiffPlugIn.createReaderInstance(); Product bandProduct = reader.readProductNodes(bandFile, null); if (bandProduct != null) { bandProducts.add(bandProduct); Band srcBand = bandProduct.getBandAt(bandIndex); if (product.containsBand(name)) { name += "2"; } Band band = new Band(name, srcBand.getDataType(), w, h); band.setNoDataValue(0); band.setNoDataValueUsed(true); band.setUnit(unit); band.setSourceImage(srcBand.getSourceImage()); product.addBand(band); return band; } return null; }
protected void readMasks() { File file; if (metadata != null) { try { String maskFileName = metadata.getMaskFileName(); if (maskFileName != null) { file = productDirectory.getFile(maskFileName); if (file != null && file.exists()) { GeoTiffProductReader reader = new GeoTiffProductReader(getReaderPlugIn()); Product udmProduct = reader.readProductNodes(file, null); Band srcBand = udmProduct.getBandAt(0); float scaleX = (float)metadata.getRasterWidth() / (float)udmProduct.getSceneRasterWidth(); float scaleY = (float)metadata.getRasterHeight() / (float)udmProduct.getSceneRasterHeight(); RenderedOp renderedOp = ScaleDescriptor.create(srcBand.getSourceImage(), scaleX, scaleY, 0.0f, 0.0f, Interpolation.getInstance(Interpolation.INTERP_NEAREST), null); Band targetBand = product.addBand("unusable_data", srcBand.getDataType()); targetBand.setSourceImage(renderedOp); FlagCoding cloudsFlagCoding = createFlagCoding(product); targetBand.setSampleCoding(cloudsFlagCoding); List<Mask> cloudsMasks = createMasksFromFlagCodding(product, cloudsFlagCoding); for (Mask mask : cloudsMasks) { product.getMaskGroup().add(mask); } } } } catch (IOException e) { logger.warning(e.getMessage()); } } }
if (firstProductBand.getDataType() != band.getDataType()) { throw new OperatorException("Different band type."); Band targetBand = new Band("band_" + (i+1), firstProductBand.getDataType(), firstBandWidth, firstBandHeight); this.targetProduct.addBand(targetBand);
srcBand.getDataType(), srcBand.getRasterWidth(), srcBand.getRasterHeight());
int height = computedBand.getRasterHeight(); Band realBand = new Band(bandName, computedBand.getDataType(), width, height); realBand.setDescription(createDescription(computedBand)); realBand.setValidPixelExpression(computedBand.getValidPixelExpression());
Band contextBand = contextProduct.addBand(srcBand.getName(), srcBand.getDataType()); if (srcBand.isFlagBand()) { contextBand.setSampleCoding(contextProduct.getFlagCodingGroup().get(srcBand.getFlagCoding().getName()));