for (Band srcBand : sourceBands) { final String unit = srcBand.getUnit(); if (unit == null) { throw new OperatorException("band " + srcBand.getName() + " requires a unit"); final String srcBandName = srcBand.getName(); if (selectedPolarisations != null && selectedPolarisations.length != 0 && !containSelectedPolarisations(srcBandName)) { ProductUtils.copyVirtualBand(targetProduct, (VirtualBand) srcBand, srcBand.getName()); } else { final Band targetBand = new Band( srcBandName, srcBand.getDataType(), srcBand.getRasterWidth(), srcBand.getRasterHeight()); targetBand.setUnit(srcBand.getUnit()); targetBand.setNoDataValue(srcBand.getNoDataValue()); targetBand.setNoDataValueUsed(srcBand.isNoDataValueUsed()); targetBand.setDescription(srcBand.getDescription()); targetProduct.addBand(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()); }
public static void setNewBandProperties(Band band, String description, String unit, double noDataValue, boolean useNoDataValue) { band.setDescription(description); band.setUnit(unit); band.setNoDataValue(noDataValue); band.setNoDataValueUsed(useNoDataValue); }
private void setBandProperties(Band band, String validMaskExpression) { band.setDescription(bandDescription); band.setUnit(bandUnit); band.setSpectralWavelength(bandWavelength); band.setGeophysicalNoDataValue(noDataValue); band.setNoDataValueUsed(noDataValueUsed); band.setValidPixelExpression(validMaskExpression); }
public static Band createTargetBand(AotConsts bandFeat, int rasterWidth, int rasterHeight) { Band targetBand = new Band(bandFeat.name, bandFeat.type, rasterWidth, rasterHeight); targetBand.setDescription(bandFeat.description); targetBand.setNoDataValue(bandFeat.noDataValue); targetBand.setNoDataValueUsed(bandFeat.noDataUsed); targetBand.setUnit(bandFeat.unit); targetBand.setScalingFactor(bandFeat.scale); targetBand.setScalingOffset(bandFeat.offset); return targetBand; }
String bandName = computedBand.getName(); int width = computedBand.getRasterWidth(); int height = computedBand.getRasterHeight(); Band realBand = new Band(bandName, computedBand.getDataType(), width, height); realBand.setDescription(createDescription(computedBand)); realBand.setValidPixelExpression(computedBand.getValidPixelExpression()); realBand.setUnit(computedBand.getUnit()); realBand.setSpectralWavelength(computedBand.getSpectralWavelength()); realBand.setGeophysicalNoDataValue(computedBand.getGeophysicalNoDataValue()); realBand.setNoDataValueUsed(computedBand.isNoDataValueUsed()); if (computedBand.isStxSet()) { realBand.setStx(computedBand.getStx()); ImageInfo imageInfo = computedBand.getImageInfo(); if (imageInfo != null) { realBand.setImageInfo(imageInfo.clone()); Product product = computedBand.getProduct(); ProductSceneViewTopComponent topComponent = getProductSceneViewTopComponent(computedBand); if (topComponent != null) { bandGroup.add(bandIndex, realBand); realBand.setSourceImage(createSourceImage(computedBand, realBand)); realBand.setModified(true);
private void setBandProperties(Band targetBand, Band band) { targetBand.setSpectralBandIndex(band.getSpectralBandIndex()); targetBand.setSpectralWavelength(band.getSpectralWavelength()); targetBand.setSpectralBandwidth(band.getSpectralBandwidth()); targetBand.setSolarFlux(band.getSolarFlux()); targetBand.setUnit(band.getUnit()); targetBand.setNoDataValue(band.getNoDataValue()); targetBand.setNoDataValueUsed(true); targetBand.setScalingFactor(band.getScalingFactor()); targetBand.setScalingOffset(band.getScalingOffset()); targetBand.setUnit(band.getUnit()); targetBand.setDescription(band.getDescription()); }
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<>())); } }
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; }
public WriteMaskTilesComputing(Band band, int tileWidth, int tileHeight, Path temporaryParentFolder) throws IOException { super(band.getRasterWidth(), band.getRasterHeight(), tileWidth, tileHeight, temporaryParentFolder); this.band = band; }
private String createToolTip(final Band band) { StringBuilder tooltip = new StringBuilder(); append(tooltip, band.getDescription()); if (band.getSpectralWavelength() > 0.0) { append(tooltip, String.format("%s nm", band.getSpectralWavelength())); if (band.getSpectralBandwidth() > 0.0) { append(tooltip, String.format("+/-%s nm", 0.5 * band.getSpectralBandwidth())); } } append(tooltip, String.format("%d x %d pixels", band.getRasterWidth(), band.getRasterHeight())); if (band instanceof VirtualBand) { append(tooltip, String.format("Expr.: %s", ((VirtualBand) band).getExpression())); } if (band.getUnit() != null) { append(tooltip, String.format(" (%s)", band.getUnit())); } return tooltip.toString(); }
private Band createTargetBand(int levels,String[] bandNames, int index, HashMap<Product, String> tiles, TileComponent tileComp) { Band targetBand = new Band(bandNames[index], this.bandDataType, tileComp.getNumColumns(), tileComp.getNumRows()); Band band = setInputSpecificationBand(tiles, index); final Dimension tileSize = JAIUtils.computePreferredTileSize(band.getRasterWidth(), band.getRasterHeight(), 1); setBandProperties(targetBand, band); initBandsGeoCoding(targetBand,tileComp); Map<Band, String> srcBands = getBandTiles(tiles, index); MosaicMultiLevelSource bandSource = new MosaicMultiLevelSource(srcBands, targetBand.getRasterWidth(), targetBand.getRasterHeight(), tileSize.width, tileSize.height, levels,tileComp, targetBand.getGeoCoding() != null ? Product.findImageToModelTransform(targetBand.getGeoCoding()) : Product.findImageToModelTransform(product.getSceneGeoCoding())); targetBand.setSourceImage(new DefaultMultiLevelImage(bandSource)); return targetBand; }
public static void createVirtualIntensityBand(final Product product, final Band band, final String countStr) { final String expression = band.getName() + " * " + band.getName(); final VirtualBand virtBand = new VirtualBand("Intensity" + countStr, ProductData.TYPE_FLOAT32, band.getRasterWidth(), band.getRasterHeight(), expression); virtBand.setUnit(Unit.INTENSITY); virtBand.setDescription("Intensity from complex data"); virtBand.setNoDataValueUsed(true); product.addBand(virtBand); }
/** * Add user selected bands to target product. */ private void addSelectedBands() { final Band[] sourceBands = sourceProduct.getBands(); boolean validProduct = false; for (Band band : sourceBands) { if (band.getName().toLowerCase().startsWith("unw")) { validProduct = true; unwrappedPhaseBand = band; break; } } if (!validProduct) { throw new OperatorException("Cannot find UnwrappedPhase band in the source product."); } final Band targetBand = new Band("displacement", ProductData.TYPE_FLOAT32, sourceImageWidth, sourceImageHeight); targetBand.setUnit(Unit.METERS); targetProduct.addBand(targetBand); }
private void resetBandTableModel() { bandModel.clear(); if (currentRaster != null) { final int numBands = currentProduct.getNumBands(); for (int i = 0; i < numBands; i++) { final Band band = currentProduct.getBandAt(i); if (shouldDisplayBand(band)) { bandModel.addRow(band.getName(), "", band.getUnit()); } } } }
private void createTargetProduct() { try { double pixelSpacingInMeter = Math.max(SARGeocoding.getAzimuthPixelSpacing(sourceProduct), SARGeocoding.getRangePixelSpacing(sourceProduct)); double pixelSpacingInDegree = SARGeocoding.getPixelSpacingInDegree(pixelSpacingInMeter); final CRSGeoCodingHandler crsHandler = new CRSGeoCodingHandler(sourceProduct, mapProjection, pixelSpacingInDegree, pixelSpacingInMeter); targetProduct = new Product(bandName, sourceProduct.getProductType(), crsHandler.getTargetWidth(), crsHandler.getTargetHeight()); targetProduct.setSceneGeoCoding(crsHandler.getCrsGeoCoding()); elevationBand = new Band(bandName, ProductData.TYPE_FLOAT32, crsHandler.getTargetWidth(), crsHandler.getTargetHeight()); elevationBand.setUnit(Unit.METERS); elevationBand.setNoDataValue(0); //todo get dem no data value elevationBand.setNoDataValueUsed(true); targetProduct.addBand(elevationBand); } catch (Exception e) { throw new OperatorException(e); } }
static private SpectrumBand createBand(int index) { final Band band = new Band("Radiance_" + (index + 1), ProductData.TYPE_INT16, 100, 100); band.setDescription("Radiance for band " + (index + 1)); band.setSpectralWavelength((float) Math.random()); band.setSpectralBandwidth((float) Math.random()); band.setUnit("sr^-1"); if (index == 7) { band.setUnit("dl"); } return new SpectrumBand(band, true); }
private static Band addVarianceBand(Product product, Band sourceBand, String varianceExpr) { Band varianceBand; varianceBand = product.addBand(sourceBand.getName() + "_variance", varianceExpr, ProductData.TYPE_FLOAT32); varianceBand.setUnit(sourceBand.getUnit()); ProductUtils.copySpectralBandProperties(sourceBand, varianceBand); return varianceBand; }