public static void setNewBandProperties(Band band, String description, String unit, double noDataValue, boolean useNoDataValue) { band.setDescription(description); band.setUnit(unit); band.setNoDataValue(noDataValue); band.setNoDataValueUsed(useNoDataValue); }
private synchronized void getElevationModel() throws Exception { if (isElevationModelAvailable) return; dem = DEMFactory.createElevationModel(demName, demResamplingMethod); demNoDataValue = dem.getDescriptor().getNoDataValue(); elevationBand.setNoDataValue(demNoDataValue); elevationBand.setNoDataValueUsed(true); isElevationModelAvailable = true; }
private Band createBand(String bandName, String description, String unit) { Band band = targetProduct.addBand(bandName, ProductData.TYPE_FLOAT32); band.setDescription(description); band.setUnit(unit); band.setNoDataValue(-9999.); band.setNoDataValueUsed(true); return band; }
private static void configureBand(Band band05X, ImageInfo imageInfo, String unit, String description) { band05X.setUnit(unit); band05X.setDescription(description); band05X.setImageInfo(imageInfo); band05X.setNoDataValue(Double.NaN); band05X.setNoDataValueUsed(true); }
private void setBandProperties(Band band, String validMaskExpression) { band.setDescription(bandDescription); band.setUnit(bandUnit); band.setSpectralWavelength(bandWavelength); band.setGeophysicalNoDataValue(noDataValue); band.setNoDataValueUsed(noDataValueUsed); band.setValidPixelExpression(validMaskExpression); }
public static Band createTargetBand(AotConsts bandFeat, int rasterWidth, int rasterHeight) { Band targetBand = new Band(bandFeat.name, bandFeat.type, rasterWidth, rasterHeight); targetBand.setDescription(bandFeat.description); targetBand.setNoDataValue(bandFeat.noDataValue); targetBand.setNoDataValueUsed(bandFeat.noDataUsed); targetBand.setUnit(bandFeat.unit); targetBand.setScalingFactor(bandFeat.scale); targetBand.setScalingOffset(bandFeat.offset); return targetBand; }
protected Band createBand(final Product product, String name, final String unit, final int bitsPerSample) { int dataType = ProductData.TYPE_UINT16; if (bitsPerSample == 16) { dataType = isProductSLC ? ProductData.TYPE_INT16 : ProductData.TYPE_UINT16; } else if (bitsPerSample == 32) { dataType = ProductData.TYPE_FLOAT32; } else if (bitsPerSample == 8) { dataType = isProductSLC ? ProductData.TYPE_INT8 : ProductData.TYPE_UINT8; } if(product.getBand(name) != null) { int cnt = 0; for(String bandName : product.getBandNames()) { if(bandName.startsWith(name)) { ++cnt; } } name += "_" + cnt; } final Band band = new Band(name, dataType, sceneWidth, sceneHeight); band.setDescription(name); band.setUnit(unit); band.setNoDataValue(0); band.setNoDataValueUsed(true); product.addBand(band); return 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<>())); } }
private void addDeltaBands() { final Band deltaLonBand = targetProduct.addBand("delta_lon_angular", "longitude - LON"); deltaLonBand.setUnit("deg"); deltaLonBand.setDescription("Delta between old longitude and new longitude in degree"); deltaLonBand.setNoDataValueUsed(true); deltaLonBand.setNoDataValue(noDataValue == null ? Double.NaN : noDataValue); deltaLonBand.setImageInfo(createDeltaBandImageInfo(-0.015, +0.015)); final Band deltaLatBand = targetProduct.addBand("delta_lat_angular", "latitude - LAT"); deltaLatBand.setUnit("deg"); deltaLatBand.setDescription("Delta between old latitude and new latitude in degree"); deltaLatBand.setNoDataValueUsed(true); deltaLatBand.setNoDataValue(noDataValue == null ? Double.NaN : noDataValue); deltaLatBand.setImageInfo(createDeltaBandImageInfo(-0.01, +0.01)); final Band deltaLonMetBand = targetProduct.addBand("delta_lon_metric", "cos(rad(LAT)) * 6378137 * rad(longitude - LON)"); deltaLonMetBand.setUnit("m"); deltaLonMetBand.setDescription("Delta between old longitude and new longitude in meters"); deltaLonMetBand.setNoDataValueUsed(true); deltaLonMetBand.setNoDataValue(noDataValue == null ? Double.NaN : noDataValue); deltaLonMetBand.setImageInfo(createDeltaBandImageInfo(-1500.0, +1500.0)); final Band deltaLatMetBand = targetProduct.addBand("delta_lat_metric", "6378137 * rad(latitude - LAT)"); deltaLatMetBand.setUnit("m"); deltaLatMetBand.setDescription("Delta between old latitude and new latitude in meters"); deltaLatMetBand.setNoDataValueUsed(true); deltaLatMetBand.setNoDataValue(noDataValue == null ? Double.NaN : noDataValue); deltaLatMetBand.setImageInfo(createDeltaBandImageInfo(-1000.0, +1000.0)); }
@Override protected void configureTargetProduct(ProductConfigurer productConfigurer) { super.configureTargetProduct(productConfigurer); final Band lineHeightBand = productConfigurer.addBand(lineHeightBandName, ProductData.TYPE_FLOAT32); final Band signalBand = sourceProduct.getBand(signalBandName); lineHeightBand.setUnit(signalBand.getUnit()); lineHeightBand.setDescription("Line height band"); lineHeightBand.setNoDataValueUsed(true); lineHeightBand.setNoDataValue(invalidMciValue); ProductUtils.copySpectralBandProperties(signalBand, lineHeightBand); if (slope) { final Band slopeBand = productConfigurer.addBand(slopeBandName, ProductData.TYPE_FLOAT32); slopeBand.setUnit(signalBand.getUnit() + " nm-1"); slopeBand.setDescription("Baseline slope band"); slopeBand.setNoDataValueUsed(true); slopeBand.setNoDataValue(invalidMciValue); } ProductUtils.copyFlagBands(sourceProduct, productConfigurer.getTargetProduct(), true); }
private void addAOTImage(Product product, String pathString) { Band srcBand = getTifBand(pathString, 1); if (srcBand == null) { logger.warning(String.format("Image %s not added", pathString)); return; } MuscateMetadata.Geoposition geoposition = getGeoposition(srcBand.getRasterWidth(), srcBand.getRasterHeight()); if (geoposition == null) { logger.warning(String.format("Unrecognized geometry of image %s, it will not be added to the product %s.", pathString, product.getName())); return; } String bandName = "AOT_" + geoposition.id; Band targetBand = new Band(bandName, srcBand.getDataType(), srcBand.getRasterWidth(), srcBand.getRasterHeight()); product.addBand(targetBand); ProductUtils.copyGeoCoding(srcBand, targetBand); targetBand.setNoDataValue(metadata.getAOTNoDataValue()); targetBand.setNoDataValueUsed(true); targetBand.setScalingFactor(1.0d / metadata.getAOTQuantificationValue()); targetBand.setScalingOffset(0.0d); targetBand.setSampleCoding(srcBand.getSampleCoding()); targetBand.setImageInfo(srcBand.getImageInfo()); targetBand.setDescription(String.format("Aerosol Optical Thickness at %.0fm resolution", geoposition.xDim)); targetBand.setSourceImage(srcBand.getSourceImage()); }
private static void addElevationBand(Product product, ElevationModel dem, String elevationBandName) { final GeoCoding geoCoding = product.getSceneGeoCoding(); ElevationModelDescriptor demDescriptor = dem.getDescriptor(); final float noDataValue = dem.getDescriptor().getNoDataValue(); final Band elevationBand = product.addBand(elevationBandName, ProductData.TYPE_FLOAT32); elevationBand.setNoDataValueUsed(true); elevationBand.setNoDataValue(noDataValue); elevationBand.setUnit(Unit.METERS); elevationBand.setDescription(demDescriptor.getName()); elevationBand.setSourceImage(createElevationSourceImage(dem, geoCoding, elevationBand)); }
private void addWVCImage(Product product, String pathString) { Band srcBand = getTifBand(pathString, 0); if (srcBand == null) { logger.warning(String.format("Image %s not added", pathString)); return; } MuscateMetadata.Geoposition geoposition = getGeoposition(srcBand.getRasterWidth(), srcBand.getRasterHeight()); if (geoposition == null) { logger.warning(String.format("Unrecognized geometry of image %s, it will not be added to the product %s.", pathString, product.getName())); return; } String bandName = "WVC_" + geoposition.id; Band targetBand = new Band(bandName, srcBand.getDataType(), srcBand.getRasterWidth(), srcBand.getRasterHeight()); product.addBand(targetBand); ProductUtils.copyGeoCoding(srcBand, targetBand); targetBand.setNoDataValue(metadata.getWVCNoDataValue()); targetBand.setNoDataValueUsed(true); targetBand.setScalingFactor(1.0d / metadata.getWVCQuantificationValue()); targetBand.setScalingOffset(0.0d); targetBand.setUnit("cm"); //TODO verify targetBand.setSampleCoding(srcBand.getSampleCoding()); targetBand.setImageInfo(srcBand.getImageInfo()); targetBand.setDescription(String.format("Water vapor content at %.0fm resolution in %s", geoposition.xDim, targetBand.getUnit())); targetBand.setSourceImage(srcBand.getSourceImage()); }
/** * Add bands to the target product. * * @throws OperatorException The exception. */ private void addSelectedBands() throws OperatorException { final String[] targetBandNames = polDecomp.getTargetBandNames(); for (final PolBandUtils.PolSourceBand bandList : srcBandList) { final Band[] targetBands = new Band[targetBandNames.length]; int i = 0; for (String targetBandName : targetBandNames) { final Band targetBand = new Band(targetBandName + bandList.suffix, ProductData.TYPE_FLOAT32, targetProduct.getSceneRasterWidth(), targetProduct.getSceneRasterHeight()); polDecomp.setBandUnit(targetBandName + bandList.suffix, targetBand); targetBand.setNoDataValueUsed(true); targetBand.setNoDataValue(0); targetProduct.addBand(targetBand); targetBands[i++] = targetBand; } bandList.addTargetBands(targetBands); } }
public static Band createBand(final Variable variable, final int rasterWidth, final int rasterHeight, int dataType) { final NcAttributeMap attMap = NcAttributeMap.create(variable); final Band band = new Band(variable.getShortName(), (dataType == ProductData.TYPE_UNDEFINED) ? getRasterDataType(variable) : dataType, rasterWidth, rasterHeight); band.setDescription(getDescription(variable, attMap)); band.setUnit(getUnit(variable, attMap)); band.setScalingFactor(getScalingFactor(attMap)); band.setScalingOffset(getAddOffset(attMap)); final Number noDataValue = getNoDataValue(attMap); if (noDataValue != null) { band.setNoDataValue(noDataValue.doubleValue()); band.setNoDataValueUsed(true); } return band; }
private Band addBand(final Product product, String name, final int w, final int h, final ImageIOFile img, final int bandIndex, final String unit) throws IOException { File bandFile = getFile(img.getName()); ProductReader reader = geotiffPlugIn.createReaderInstance(); Product bandProduct = reader.readProductNodes(bandFile, null); if (bandProduct != null) { bandProducts.add(bandProduct); Band srcBand = bandProduct.getBandAt(bandIndex); if (product.containsBand(name)) { name += "2"; } Band band = new Band(name, srcBand.getDataType(), w, h); band.setNoDataValue(0); band.setNoDataValueUsed(true); band.setUnit(unit); band.setSourceImage(srcBand.getSourceImage()); product.addBand(band); return band; } return null; }
@Test public void testCreateTransectProfileText_Byte() throws IOException { final Product product = new Product("X", "Y", 2, 1); Band node = product.addBand("name", ProductData.TYPE_INT8); node.setSynthetic(true); node.setNoDataValue(0); node.setNoDataValueUsed(true); final byte[] data = new byte[product.getSceneRasterWidth() * product.getSceneRasterHeight()]; Arrays.fill(data, (byte) 1); data[0] = 0; // no data node.setData(ProductData.createInstance(data)); final Line2D.Float shape = new Line2D.Float(0.5f, 0.5f, 1.5f, 0.5f); final TransectProfileData profileData = node.createTransectProfileData(shape); final String profileDataString = StatisticsUtils.TransectProfile.createTransectProfileText(node, profileData); assertTrue(profileDataString.contains("NaN")); assertFalse(profileDataString.toLowerCase().contains("no data")); }
private void createTargetProduct() { try { double pixelSpacingInMeter = Math.max(SARGeocoding.getAzimuthPixelSpacing(sourceProduct), SARGeocoding.getRangePixelSpacing(sourceProduct)); double pixelSpacingInDegree = SARGeocoding.getPixelSpacingInDegree(pixelSpacingInMeter); final CRSGeoCodingHandler crsHandler = new CRSGeoCodingHandler(sourceProduct, mapProjection, pixelSpacingInDegree, pixelSpacingInMeter); targetProduct = new Product(bandName, sourceProduct.getProductType(), crsHandler.getTargetWidth(), crsHandler.getTargetHeight()); targetProduct.setSceneGeoCoding(crsHandler.getCrsGeoCoding()); elevationBand = new Band(bandName, ProductData.TYPE_FLOAT32, crsHandler.getTargetWidth(), crsHandler.getTargetHeight()); elevationBand.setUnit(Unit.METERS); elevationBand.setNoDataValue(0); //todo get dem no data value elevationBand.setNoDataValueUsed(true); targetProduct.addBand(elevationBand); } catch (Exception e) { throw new OperatorException(e); } }
@Override protected void configureTargetProduct(ProductConfigurer productConfigurer) { super.configureTargetProduct(productConfigurer); String[] names = getSourceProduct().getBandNames(); for (String name : names) { ProductUtils.copyBand(name, getSourceProduct(), getTargetProduct(), true); ProductUtils.copyGeoCoding(getSourceProduct().getRasterDataNode(name), getTargetProduct().getRasterDataNode(name)); } productConfigurer.copyMasks(); productConfigurer.copyMetadata(); productConfigurer.copyVectorData(); final Band waterVapourBand = productConfigurer.addBand(WATER_VAPOUR_BAND_NAME, ProductData.TYPE_FLOAT32); waterVapourBand.setNoDataValue(WV_NO_DATA_VALUE); waterVapourBand.setNoDataValueUsed(true); waterVapourBand.setUnit("kg/m^2"); }
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()); }