private void initBandsMap(Product product) throws IOException { final Band[] bands = product.getBands(); bandMap = new HashMap<>(bands.length); for (Band band : bands) { if (!(band instanceof VirtualBand || band instanceof FilterBand)) { final int bandIndex = bandMap.size(); bandMap.put(band, bandIndex); band.setSourceImage(getMultiLevelImageSourceImage(band, bandIndex)); } } }
private static void copyBandData(Mask[] selectedMasks, Product targetProduct) { for (Mask mask : selectedMasks) { Band band = createBandCopy(targetProduct, mask); band.setSourceImage(mask.getSourceImage()); } }
private static void reprojectBandData(Mask[] selectedMasks, Product sourceProduct, Product targetProduct) { final Map<String, Object> projParameters = Collections.EMPTY_MAP; Map<String, Product> projProducts = new HashMap<String, Product>(); projProducts.put("source", sourceProduct); projProducts.put("collocateWith", targetProduct); Product reprojectedProduct = GPF.createProduct("Reproject", projParameters, projProducts); for (Mask mask : selectedMasks) { Band band = createBandCopy(targetProduct, mask); MultiLevelImage image = reprojectedProduct.getMaskGroup().get(mask.getName()).getSourceImage(); band.setSourceImage(image); } }
private void setSourceImages() { for (Band destBand : tsProduct.getBands()) { final Band raster = getSourceBand(destBand.getName()); if (raster != null) { destBand.setSourceImage(raster.getSourceImage()); } } }
private static Band createBand(float fillValue) { final Band band = new Band("b1", ProductData.TYPE_FLOAT32, WIDTH, HEIGHT); band.setSourceImage(ConstantDescriptor.create((float) WIDTH, (float) HEIGHT, new Float[]{fillValue}, null)); return band; }
private Band addBand(RasterDataNode raster, TimeCoding rasterTimeCoding, String bandName) { final Band band = new Band(bandName, raster.getDataType(), tsProduct.getSceneRasterWidth(), tsProduct.getSceneRasterHeight()); band.setSourceImage(raster.getSourceImage()); ProductUtils.copyRasterDataNodeProperties(raster, band); // todo copy also referenced band in valid pixel expression band.setValidPixelExpression(null); rasterTimeMap.put(band, rasterTimeCoding); tsProduct.addBand(band); return band; }
static Band createSubset(Band sourceBand, Scene targetScene, ProductSubsetDef subsetDef) { final Band targetBand = new Band(sourceBand.getName(), sourceBand.getDataType(), targetScene.getRasterWidth(), targetScene.getRasterHeight()); ProductUtils.copyRasterDataNodeProperties(sourceBand, targetBand); targetBand.setSourceImage(getSourceImage(subsetDef, sourceBand)); return targetBand; }
static Band createSubset(Band sourceBand, Scene targetScene, ProductSubsetDef subsetDef) { final Band targetBand = new Band(sourceBand.getName(), sourceBand.getDataType(), targetScene.getRasterWidth(), targetScene.getRasterHeight()); ProductUtils.copyRasterDataNodeProperties(sourceBand, targetBand); targetBand.setSourceImage(getSourceImage(subsetDef, sourceBand)); return targetBand; }
private void reopenProduct(Product product, File newFile) throws IOException { DimapProductReader productReader = (DimapProductReader) ProductIO.getProductReader( DimapProductConstants.DIMAP_FORMAT_NAME); productReader.bindProduct(newFile, product); product.setProductReader(productReader); Band[] bands = product.getBands(); for (Band band : bands) { if (band.isSourceImageSet() && band.getSourceImage().getImage(0) instanceof BandOpImage) { band.setSourceImage(null); } } }
@Override public void initialize() throws OperatorException { super.initialize(); band.setSourceImage(ConstantDescriptor.create((float) targetProduct.getSceneRasterWidth(), (float) targetProduct.getSceneRasterHeight(), new Float[]{sampleValue}, null)); }
@Override public void initialize() { targetProduct = new Product("name", "desc", RASTER_WIDTH, RASTER_HEIGHT); targetProduct.addBand("OperatorBand", ProductData.TYPE_INT8); targetProduct.addBand("ConstantBand", ProductData.TYPE_INT8).setSourceImage(new BufferedImage(RASTER_WIDTH, RASTER_HEIGHT, BufferedImage.TYPE_BYTE_INDEXED)); targetProduct.addBand(new VirtualBand("VirtualBand", ProductData.TYPE_FLOAT32, RASTER_WIDTH, RASTER_HEIGHT, "OperatorBand + ConstantBand")); targetProduct.setPreferredTileSize(2, 2); }
private static void addElevationBand(Product product, ElevationModel dem, String elevationBandName) { final GeoCoding geoCoding = product.getGeoCoding(); ElevationModelDescriptor demDescriptor = dem.getDescriptor(); final float noDataValue = dem.getDescriptor().getNoDataValue(); final Band elevationBand = product.addBand(elevationBandName, ProductData.TYPE_INT16); elevationBand.setSynthetic(true); elevationBand.setNoDataValue(noDataValue); elevationBand.setUnit("m"); elevationBand.setDescription(demDescriptor.getName()); elevationBand.setSourceImage(createElevationSourceImage(dem, geoCoding, elevationBand)); }
@Override public void customizeProduct(Product product) { product.removeBand(product.getBand("num_passes")); Band const3 = product.addBand("const3", ProductData.TYPE_INT32); int width = product.getSceneRasterWidth(); int height = product.getSceneRasterHeight(); const3.setSourceImage(ConstantDescriptor.create((float) width, (float) height, new Integer[]{3}, null)); } }
private Band createBand(double factor, double offset, boolean log10Scaled) { Product p = new Product("n", "t", 2, 2); Band band = p.addBand("b", ProductData.TYPE_INT8); band.setScalingFactor(factor); band.setScalingOffset(offset); band.setLog10Scaled(log10Scaled); band.setSourceImage(createSourceImage()); return band; }
@Override protected void configureTargetProduct(ProductConfigurer productConfigurer) { super.configureTargetProduct(productConfigurer); final Band band = productConfigurer.addBand("const_7", ProductData.TYPE_FLOAT32); band.setSourceImage(ConstantDescriptor.create((float) productConfigurer.getTargetProduct().getSceneRasterWidth(), (float) productConfigurer.getTargetProduct().getSceneRasterHeight(), new Float[]{7.0F}, null)); }
@Override public void initialize() throws OperatorException { Product targetProduct = new Product("target", "target", 100, 100); for (Band srcBand : source.getBands()) { Band band = targetProduct.addBand(srcBand.getName(), srcBand.getDataType()); band.setSourceImage(srcBand.getSourceImage()); } setTargetProduct(targetProduct); }
@Override public void initialize() throws OperatorException { Product product = new Product("name", "desc", 1, 1); RenderedOp d = ConstantDescriptor.create( (float) product.getSceneRasterWidth(), (float) product.getSceneRasterHeight(), new Float[]{0.5f}, null); product.addBand("a", ProductData.TYPE_INT32); product.addBand("b", ProductData.TYPE_INT32); product.addBand("c", ProductData.TYPE_INT32); product.addBand("d", ProductData.TYPE_FLOAT32).setSourceImage(d); setTargetProduct(product); }
private Band createBand(String name, int dataType, int w, int h, float[] floats, Double noDataValue) { final SampleModel sm = new PixelInterleavedSampleModel(DataBuffer.TYPE_FLOAT, w, h, 1, w, new int[]{0}); final ColorModel cm = PlanarImage.createColorModel(sm); final TiledImage sourceImage = new TiledImage(0, 0, w, h, 0, 0, sm, cm); sourceImage.setData(WritableRaster.createWritableRaster(sm, new DataBufferFloat(floats, w * h), null)); final Band band = new Band(name, dataType, w, h); band.setSourceImage(sourceImage); if (noDataValue != null) { band.setNoDataValueUsed(true); band.setNoDataValue(noDataValue); } return band; } }
private void setSourceImage(Band sourceBand) { final TiledImage sourceImage = new TiledImage(0, 0, sourceBand.getSceneRasterWidth(), sourceBand.getSceneRasterHeight(), 0, 0, new SingleBandedSampleModel(DataBuffer.TYPE_INT, sourceBand.getSceneRasterWidth(), sourceBand.getSceneRasterHeight()), null); sourceImage.setSample(0, 0, 0, 123); sourceImage.setSample(1, 1, 0, 234); sourceImage.setSample(2, 2, 0, 345); sourceImage.setSample(3, 3, 0, 456); sourceBand.setSourceImage(sourceImage); }
@Override public void initialize() { int width = sourceProduct.getSceneRasterWidth(); int height = sourceProduct.getSceneRasterHeight(); PlanarImage constImage = ConstantDescriptor.create((float) width, (float) height, new Float[]{66.6f}, null); targetProduct = new Product("name", "desc", width, height); targetProduct.addBand("OperatorBand", ProductData.TYPE_INT8); targetProduct.addBand("ConstantBand", ProductData.TYPE_FLOAT32).setSourceImage(constImage); targetProduct.addBand(new VirtualBand("VirtualBand", ProductData.TYPE_FLOAT32, width, height, "OperatorBand + ConstantBand")); ProductUtils.copyBand(sourceProduct.getBandAt(0).getName(), sourceProduct, targetProduct, true); }