private void processLandWaterMask() { boolean isHigherResolutionInput = sourceProduct.getBand("B2") != null && sourceProduct.getBand("B2").getGeoCoding().getMapCRS().getName().toString().contains("UTM") && sourceProduct.getBand("B2").getImageToModelTransform().getScaleX() < LAND_WATER_MASK_RESOLUTION; HashMap<String, Object> waterMaskParameters = new HashMap<>(); waterMaskParameters.put("resolution", LAND_WATER_MASK_RESOLUTION); if (isHigherResolutionInput) { System.out.println("No subsampling of " + sourceProduct.getBand("B2").getImageToModelTransform().getScaleX() + " m product necessary to access " + LAND_WATER_MASK_RESOLUTION + " m water mask"); waterMaskParameters.put("subSamplingFactorX", 1); waterMaskParameters.put("subSamplingFactorY", 1); } else { waterMaskParameters.put("subSamplingFactorX", OVERSAMPLING_FACTOR_X); waterMaskParameters.put("subSamplingFactorY", OVERSAMPLING_FACTOR_Y); } waterMaskProduct = GPF.createProduct("LandWaterMask", waterMaskParameters, sourceProduct); }
MultiLevelModel targetModel, Reproject reprojection) { final CoordinateReferenceSystem sourceModelCrs = Product.findModelCRS(sourceGeoCoding); final CoordinateReferenceSystem targetModelCrs = Product.findModelCRS(targetBand.getGeoCoding()); final AffineTransform sourceImageToMapTransform = Product.findImageToModelTransform(sourceGeoCoding); final AffineTransform targetImageToMapTransform = Product.findImageToModelTransform(targetBand.getGeoCoding());
/** * Returns the rotation angle of otherCell relative to the current cell. * @param otherCell The second cell to get the rotation from. * @return The angle value (radians) */ public double rotation(BandMatrixCell otherCell) { Assert.notNull(otherCell); Assert.notNull(otherCell.band); double angle = 0.0; GeoCoding otherGeoCoding = otherCell.band.getGeoCoding(); if (otherGeoCoding != null) { GeoPos brCorner = new GeoPos(); otherGeoCoding.getGeoPos(new PixelPos(otherCell.band.getRasterWidth() - 1, otherCell.band.getRasterHeight() - 1), brCorner); angle = (brCorner.getLat() - otherCell.origin.getY()) / (brCorner.getLon() - otherCell.origin.getX()); } return angle; } }
private void initBandGeoCoding(ImageMetadata imageMetadata, Band band, int sceneWidth, int sceneHeight) { int bandWidth = imageMetadata.getRasterWidth(); int bandHeight = imageMetadata.getRasterHeight(); GeoCoding geoCoding = null; ImageMetadata.InsertionPoint insertPoint = imageMetadata.getInsertPoint(); String crsCode = imageMetadata.getCRSCode(); try { CoordinateReferenceSystem crs = CRS.decode(crsCode); if (imageMetadata.hasInsertPoint()) { geoCoding = new CrsGeoCoding(crs, bandWidth, bandHeight, insertPoint.x, insertPoint.y, insertPoint.stepX, insertPoint.stepY, 0.0, 0.0); } else { if (sceneWidth != bandWidth) { AffineTransform2D transform2D = new AffineTransform2D((float) sceneWidth / bandWidth, 0.0, 0.0, (float) sceneHeight / bandHeight, 0.0, 0.0); geoCoding = addTiePointGridGeo(imageMetadata, bandWidth, bandHeight); band.setImageToModelTransform(transform2D); } } } catch (Exception e) { logger.warning(e.getMessage()); } if(band.getGeoCoding() == null) { band.setGeoCoding(geoCoding); } }
band.setImageToModelTransform(product.findImageToModelTransform(band.getGeoCoding()));
private void setInvalidTargetSamples(Map<Band, Tile> targetTiles, int x, int y) { float[] latLon = getLatLon(x, y, pixelWindow, sourceProduct); for (Tile t : targetTiles.values()) { if (t.getRasterDataNode() == latBand) { targetTiles.get(targetProduct.getBand("latitude")).setSample(x, y, latLon[0]); } else if (t.getRasterDataNode() == lonBand) { targetTiles.get(targetProduct.getBand("longitude")).setSample(x, y, latLon[1]); } else if (t.getRasterDataNode() == aotBand) { if (aodDefault != null && aodDefault.getGeoCoding() != null) { final PixelPos pixelPos = aodDefault.getGeoCoding().getPixelPos(new GeoPos(latLon[0], latLon[1]), new PixelPos()); t.setSample(x, y, aodDefault.getSampleFloat((int) pixelPos.getX(), (int) pixelPos.getY())); } else { t.setSample(x, y, t.getRasterDataNode().getNoDataValue()); } } else { t.setSample(x, y, t.getRasterDataNode().getNoDataValue()); } } }
@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 }
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; }
targetBand.setScalingOffset(band.getScalingOffset()); targetBand.setDescription(band.getDescription()); if (band.getGeoCoding() != null) { targetBand.setGeoCoding(band.getGeoCoding()); } else { if (width != band.getRasterWidth()) { band.getRasterWidth(), band.getRasterHeight(), tileSize.width, tileSize.height, levels, band.getGeoCoding() != null ? targetBand.getGeoCoding() != null ? Product.findImageToModelTransform(targetBand.getGeoCoding()) : Product.findImageToModelTransform(product.getSceneGeoCoding()) : targetBand.getImageToModelTransform());
@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 }
band.setImageToModelTransform(product.findImageToModelTransform(band.getGeoCoding()));
private double processVector(final Band band) { final GeoCoding bandGC = band.getGeoCoding(); final ReferencedEnvelope env = vectorNode.getEnvelope(); final String envCode = env.getCoordinateReferenceSystem().getName().getCode();
Product.findImageToModelTransform(band.getGeoCoding()));
MathTransform mapTransform = band.getGeoCoding().getImageToMapTransform(); DirectPosition bandOrigin = mapTransform.transform(new DirectPosition2D(0, 0), null); S2MosaicMultiLevelSource bandSource = band.getRasterWidth(), band.getRasterHeight(), tileSize.width, tileSize.height, levels, band.getGeoCoding(), this.overlappingMethod); band.setSourceImage(new DefaultMultiLevelImage(bandSource));
throw new IOException(e); band.setImageToModelTransform(product.findImageToModelTransform(band.getGeoCoding())); Product.findImageToModelTransform(band.getGeoCoding()));
levels, typeMap.get(pixelDataType), imageMetadata.isGeocoded() ? targetBand.getGeoCoding() != null ? Product.findImageToModelTransform(targetBand.getGeoCoding()) : Product.findImageToModelTransform(product.getSceneGeoCoding()) : targetBand.getImageToModelTransform());
levels, typeMap.get(pixelDataType), imageMetadata.isGeocoded() ? targetBand.getGeoCoding() != null ? Product.findImageToModelTransform(targetBand.getGeoCoding()) : Product.findImageToModelTransform(product.getSceneGeoCoding()) : targetBand.getImageToModelTransform());
Product.findImageToModelTransform(band.getGeoCoding()));
targetBand.setGeoCoding(sourceBand.getGeoCoding()); this.targetProduct.addBand(targetBand);