热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

band偏移量java_JavaBand.setScalingOffset方法代码示例

importorg.esa.snap.core.datamodel.Band;导入方法依赖的package包类OverrideprotectedvoidaddBands(Produ

import org.esa.snap.core.datamodel.Band; //导入方法依赖的package包/类

@Override

protected void addBands(Product product, SpotDimapMetadata componentMetadata, int componentIndex) {

String[] bandNames = componentMetadata.getBandNames();

String[] bandUnits = componentMetadata.getBandUnits();

int width, height, currentW, currentH;

width = product.getSceneRasterWidth();

height = product.getSceneRasterHeight();

currentW = componentMetadata.getRasterWidth();

currentH = componentMetadata.getRasterHeight();

if (width == currentW && height == currentH) {

try {

if (SpotConstants.DIMAP.equals(componentMetadata.getFormatName())) {

String[] fileNames = componentMetadata.getRasterFileNames();

if (fileNames == null || fileNames.length == 0) {

throw new InvalidMetadataException("No raster file found in metadata");

}

String rasterFileName = componentMetadata.getPath().toLowerCase().replace(componentMetadata.getFileName().toLowerCase(), fileNames[0].toLowerCase());

File rasterFile = productDirectory.getFile(rasterFileName);

GeoTiffProductReader tiffReader = new GeoTiffReaderEx(getReaderPlugIn());

logger.info("Read product nodes");

Product tiffProduct = tiffReader.readProductNodes(rasterFile, null);

if (tiffProduct != null) {

if (product == null) {

product = createProduct(tiffProduct.getSceneRasterWidth(), tiffProduct.getSceneRasterHeight(), wrappingMetadata.getComponentMetadata(0));

}

MetadataElement tiffMetadata = tiffProduct.getMetadataRoot();

if (tiffMetadata != null) {

XmlMetadata.CopyChildElements(tiffMetadata, product.getMetadataRoot());

}

tiffProduct.transferGeoCodingTo(product, null);

product.setPreferredTileSize(tiffProduct.getPreferredTileSize());

int numBands = tiffProduct.getNumBands();

String bandPrefix = "";

logger.info("Read bands");

if (wrappingMetadata.hasMultipleComponents()) {

bandPrefix = "scene_" + String.valueOf(componentIndex) + "_";

String groupPattern = "";

for (int idx = 0; idx

groupPattern += "scene_" + String.valueOf(idx) + ":";

}

groupPattern = groupPattern.substring(0, groupPattern.length() - 1);

product.setAutoGrouping(groupPattern);

}

for (int idx = 0; idx

Band srcBand = tiffProduct.getBandAt(idx);

String bandName = bandPrefix + (idx

Band targetBand = new ColorPaletteBand(bandName, srcBand.getDataType(), product.getSceneRasterWidth(), product.getSceneRasterHeight(), this.colorPaletteFilePath);

targetBand.setNoDataValue(componentMetadata.getNoDataValue() > -1 ? componentMetadata.getNoDataValue() : srcBand.getNoDataValue());

targetBand.setNoDataValueUsed((componentMetadata.getNoDataValue() > -1));

targetBand.setSpectralWavelength(componentMetadata.getWavelength(idx) > 0 ? componentMetadata.getWavelength(idx) : srcBand.getSpectralWavelength());

targetBand.setSpectralBandwidth(componentMetadata.getBandwidth(idx) > 0 ? componentMetadata.getBandwidth(idx) : srcBand.getSpectralBandwidth());

targetBand.setScalingFactor(srcBand.getScalingFactor());

targetBand.setScalingOffset(srcBand.getScalingOffset());

targetBand.setSolarFlux(srcBand.getSolarFlux());

targetBand.setUnit(srcBand.getUnit() != null ? srcBand.getUnit() : bandUnits[idx]);

targetBand.setSampleCoding(srcBand.getSampleCoding());

targetBand.setImageInfo(srcBand.getImageInfo());

targetBand.setSpectralBandIndex(srcBand.getSpectralBandIndex());

targetBand.setDescription(bandName);

product.addBand(targetBand);

readBandStatistics(targetBand, idx, componentMetadata);

bandMap.put(targetBand, srcBand);

}

}

} else {

logger.warning(String.format("Component product %s is not in DIMAP format!", componentMetadata.getProductName()));

}

} catch (IOException ioEx) {

logger.severe("Error while reading component: " + ioEx.getMessage());

}

} else {

logger.warning(String.format("Cannot add component product %s due to raster size [Found: %d x %d pixels, Expected: %d x %d pixels]",

componentMetadata.getProductName(), currentW, currentH, width, height));

}

}



推荐阅读
author-avatar
手机用户2602922383_687
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有