private String createValidMaskExpressionForNoDataValue() { final String ref = BandArithmetic.createExternalName(getName()); final double noDataValue = getGeophysicalNoDataValue(); if (Double.isNaN(noDataValue)) { return "!nan(" + ref + ")"; } else if (Double.isInfinite(noDataValue)) { return "!inf(" + ref + ")"; } else { if (ProductData.isIntType(getDataType())) { double rawNoDataValue = getNoDataValue(); String rawSymbol = getName() + ".raw"; String extName = BandArithmetic.createExternalName(rawSymbol); return extName + " != " + rawNoDataValue; } else { return "fneq(" + ref + "," + noDataValue + ")"; } } }
@Override public String toString() { String className = getClass().getSimpleName(); String productName = ""; if (rasterDataNode.getProduct() != null) { productName = ":" + rasterDataNode.getProduct().getName(); } String bandName = "." + rasterDataNode.getName(); return className + productName + bandName; }
private static boolean pixelIsNotInBounds(RasterDataNode raster, int x, int y) { int height = raster.getSceneRasterHeight(); int width = raster.getSceneRasterWidth(); return x < 0 || x >= width || y < 0 || y >= height; } }
public byte[] quantizeRasterData(final double newMin, final double newMax, final double gamma, ProgressMonitor pm) throws IOException { final byte[] colorIndexes = new byte[getSceneRasterWidth() * getSceneRasterHeight()]; quantizeRasterData(newMin, newMax, gamma, colorIndexes, 0, 1, pm); return colorIndexes; }
/** * Creates raster data that is compatible to this dataset's data type. The data buffer returned contains exactly * <code>getBandOutputRasterWidth()*getBandOutputRasterHeight()</code> elements of a compatible data type. * * @return raster data compatible with this product raster * @see #createCompatibleRasterData */ public ProductData createCompatibleSceneRasterData() { return createCompatibleRasterData(getSceneRasterWidth(), getSceneRasterHeight()); }
targetRaster.setDescription(sourceRaster.getDescription()); targetRaster.setUnit(sourceRaster.getUnit()); targetRaster.setScalingFactor(sourceRaster.getScalingFactor()); targetRaster.setScalingOffset(sourceRaster.getScalingOffset()); targetRaster.setLog10Scaled(sourceRaster.isLog10Scaled()); targetRaster.setNoDataValueUsed(sourceRaster.isNoDataValueUsed()); targetRaster.setNoDataValue(sourceRaster.getNoDataValue()); targetRaster.setValidPixelExpression(sourceRaster.getValidPixelExpression()); if (sourceRaster instanceof Band && targetRaster instanceof Band) { Band sourceBand = (Band) sourceRaster;
AbstractTimeSeries timeSeries = timeSeriesMapper.getTimeSeries(view.getProduct()); List<Band> bands = timeSeries.getBandsForVariable( AbstractTimeSeries.rasterToVariableName(view.getRaster().getName())); final KmlFolder folder = new KmlFolder(refRaster.getName(), refRaster.getDescription()); for (RasterDataNode raster : bands) { final GeoCoding geoCoding = raster.getGeoCoding(); final PixelPos upperLeftPP = new PixelPos(0, 0); final PixelPos lowerRightPP = new PixelPos(raster.getSceneRasterWidth(), raster.getSceneRasterHeight()); final GeoPos upperLeftGP = geoCoding.getGeoPos(upperLeftPP, null); final GeoPos lowerRightGP = geoCoding.getGeoPos(lowerRightPP, null); final ImageInfo imageInfo = raster.getImageInfo(ProgressMonitor.NULL); final RenderedImage levelImage = imageManager.createColoredBandImage(new RasterDataNode[]{raster}, imageInfo, level); final String name = raster.getName(); final KmlGroundOverlay groundOverlay = new KmlGroundOverlay(name, levelImage, referencedEnvelope, startTime, endTime); groundOverlay.setIconName(name + raster.getProduct().getRefNo()); folder.addChild(groundOverlay);
private void reprojectSourceRaster(RasterDataNode sourceRaster) { final int targetDataType; MultiLevelImage sourceImage; if (sourceRaster.isScalingApplied()) { targetDataType = sourceRaster.getGeophysicalDataType(); sourceImage = sourceRaster.getGeophysicalImage(); } else { targetDataType = sourceRaster.getDataType(); sourceImage = sourceRaster.getSourceImage(); final Band targetBand = targetProduct.addBand(sourceRaster.getName(), targetDataType); targetBand.setLog10Scaled(sourceRaster.isLog10Scaled()); targetBand.setNoDataValue(targetNoDataValue.doubleValue()); targetBand.setNoDataValueUsed(true); targetBand.setDescription(sourceRaster.getDescription()); targetBand.setUnit(sourceRaster.getUnit()); final String exp = sourceRaster.getValidMaskExpression(); if (exp != null) { sourceImage = createNoDataReplacedImage(sourceRaster, targetNoDataValue);
public static void writeCfBandAttributes(RasterDataNode rasterDataNode, NVariable variable) throws IOException { final String description = rasterDataNode.getDescription(); if (description != null) { variable.addAttribute("long_name", description); String unit = rasterDataNode.getUnit(); if (unit != null) { unit = CfCompliantUnitMapper.tryFindUnitString(unit); if (!rasterDataNode.isLog10Scaled()) { final double scalingFactor = rasterDataNode.getScalingFactor(); if (scalingFactor != 1.0) { variable.addAttribute(Constants.SCALE_FACTOR_ATT_NAME, scalingFactor); final double scalingOffset = rasterDataNode.getScalingOffset(); if (scalingOffset != 0.0) { variable.addAttribute(Constants.ADD_OFFSET_ATT_NAME, scalingOffset); noDataValue = rasterDataNode.getNoDataValue(); } else { noDataValue = rasterDataNode.getGeophysicalNoDataValue(); if (rasterDataNode.isNoDataValueUsed()) { Number fillValue = DataTypeUtils.convertTo(noDataValue, variable.getDataType()); variable.addAttribute(Constants.FILL_VALUE_ATT_NAME, fillValue);
public void testSetRawNoDataValue_SetNoDataValue_UByte_WithScalingLikeAlgal_MER_RR__2P() { short noDataValue; double geophysNoDataValue; initNode(ProductData.TYPE_UINT8, 0.023622047156095505, -3.0236220359802246, true); noDataValue = 214; _node.setNoDataValue(noDataValue); geophysNoDataValue = _node.getGeophysicalNoDataValue(); _node.setGeophysicalNoDataValue(4f); _node.setGeophysicalNoDataValue(geophysNoDataValue); assertEquals("Expected "+ noDataValue+" but was " + _node.getNoDataValue(), true, noDataValue == _node.getNoDataValue()); noDataValue = 120; _node.setNoDataValue(noDataValue); geophysNoDataValue = _node.getGeophysicalNoDataValue(); _node.setGeophysicalNoDataValue(4f); _node.setGeophysicalNoDataValue(geophysNoDataValue); assertEquals("Expected "+ noDataValue+" but was " + _node.getNoDataValue(), true, noDataValue == _node.getNoDataValue()); }
public static MultiLevelImage createMaskedGeophysicalImage(final RasterDataNode node, Number maskValue) { MultiLevelImage varImage = node.getGeophysicalImage(); if (node.getValidPixelExpression() != null) { varImage = replaceInvalidValuesByNaN(node, varImage, node.getValidMaskImage(), maskValue); } else if (node.isNoDataValueSet() && node.isNoDataValueUsed() && Double.compare(maskValue.doubleValue(), node.getGeophysicalNoDataValue()) != 0) { varImage = replaceNoDataValueByNaN(node, varImage, node.getGeophysicalNoDataValue(), maskValue); } return varImage; }
@Override public RenderedImage createImage(int level) { return VirtualBandOpImage.create(expression, associatedNode.getDataType(), associatedNode.isNoDataValueUsed() ? associatedNode.getGeophysicalNoDataValue() : null, associatedNode.getProduct(), ResolutionLevel.create(getModel(), level)); } };
private static String formatKML(ProductSceneView view, String imageName) { final RasterDataNode raster = view.getRaster(); final Product product = raster.getProduct(); final GeoCoding geoCoding = raster.getGeoCoding(); final PixelPos upperLeftPP = new PixelPos(0, 0); final PixelPos lowerRightPP = new PixelPos(product.getSceneRasterWidth(), description = parent.getTitle() + "\n" + product.getName(); } else { name = raster.getName(); description = raster.getDescription() + "\n" + product.getName(); legendKml = " <ScreenOverlay>\n" + " <name>Legend</name>\n"
public static ImageLayout createSingleBandedImageLayout(RasterDataNode rasterDataNode, int dataBufferType) { int width = rasterDataNode.getSceneRasterWidth(); int height = rasterDataNode.getSceneRasterHeight(); Dimension tileSize = getPreferredTileSize(rasterDataNode.getProduct()); return createSingleBandedImageLayout(dataBufferType, width, height, tileSize.width, tileSize.height); }
final String renamedExpression = "ident_1 + newIdent - ident_3"; final RasterDataNode node = createRasterDataNode(); node.setValidPixelExpression(initialExpression); final int width = node.getSceneRasterWidth(); final int height = node.getSceneRasterHeight(); final boolean[] isActive = {false}; final Product product = new Product("n", "t", width, height) { addRasterDataNodeToProduct(product, node); product.setModified(false); assertFalse(node.isModified()); assertEquals(initialExpression, node.getValidPixelExpression()); node.updateExpression(oldIdentifier, newIdentifier); assertTrue(node.isModified()); assertEquals(renamedExpression, node.getValidPixelExpression());
private static void writeBandNames(PrintWriter out, RasterDataNode rasterDataNode) { assert rasterDataNode != null; out.println("band names = { " + rasterDataNode.getName() + " }"); }
private boolean isNoDataValue(double sample) { final RasterDataNode rasterDataNode = tile.getRasterDataNode(); if (rasterDataNode.isNoDataValueUsed()) { if (rasterDataNode.isScalingApplied()) { return rasterDataNode.getGeophysicalNoDataValue() == sample; } else { return rasterDataNode.getNoDataValue() == sample; } } return false; } }
protected RasterDataNodeOpImage(RasterDataNode rasterDataNode, ResolutionLevel level) { super(ImageManager.getDataBufferType(rasterDataNode.getDataType()), rasterDataNode.getSceneRasterWidth(), rasterDataNode.getSceneRasterHeight(), getPreferredTileSize(rasterDataNode), null, level); this.rasterDataNode = rasterDataNode; }
private static int getProductIndex(Product[] products, RasterDataNode raster) { int productIndex = -1; for (int i = 0; i < products.length; i++) { Product product = products[i]; if (product == raster.getProduct()) { productIndex = i; break; } } return productIndex; }
private static void writedescription(PrintWriter out, RasterDataNode rasterDataNode) { assert rasterDataNode != null; String description = rasterDataNode.getDescription(); String unit = rasterDataNode.getUnit(); if (unit == null || unit.trim().length() == 0) { unit = "1"; if (rasterDataNode.isLog10Scaled()) { unit = "log(" + unit + ")"; description = rasterDataNode.getProduct().getDescription();