private static Product copyProduct(Product writtenProduct) { Product targetProduct = new Product(writtenProduct.getName(), writtenProduct.getProductType(), writtenProduct.getSceneRasterWidth(), writtenProduct.getSceneRasterHeight()); targetProduct.setStartTime(writtenProduct.getStartTime()); targetProduct.setEndTime(writtenProduct.getEndTime()); ProductUtils.copyMetadata(writtenProduct, targetProduct); ProductUtils.copyGeoCoding(writtenProduct, targetProduct); ProductUtils.copyTiePointGrids(writtenProduct, targetProduct); ProductUtils.copyMasks(writtenProduct, targetProduct); ProductUtils.copyVectorData(writtenProduct, targetProduct); for (Band band : writtenProduct.getBands()) { // Force setting source image, otherwise GPF will set an OperatorImage and invoke computeTile()!! ProductUtils.copyBand(band.getName(), writtenProduct, targetProduct, true); } return targetProduct; }
private void createOutputProduct() throws IOException { String productType = sourceProduct.getProductType() + "_SMAC"; String productName = sourceProduct.getName() + "_SMAC"; int sceneWidth = sourceProduct.getSceneRasterWidth(); int sceneHeight = sourceProduct.getSceneRasterHeight(); targetProduct = new Product(productName, productType, sceneWidth, sceneHeight); // loop over bands and create them // ------------------------------- if (ObjectUtils.equalObjects(sensorType, SensorCoefficientManager.MERIS_NAME)) { addBandsToOutput("Atmosphere corrected MERIS band ", true); } else { addBandsToOutput("Atmosphere corrected band ", false); } ProductUtils.copyTiePointGrids(sourceProduct, targetProduct); // the following line copies the processing request as metadata into the target product. // there is no such mechanism in GPF yet, so it is commented out. // copyRequestMetaData(_outputProduct); ProductUtils.copyFlagBands(sourceProduct, targetProduct, true); // for MERIS FSG / FRG products ProductUtils.copyBand(EnvisatConstants.MERIS_AMORGOS_L1B_CORR_LATITUDE_BAND_NAME, sourceProduct, targetProduct, true); ProductUtils.copyBand(EnvisatConstants.MERIS_AMORGOS_L1B_CORR_LONGITUDE_BAND_NAME, sourceProduct, targetProduct, true); ProductUtils.copyBand(EnvisatConstants.MERIS_AMORGOS_L1B_ALTIUDE_BAND_NAME, sourceProduct, targetProduct, true); ProductUtils.copyGeoCoding(sourceProduct, targetProduct); }
/** * Converts the geographic boundary of the region within the given product into one, two or three shape objects. If * the product does not intersect the 180 degree meridian, a single general path is returned. Otherwise two or three * shapes are created and returned in the order from west to east. * <p/> * This method delegates to {@link #createGeoBoundaryPaths(org.esa.beam.framework.datamodel.Product, java.awt.Rectangle, int, boolean) createGeoBoundaryPaths(Product, Rectangle, int, boolean)} * and the additional parameter <code>usePixelCenter</code> is <code>true</code>. * <p/> * The geographic boundary of the given product are returned as shapes comprising (longitude,latitude) pairs. * * @param product the input product * @param region the region rectangle in product pixel coordinates, can be null for entire product * @param step the step given in pixels * * @return an array of shape objects * * @throws IllegalArgumentException if product is null or if the product's {@link GeoCoding} is null * @see #createGeoBoundary(org.esa.beam.framework.datamodel.Product, java.awt.Rectangle, int) */ public static GeneralPath[] createGeoBoundaryPaths(Product product, Rectangle region, int step) { final boolean usePixelCenter = true; return createGeoBoundaryPaths(product, region, step, usePixelCenter); }
/** * Copies all properties from source product to the target product. * * @param sourceProduct the source product * @param targetProduct the target product */ public static void copyProductNodes(final Product sourceProduct, final Product targetProduct) { ProductUtils.copyMetadata(sourceProduct, targetProduct); ProductUtils.copyTiePointGrids(sourceProduct, targetProduct); ProductUtils.copyFlagCodings(sourceProduct, targetProduct); ProductUtils.copyGeoCoding(sourceProduct, targetProduct); ProductUtils.copyMasks(sourceProduct, targetProduct); ProductUtils.copyVectorData(sourceProduct, targetProduct); ProductUtils.copyIndexCodings(sourceProduct, targetProduct); targetProduct.setStartTime(sourceProduct.getStartTime()); targetProduct.setEndTime(sourceProduct.getEndTime()); targetProduct.setDescription(sourceProduct.getDescription()); }
/** * Creates the output product skeleton. */ private void initOutputProduct() throws IOException, ParseException { if (!EnvisatConstants.MERIS_L1_TYPE_PATTERN.matcher(l1bProduct.getProductType()).matches()) { throw new OperatorException("Product type '" + l1bProduct.getProductType() + "' is not supported." + "It must be a MERIS Level 1b product."); } tempCloudProduct = cloudNode.readProductNodes(l1bProduct, null); targetProduct = cloudNode.createTargetProductImpl(); ProductUtils.copyFlagBands(l1bProduct, targetProduct, true); ProductUtils.copyTiePointGrids(l1bProduct, targetProduct); ProductUtils.copyGeoCoding(l1bProduct, targetProduct); ProductUtils.copyMetadata(l1bProduct, targetProduct); targetProduct.setStartTime(l1bProduct.getStartTime()); targetProduct.setEndTime(l1bProduct.getEndTime()); cloudNode.startProcessing(); getLogger().info("Output product successfully initialised"); }
ProductUtils.copyMetadata(masterProduct, targetProduct); ProductUtils.copyTiePointGrids(masterProduct, targetProduct); final Band targetBand = ProductUtils.copyBand(sourceBand.getName(), masterProduct, targetProduct, true); handleSampleCodings(sourceBand, targetBand, renameMasterComponents, masterComponentPattern); sourceRasterMap.put(targetBand, sourceBand); ProductUtils.copyRasterDataNodeProperties(sourceBand, targetBand); handleSampleCodings(sourceBand, targetBand, renameSlaveComponents, slaveComponentPattern); sourceRasterMap.put(targetBand, sourceBand); ProductUtils.copyRasterDataNodeProperties(sourceGrid, targetBand); sourceRasterMap.put(targetBand, sourceGrid); ProductUtils.copyGeoCoding(masterProduct, targetProduct); copyMasks(slaveProduct, renameSlaveComponents, slaveComponentPattern);
targetProduct.addBand(ndviOutputBand); ProductUtils.copyTiePointGrids(sourceProduct, targetProduct); ProductUtils.copyGeoCoding(sourceProduct, targetProduct); ProductUtils.copyFlagBands(sourceProduct, targetProduct, true); targetProduct.addBand(ndviFlagsOutputBand); ProductUtils.copyMasks(sourceProduct, targetProduct); ProductUtils.copyOverlayMasks(sourceProduct, targetProduct);
final String erroBandName = sourceBands[i].getName() + errorBandNameSuffix; errorBands[i] = targetProduct.addBand(erroBandName, ProductData.TYPE_FLOAT32); ProductUtils.copySpectralBandProperties(sourceBands[i], errorBands[i]); ProductUtils.copyMetadata(sourceProduct, targetProduct); ProductUtils.copyTiePointGrids(sourceProduct, targetProduct); ProductUtils.copyGeoCoding(sourceProduct, targetProduct);
@Override public void initialize() throws OperatorException { collectSourceBands(); int width = sourceProduct.getSceneRasterWidth(); int height = sourceProduct.getSceneRasterHeight(); final String name = sourceProduct.getName() + "_CLUSTERS"; final String type = sourceProduct.getProductType() + "_CLUSTERS"; targetProduct = new Product(name, type, width, height); ProductUtils.copyTiePointGrids(sourceProduct, targetProduct); ProductUtils.copyGeoCoding(sourceProduct, targetProduct); targetProduct.setStartTime(sourceProduct.getStartTime()); targetProduct.setEndTime(sourceProduct.getEndTime()); clusterMapBand = new Band("class_indices", ProductData.TYPE_UINT8, width, height); clusterMapBand.setDescription("Class_indices"); clusterMapBand.setNoDataValue(NO_DATA_VALUE); clusterMapBand.setNoDataValueUsed(true); targetProduct.addBand(clusterMapBand); final IndexCoding indexCoding = new IndexCoding("Cluster_classes"); for (int i = 0; i < clusterCount; i++) { indexCoding.addIndex("class_" + (i + 1), i, "Cluster " + (i + 1)); } targetProduct.getIndexCodingGroup().add(indexCoding); clusterMapBand.setSampleCoding(indexCoding); clusterAnalysis = new MetadataElement("Cluster_Analysis"); targetProduct.getMetadataRoot().addElement(clusterAnalysis); setTargetProduct(targetProduct); }
sourceProduct.getSceneRasterHeight()); ProductUtils.copyTiePointGrids(sourceProduct, flhProduct); ProductUtils.copyGeoCoding(sourceProduct, flhProduct); ProductUtils.copyFlagBands(sourceProduct, flhProduct, true);
ProductUtils.copyTiePointGrids(sourceProduct, targetProduct); ProductUtils.copyGeoCoding(sourceProduct, targetProduct); targetProduct.setStartTime(sourceProduct.getStartTime()); targetProduct.setEndTime(sourceProduct.getEndTime()); ProductUtils.copySpectralBandProperties(sourceBands[i], componentBand); componentBands[i] = componentBand;
@Override public void copyGeoCoding() { ProductUtils.copyGeoCoding(getSourceProduct(), getTargetProduct()); }
/** * Copies the named band from the source product to the target product. * * @param sourceBandName the name of the band to be copied. * @param sourceProduct the source product. * @param targetProduct the target product. * @param copySourceImage whether the source image of the source band should be copied. * * @return the copy of the band, or <code>null</code> if the sourceProduct does not contain a band with the given name. * * @since BEAM 4.10 */ public static Band copyBand(String sourceBandName, Product sourceProduct, Product targetProduct, boolean copySourceImage) { return copyBand(sourceBandName, sourceProduct, sourceBandName, targetProduct, copySourceImage); }
ProductUtils.copyMetadata(sourceProducts[0], targetProduct); ProductUtils.copyGeoCoding(sourceProducts[0], targetProduct); for (Product sourceProduct : sourceProducts) { if (sourceProduct.getStartTime() != null && sourceProduct.getEndTime() != null) {
elevationModel = createElevationModel(); ProductUtils.copyMetadata(sourceProduct, targetProduct); ProductUtils.copyFlagCodings(sourceProduct, targetProduct); copyIndexCoding(); try { reprojectRasterDataNodes(sourceProduct.getTiePointGrids()); ProductUtils.copyVectorData(sourceProduct, targetProduct); ProductUtils.copyMasks(sourceProduct, targetProduct); ProductUtils.copyOverlayMasks(sourceProduct, targetProduct); targetProduct.setAutoGrouping(sourceProduct.getAutoGrouping());
ProductUtils.copyMetadata(sourceProduct, product); ProductUtils.copyMasks(sourceProduct, product); addGeoCodingToProduct(product); ProductUtils.copyVectorData(sourceProduct, product); ProductUtils.copyOverlayMasks(sourceProduct, product); ProductUtils.copyPreferredTileSize(sourceProduct, product); setSceneRasterStartAndStopTime(product); addSubsetInfoMetadata(product);
@Override public void copyMetadata() { ProductUtils.copyMetadata(getSourceProduct(), getTargetProduct()); }
@Override public double evalD(EvalEnv env) throws EvalException { int pixelY = ((RasterDataEvalEnv) env).getPixelY(); ProductData.UTC scanLineTime = ProductUtils.getScanLineTime(product, pixelY); if (scanLineTime != null) { return scanLineTime.getMJD(); } return Double.NaN; } }
private static FilterBand createFilterBand(Filter filter, String bandName, int iterationCount) { RasterDataNode sourceRaster = (RasterDataNode) VisatApp.getApp().getSelectedProductNode(); FilterBand targetBand; Product product = sourceRaster.getProduct(); if (filter.getOperation() == Filter.Operation.CONVOLVE) { targetBand = new ConvolutionFilterBand(bandName, sourceRaster, getKernel(filter), iterationCount); if (sourceRaster instanceof Band) { ProductUtils.copySpectralBandProperties((Band) sourceRaster, targetBand); } } else { GeneralFilterBand.OpType opType = getOpType(filter.getOperation()); targetBand = new GeneralFilterBand(bandName, sourceRaster, opType, getKernel(filter), iterationCount); if (sourceRaster instanceof Band) { ProductUtils.copySpectralBandProperties((Band) sourceRaster, targetBand); } } targetBand.setDescription(String.format("Filter '%s' (=%s) applied to '%s'", filter.getName(), filter.getOperation(), sourceRaster.getName())); if (sourceRaster instanceof Band) { ProductUtils.copySpectralBandProperties((Band) sourceRaster, targetBand); } product.addBand(targetBand); targetBand.fireProductNodeDataChanged(); return targetBand; }
for (String bandName : n1Product.getBandNames()) { if (!"l1_flags".equals(bandName) && !targetProduct.containsBand(bandName)) { ProductUtils.copyBand(bandName, n1Product, targetProduct, false); ProductUtils.copyFlagBands(n1Product, targetProduct, false); try { File originalFileLocation = n1Product.getFileLocation();