public ElevationSourceImage(ElevationModel dem, GeoCoding geoCoding, Band band, ResolutionLevel level) { super(band, level); this.dem = dem; this.geoCoding = geoCoding; noDataValue = band.getNoDataValue(); }
private static String getCheckForNoDataExpression(final Product product, final String exp) { final String[] bandNames = product.getBandNames(); StringBuilder checkForNoData = new StringBuilder("(" + exp + " == NaN"); if (StringUtils.contains(bandNames, exp)) { double nodatavalue = product.getBand(exp).getNoDataValue(); checkForNoData.append(" or " + exp + " == " + nodatavalue); } checkForNoData.append(") ? NaN : "); return checkForNoData.toString(); }
public static double getNoDataValue(final File extFile) { try { final Product product = CommonReaders.readProduct(extFile); if (product != null) return product.getBandAt(0).getNoDataValue(); } catch (Exception e) { // } return 0; } }
private void computeData() { resetData(); for (Band band : selectedBands) { final int index = getTimeIndex(band); if (index >= 0) { dataPoints[index] = processVector(band); if (dataPoints[index] == band.getNoDataValue()) { dataPoints[index] = Double.NaN; } } } dataComputed = true; }
/** * Get product co-polarization. */ private void getProductCoPolarization() { final String[] sourceBandNames = sourceProduct.getBandNames(); for (String bandName : sourceBandNames) { if (bandName.contains("HH")) { coPolarization = "HH"; coPolBand = sourceProduct.getBand(bandName); break; } else if (bandName.contains("VV")) { coPolarization = "VV"; coPolBand = sourceProduct.getBand(bandName); break; } } if (coPolarization == null) { throw new OperatorException("Input product does not contain band with HH or VV polarization"); } noDataValue = coPolBand.getNoDataValue(); }
"==" + trgBand.getNoDataValue() + '?' + trgBand.getNoDataValue() + ':' + trgBandName + " / sin(projectedLocalIncidenceAngle * PI/180.0)" + " * sin(incidenceAngleFromEllipsoid * PI/180)"; "==" + trgBand.getNoDataValue() + '?' + trgBand.getNoDataValue() + ':' + trgBandName + " / sin(projectedLocalIncidenceAngle * PI/180.0)" + " * sin(localIncidenceAngle * PI/180)";
/** * Create Beta0 image as a virtual band. */ public static void createBetaNoughtVirtualBand(final Product targetProduct) { final Band[] bands = targetProduct.getBands(); for (Band trgBand : bands) { final String trgBandName = trgBand.getName(); if (trgBand instanceof VirtualBand || !trgBandName.contains("Sigma0")) { continue; } final String expression = trgBandName + "==" + trgBand.getNoDataValue() + '?' + trgBand.getNoDataValue() + ':' + trgBandName + " / sin(projectedLocalIncidenceAngle * PI/180.0)"; String betaNoughtVirtualBandName = trgBandName.replace("Sigma0", "Beta0"); final VirtualBand band = new VirtualBand(betaNoughtVirtualBandName, ProductData.TYPE_FLOAT32, trgBand.getRasterWidth(), trgBand.getRasterHeight(), expression); band.setUnit(trgBand.getUnit()); band.setDescription("Beta0 image"); band.setNoDataValueUsed(true); targetProduct.addBand(band); } } }
/** * 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<>())); } }
targetBand.setNoDataValue(srcBand.getNoDataValue()); targetBand.setNoDataValueUsed(srcBand.isNoDataValueUsed()); targetProduct.addBand(targetBand);
@Override public void readValues(final ImageLayer imageLayer, final GeoPos geoPos, final int level) { resetData(); for (Band band : selectedBands) { final int index = getTimeIndex(band); if (index >= 0) { final PixelPos pix = band.getGeoCoding().getPixelPos(geoPos, null); dataPoints[index] = getPixelDouble(band, (int) pix.getX(), (int) pix.getY()); if (dataPoints[index] == band.getNoDataValue()) { dataPoints[index] = Double.NaN; } } } Range.computeRangeDouble(dataPoints, IndexValidator.TRUE, dataPointRange, ProgressMonitor.NULL); // no invalidate() call here, SpectrumDiagram does this }
try { return reprojection.reproject(leveledSourceImage, sourceGeometry, targetGeometry, targetBand.getNoDataValue(), resampling, hints, targetLevel, tileSize); } catch (FactoryException | TransformException e) {
@Override public void readValues(final ImageLayer imageLayer, final GeoPos geoPos, final int level) { resetData(); if (placemark != null) { for (Band band : selectedBands) { final int index = getTimeIndex(band); if (index >= 0) { final PixelPos pix = band.getGeoCoding().getPixelPos(placemark.getGeoPos(), null); /*final MultiLevelModel multiLevelModel = ImageManager.getMultiLevelModel(band); final AffineTransform i2mTransform = multiLevelModel.getImageToModelTransform(0); final AffineTransform m2iTransform = multiLevelModel.getModelToImageTransform(level); final Point2D modelPixel = i2mTransform.transform(placemark.getPixelPos(), null); final Point2D imagePixel = m2iTransform.transform(modelPixel, null); final int pixX = (int) Math.floor(imagePixel.getX()); final int pixY = (int) Math.floor(imagePixel.getY()); */ dataPoints[index] = ProductUtils.getGeophysicalSampleAsLong(band, (int) pix.getX(), (int) pix.getY(), level); if (dataPoints[index] == band.getNoDataValue()) { dataPoints[index] = Double.NaN; } } } } Range.computeRangeDouble(dataPoints, IndexValidator.TRUE, dataPointRange, ProgressMonitor.NULL); // no invalidate() call here, SpectrumDiagram does this }
private void saveCoherence(final DoubleMatrix cohMatrix, final ProductContainer product, final Map<Band, Tile> targetTileMap, final Rectangle targetRectangle) { final int x0 = targetRectangle.x; final int y0 = targetRectangle.y; final int maxX = x0 + targetRectangle.width; final int maxY = y0 + targetRectangle.height; final Band coherenceBand = targetProduct.getBand(product.getBandName(Unit.COHERENCE)); final Tile coherenceTile = targetTileMap.get(coherenceBand); final ProductData coherenceData = coherenceTile.getDataBuffer(); final double srcNoDataValue = product.sourceMaster.realBand.getNoDataValue(); final Tile slvTileReal = getSourceTile(product.sourceSlave.realBand, targetRectangle); final ProductData srcSlvData = slvTileReal.getDataBuffer(); final TileIndex srcSlvIndex = new TileIndex(slvTileReal); final TileIndex tgtIndex = new TileIndex(coherenceTile); for (int y = y0; y < maxY; y++) { tgtIndex.calculateStride(y); srcSlvIndex.calculateStride(y); final int yy = y - y0; for (int x = x0; x < maxX; x++) { final int tgtIdx = tgtIndex.getIndex(x); final int xx = x - x0; if (srcSlvData.getElemDoubleAt(srcSlvIndex.getIndex(x)) == srcNoDataValue) { coherenceData.setElemFloatAt(tgtIdx, (float) srcNoDataValue); } else { final double coh = cohMatrix.get(yy, xx); coherenceData.setElemFloatAt(tgtIdx, (float) coh); } } } }
noDataValue = masterProduct.getBandAt(0).getNoDataValue();
private void saveCoherence(final DoubleMatrix cohMatrix, final ProductContainer product, final Map<Band, Tile> targetTileMap, final Rectangle targetRectangle) { final int x0 = targetRectangle.x; final int y0 = targetRectangle.y; final int maxX = x0 + targetRectangle.width; final int maxY = y0 + targetRectangle.height; final Band coherenceBand = targetProduct.getBand(product.getBandName(Unit.COHERENCE)); final Tile coherenceTile = targetTileMap.get(coherenceBand); final ProductData coherenceData = coherenceTile.getDataBuffer(); final double srcNoDataValue = product.sourceMaster.realBand.getNoDataValue(); final Tile slvTileReal = getSourceTile(product.sourceSlave.realBand, targetRectangle); final ProductData srcSlvData = slvTileReal.getDataBuffer(); final TileIndex srcSlvIndex = new TileIndex(slvTileReal); final TileIndex tgtIndex = new TileIndex(coherenceTile); for (int y = y0; y < maxY; y++) { tgtIndex.calculateStride(y); srcSlvIndex.calculateStride(y); final int yy = y - y0; for (int x = x0; x < maxX; x++) { final int tgtIdx = tgtIndex.getIndex(x); final int xx = x - x0; if (srcSlvData.getElemDoubleAt(srcSlvIndex.getIndex(x)) == srcNoDataValue) { coherenceData.setElemFloatAt(tgtIdx, (float) srcNoDataValue); } else { final double coh = cohMatrix.get(yy, xx); coherenceData.setElemFloatAt(tgtIdx, (float) coh); } } } }
targetBand.setNoDataValue(srcBand.getNoDataValue()); targetBand.setNoDataValueUsed(false); targetBand.setSpectralWavelength(srcBand.getSpectralWavelength());
targetBand.setNoDataValue(srcBand.getNoDataValue()); targetBand.setNoDataValueUsed(srcBand.isNoDataValueUsed()); targetBand.setDescription(srcBand.getDescription());
scalings[1] = product.getSceneRasterHeight() / (float) sourceImage.getHeight(); PlanarImage scaledImage = SourceImageScaler.scaleMultiLevelImage(targetImage, sourceImage, scalings, null, renderingHints, band.getNoDataValue(), Interpolation.getInstance(Interpolation.INTERP_NEAREST)); band.setSourceImage(scaledImage);
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()); }
Band srcBand = nitfProduct.getBandAt(idx); targetBand = new ColorPaletteBand(bandName, srcBand.getDataType(), product.getSceneRasterWidth(), product.getSceneRasterHeight(), this.colorPaletteFilePath); targetBand.setNoDataValue(srcBand.getNoDataValue()); targetBand.setNoDataValueUsed(srcBand.isNoDataValueUsed()); targetBand.setScalingOffset(srcBand.getScalingOffset());