private void prepareTargetBand(int rgbIndex, Band sourceBand, String bandName, int width, int height) { Band targetBand = new Band(bandName, sourceBand.getDataType(), width, height); targetProduct.addBand(targetBand); bandMap.put(targetBand, sourceBand); ProductData data = targetBand.createCompatibleRasterData(); dataMap.put(targetBand, data); targetBand.setRasterData(data); rgbChannelNodes[rgbIndex] = targetBand; }
/** * Tests the correct datatypes to be returned */ public void testGetDataType() { assertEquals(ProductData.TYPE_UINT8, _rsBandBlaByte5050.getDataType()); assertEquals(ProductData.TYPE_UINT16, _rsBandBlubbUShort1010.getDataType()); assertEquals(ProductData.TYPE_INT16, _rsBandTestShort2020.getDataType()); assertEquals(ProductData.TYPE_INT32, _rsBandGnmpfInt1515.getDataType()); assertEquals(ProductData.TYPE_FLOAT32, _rsBandBlimFloat2323.getDataType()); assertEquals(ProductData.TYPE_FLOAT32, _rsBandZippFloat1005.getDataType()); assertEquals(ProductData.TYPE_FLOAT64, _rsBandBlepDouble100100.getDataType()); }
private WritableRaster createWritableRaster(Rectangle rectangle) { final int dataBufferType = ImageManager.getDataBufferType(getTargetBand().getDataType()); SampleModel sampleModel = ImageUtils.createSingleBandedSampleModel(dataBufferType, rectangle.width, rectangle.height); final Point location = new Point(rectangle.x, rectangle.y); return createWritableRaster(sampleModel, location); }
private Interpolation getResampling(Band band) { int resampleType = getResampleType(); if (!ProductData.isFloatingPointType(band.getDataType())) { resampleType = Interpolation.INTERP_NEAREST; } return Interpolation.getInstance(resampleType); }
private static boolean isValidColorMapProduct(Product product) { return getNumBands(product) == 1 && product.getBandAt(0).getIndexCoding() != null && product.getBandAt(0).getDataType() == ProductData.TYPE_UINT8; }
private static boolean isValidColorMapProduct(Product product) { return getNumBands(product) == 1 && product.getBandAt(0).getIndexCoding() != null && product.getBandAt(0).getDataType() == ProductData.TYPE_UINT8; }
/** * Creates a string defining this band object. */ @Override public String toString() { return getClass().getName() + "[" + getName() + "," + ProductData.getTypeString(getDataType()) + "," + +getRasterWidth() + "," + +getRasterHeight() + "," + +getSpectralBandIndex() + "," + +getSpectralWavelength() + "," + +getSpectralBandwidth() + "," + +getSolarFlux() + "]"; }
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 testBands(Product product) { final Band[] bands = product.getBands(); assertEquals(4, bands.length); assertEquals("lat", bands[0].getName()); assertEquals("lon", bands[1].getName()); assertEquals("radiance_1", bands[2].getName()); assertEquals("radiance_2", bands[3].getName()); assertEquals(ProductData.TYPE_FLOAT32, bands[0].getDataType()); assertEquals(ProductData.TYPE_FLOAT32, bands[1].getDataType()); assertEquals(ProductData.TYPE_FLOAT32, bands[2].getDataType()); assertEquals(ProductData.TYPE_FLOAT32, bands[3].getDataType()); }
private static ProductData createDataFor(Band dataBand) { final int width = dataBand.getSceneRasterWidth(); final int height = dataBand.getSceneRasterHeight(); final ProductData data = ProductData.createInstance(dataBand.getDataType(), width * height); for (int y = 0; y < height; y++) { final int line = y * width; for (int x = 0; x < width; x++) { data.setElemIntAt(line + x, x * y); } } return data; } }
private static ProductData createDataFor(Band dataBand) { final int width = dataBand.getSceneRasterWidth(); final int height = dataBand.getSceneRasterHeight(); final ProductData data = ProductData.createInstance(dataBand.getDataType(), width * height); for (int y = 0; y < height; y++) { final int line = y * width; for (int x = 0; x < width; x++) { data.setElemIntAt(line + x, x * y); } } return data; } }
@Test public void testRead_ProductWithIntegerValues() throws Exception { final Product product = readTestProduct("simple_format_4_integer_features.txt"); assertNotNull(product); assertEquals(2, product.getSceneRasterWidth()); assertEquals(2, product.getSceneRasterHeight()); final Band[] bands = product.getBands(); assertEquals(3, bands.length); assertEquals("class", bands[0].getName()); assertEquals("radiance", bands[1].getName()); assertEquals("anotherOne", bands[2].getName()); assertEquals(ProductData.TYPE_INT32, bands[0].getDataType()); assertEquals(ProductData.TYPE_FLOAT32, bands[1].getDataType()); assertEquals(ProductData.TYPE_INT32, bands[2].getDataType()); }
@Test public void testSimplestCaseWithFactoryMethod() throws Exception { Product sourceProduct = createTestProduct(4, 4); BandMathsOp bandMathsOp = createBooleanExpressionBand(sourceProduct, "band1 > 0"); assertNotNull(bandMathsOp); Product targetProduct = bandMathsOp.getTargetProduct(); assertNotNull(targetProduct); Band band = targetProduct.getBandAt(0); assertNotNull(band); assertEquals(ProductData.TYPE_INT8, band.getDataType()); int[] intValues = new int[16]; band.readPixels(0, 0, 4, 4, intValues, ProgressMonitor.NULL); int[] expectedValues = new int[16]; Arrays.fill(expectedValues, 1); assertTrue(Arrays.equals(expectedValues, intValues)); }
@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 { sourceBand = sourceProduct.getBand(bandName); targetProduct = new Product(sourceProduct.getName(), sourceProduct.getProductType(), sourceProduct.getSceneRasterWidth(), sourceProduct.getSceneRasterHeight()); targetBand = targetProduct.addBand(bandName, sourceBand.getDataType()); }
private void copyBandTo(Product destP, Band sourceBand) { final Band destBand = new Band(sourceBand.getName(), sourceBand.getDataType(), sourceBand.getRasterWidth(), sourceBand.getRasterHeight()); destBand.setRasterData(sourceBand.getData().createDeepClone()); destP.addBand(destBand); }
@Override public void initialize() throws OperatorException { targetProduct = new Product(sourceProduct.getName() + "_MulConst", sourceProduct.getProductType(), sourceProduct.getSceneRasterWidth(), sourceProduct.getSceneRasterHeight()); Band[] bands = sourceProduct.getBands(); for (Band sourceBand : bands) { targetProduct.addBand(sourceBand.getName(), sourceBand.getDataType()); } }
@Override public void initialize() throws OperatorException { targetProduct = new Product(sourceProduct1.getName() + "_Add", sourceProduct1.getProductType(), sourceProduct1.getSceneRasterWidth(), sourceProduct1.getSceneRasterHeight()); Band[] bands = sourceProduct1.getBands(); for (Band sourceBand : bands) { targetProduct.addBand(sourceBand.getName(), sourceBand.getDataType()); } }
private static void assertEquality(Band band1, Band band2) throws IOException { assertEquals(band1.getName(), band2.getName()); assertEquals(band1.getDataType(), band2.getDataType()); assertEquals(band1.getScalingFactor(), band2.getScalingFactor(), 1.0e-6); assertEquals(band1.getScalingOffset(), band2.getScalingOffset(), 1.0e-6); final int width = band1.getRasterWidth(); final int height = band1.getRasterHeight(); band2.readRasterDataFully(ProgressMonitor.NULL); for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { assertEquals(band1.getPixelDouble(i, j), band2.getPixelDouble(i, j), 1.0e-13); } } }