protected FlagCoding createFlagCoding(Product product) { FlagCoding flagCoding = new FlagCoding("unusable_data"); flagCoding.addFlag(RapidEyeConstants.FLAG_BLACK_FILL, 1, "area was not imaged by spacecraft"); flagCoding.addFlag(RapidEyeConstants.FLAG_CLOUDS, 2, "cloud covered"); flagCoding.addFlag(RapidEyeConstants.FLAG_MISSING_BLUE_DATA, 4, "missing/suspect data in blue band"); flagCoding.addFlag(RapidEyeConstants.FLAG_MISSING_GREEN_DATA, 8, "missing/suspect data in green band"); flagCoding.addFlag(RapidEyeConstants.FLAG_MISSING_RED_DATA, 16, "missing/suspect data in red band"); flagCoding.addFlag(RapidEyeConstants.FLAG_MISSING_RED_EDGE_DATA, 32, "missing/suspect data in red edge band"); flagCoding.addFlag(RapidEyeConstants.FLAG_MISSING_NIR_DATA, 64, "missing/suspect data in nir band"); product.getFlagCodingGroup().add(flagCoding); return flagCoding; }
protected List<Mask> createMasksFromFlagCodding(Product product, FlagCoding flagCoding) { String flagCodingName = flagCoding.getName(); ArrayList<Mask> masks = new ArrayList<>(); final int width = product.getSceneRasterWidth(); final int height = product.getSceneRasterHeight(); for (String flagName : flagCoding.getFlagNames()) { MetadataAttribute flag = flagCoding.getFlag(flagName); masks.add(Mask.BandMathsType.create(flagName, flag.getDescription(), width, height, flagCodingName + "." + flagName, ColorIterator.next(), 0.5)); } return masks; }
private int getFlagRowCount() { int rowCount = 0; for (Band band : currentFlagBands) { rowCount += band.getFlagCoding().getNumAttributes(); } return rowCount; }
private FlagCoding initFlagCoding() { flagCoding = new FlagCoding(FLAGS_BAND_NAME); flagCoding.setDescription("Index Flag Coding"); addFlagDescriptor(ARITHMETIC_FLAG_NAME, ARITHMETIC_FLAG_VALUE, "Value calculation failed due to an arithmetic exception"); addFlagDescriptor(LOW_FLAG_NAME, LOW_FLAG_VALUE, "Index value is too low"); addFlagDescriptor(HIGH_FLAG_NAME, HIGH_FLAG_VALUE, "Index value is too high"); return flagCoding; }
String[] flagNames = srcFC.getFlagNames(); FlagCoding contextFC = new FlagCoding(flagCodingName); for (String flagName : flagNames) { contextFC.addFlag(flagName, srcFC.getFlagMask(flagName), srcFC.getFlag(flagName).getDescription()); Band contextBand = contextProduct.addBand(srcBand.getName(), srcBand.getDataType()); if (srcBand.isFlagBand()) { contextBand.setSampleCoding(contextProduct.getFlagCodingGroup().get(srcBand.getFlagCoding().getName()));
public static void createFlagMasks(Product targetProduct) { Guardian.assertNotNull("targetProduct", targetProduct); int w = targetProduct.getSceneRasterWidth(); int h = targetProduct.getSceneRasterHeight(); MyMaskColor mColor = new MyMaskColor(); ProductNodeGroup<Mask> tarMG = targetProduct.getMaskGroup(); ProductNodeGroup<FlagCoding> tarFCG = targetProduct.getFlagCodingGroup(); for (int node=0; node<tarFCG.getNodeCount(); node++){ FlagCoding fc = tarFCG.get(node); for (int i=0; i<fc.getNumAttributes(); i++){ MetadataAttribute f = fc.getAttributeAt(i); String expr = fc.getName() + "." + f.getName(); Mask m = Mask.BandMathsType.create(f.getName(), f.getDescription(), w, h, expr, mColor.next(), 0.5); tarMG.add(m); } } }
private void copyBands(Product sourceProduct, Product targetProduct) { Guardian.assertNotNull("source", sourceProduct); Guardian.assertNotNull("target", targetProduct); ProductNodeGroup<FlagCoding> targetFCG = targetProduct.getFlagCodingGroup(); for (int iBand = 0; iBand < sourceProduct.getNumBands(); iBand++) { Band sourceBand = sourceProduct.getBandAt(iBand); if (!targetProduct.containsBand(sourceBand.getName())) { Band targetBand = copyBandScl(sourceBand.getName(), sourceProduct, sourceBand.getName(), targetProduct); if (sourceBand.isFlagBand()) { FlagCoding flgCoding = sourceBand.getFlagCoding(); if (!targetFCG.contains(flgCoding.getName())) { ProductUtils.copyFlagCoding(flgCoding, targetProduct); } if (targetBand != null) { targetBand.setSampleCoding(targetFCG.get(flgCoding.getName())); } } } } }
private void resetFlagTableModel() { flagModel.clear(); if (currentRaster != null) { for (Band band : currentFlagBands) { // currentFlagBands is already filtered for "equals size" in registerFlagDatasets final FlagCoding flagCoding = band.getFlagCoding(); final int numFlags = flagCoding.getNumAttributes(); final String bandNameDot = band.getName() + "."; for (int j = 0; j < numFlags; j++) { String name = bandNameDot + flagCoding.getAttributeAt(j).getName(); flagModel.addRow(name, "", ""); } } } }
final IndexCoding sourceIndexCoding = sourceBand.getIndexCoding(); if (sourceFlagCoding != null) { final String flagCodingName = sourceFlagCoding.getName(); final FlagCoding destFlagCoding = targetProduct.getFlagCodingGroup().get(flagCodingName); targetBand.setSampleCoding(destFlagCoding);
for (int j = 0; j < band.getFlagCoding().getNumAttributes(); j++) { if (available) { MetadataAttribute attribute = band.getFlagCoding().getAttributeAt(j); final ProductData flagData = attribute.getData(); final long flagMask;
/** * Creates the flags for the diverse masks (snow, water); the flags are: * <ul><li>no diverse data</li></ul> * <ul><li>water</li></ul> * <ul><li>snow</li></ul> * <ul><li>Sun too low for terrain correction (limitation of correction factor that tends to the infinity, correction is false)</li></ul> * <ul><li>Sun too low for terrain correction (correction might be inaccurate)</li></ul> * * @param outputProduct the products on which the flagCoding containing the flags is added * @return the flagCoding created with the saturated flags, and added to the */ FlagCoding createDiverseFlagCoding(Product outputProduct) { String bandName = SpotConstants.SPOT4_TAKE5_TAG_DIVERSE; FlagCoding flagCoding = new FlagCoding(bandName); flagCoding.addFlag("no_div_data", 1, "no diverse data"); flagCoding.addFlag("water", 2, "water"); flagCoding.addFlag("snow", 4, "snow"); flagCoding.addFlag("false_correction", 8, "Sun too low for terrain correction (limitation of correction factor that tends to the infinity, correction is false)"); flagCoding.addFlag("inaccurate_correction", 16, "Sun too low for terrain correction (correction might be inaccurate)"); outputProduct.getFlagCodingGroup().add(flagCoding); return flagCoding; }
/** * Creates and adds masks to the product, by using the given flag coding. Each added mask uses the width and the height of the product. * * @param product the product on which the masks are added * @param flagCoding for each flag of this flagCoding parameter, a new mask is added, with the same name as the flag * @return the list of all the masks added to the product */ List<Mask> createMasksFromFlagCodding(Product product, FlagCoding flagCoding) { String flagCodingName = flagCoding.getName(); ArrayList<Mask> masks = new ArrayList<Mask>(); final int width = product.getSceneRasterWidth(); final int height = product.getSceneRasterHeight(); for (String flagName : flagCoding.getFlagNames()) { MetadataAttribute flag = flagCoding.getFlag(flagName); masks.add(Mask.BandMathsType.create(flagName, flag.getDescription(), width, height, flagCodingName + "." + flagName, ColorIterator.next(), 0.5)); } return masks; }
/** * Creates the flags for the clouds mask; the flags are: * <ul><li>all clouds (except thin ones) or shadows</li></ul> * <ul><li>all clouds (except thin ones)</li></ul> * <ul><li>cloud detected through absolute threshold</li></ul> * <ul><li>cloud detected through multi-t threshold</li></ul> * <ul><li>very thin clouds</li></ul> * <ul><li>high clouds detected with 1.38 µm band (LANDSAT 8 only)</li></ul> * <ul><li>cloud shadows matched with a cloud</li></ul> * <ul><li>cloud shadows in the zone where clouds could be outside the image (less reliable)</li></ul> * * @param outputProduct the products on which the flagCoding containing the flags is added * @return the flagCoding created with the clouds flags, and added to the product */ FlagCoding createCloudsFlagCoding(Product outputProduct) { String bandName = SpotConstants.SPOT4_TAKE5_TAG_CLOUDS; FlagCoding flagCoding = new FlagCoding(bandName); flagCoding.addFlag("clouds_or_shadows", 1, "all clouds (except thin ones) or shadows"); flagCoding.addFlag("clouds", 2, "all clouds (except thin ones)"); flagCoding.addFlag("cloud_absolute_threshold", 4, "cloud detected through absolute threshold"); flagCoding.addFlag("cloud_multi_t_threshold", 8, "cloud detected through multi-t threshold"); flagCoding.addFlag("thin_clouds", 16, "very thin clouds"); flagCoding.addFlag("clouds_1.38band", 32, "high clouds detected with 1.38 µm band (LANDSAT 8 only)"); flagCoding.addFlag("shadows_matched_clouds", 64, "cloud shadows matched with a cloud"); flagCoding.addFlag("shadows_for_clouds_outside", 128, "cloud shadows in the zone where clouds could be outside the image (less reliable)"); outputProduct.getFlagCodingGroup().add(flagCoding); return flagCoding; }
/** * Creates the flags for the saturation mask; the flags are: * <ul><li>XS1 band is saturated</li></ul> * <ul><li>XS2 band is saturated</li></ul> * <ul><li>XS3 band is saturated</li></ul> * <ul><li>SWIR band is saturated</li></ul> * * @param outputProduct the products on which the flagCoding containing the flags is added * @return the flagCoding created with the saturated flags, and added to the product */ FlagCoding createSaturatedFlagCoding(Product outputProduct) { String bandName = SpotConstants.SPOT4_TAKE5_TAG_SATURATION; FlagCoding flagCoding = new FlagCoding(bandName); flagCoding.addFlag("XS1_saturated", 1, "XS1 band is saturated"); flagCoding.addFlag("XS2_saturated", 2, "XS2 band is saturated"); flagCoding.addFlag("XS3_saturated", 4, "XS3 band is saturated"); flagCoding.addFlag("SWIR_saturated", 8, "SWIR band is saturated"); outputProduct.getFlagCodingGroup().add(flagCoding); return flagCoding; }
public static FlagCoding createIdepixFlagCoding(String flagIdentifier) { FlagCoding flagCoding = new FlagCoding(flagIdentifier); flagCoding.addFlag("IDEPIX_INVALID", BitSetter.setFlag(0, S2IdepixConstants.IDEPIX_INVALID), IDEPIX_INVALID_DESCR_TEXT); flagCoding.addFlag("IDEPIX_CLOUD", BitSetter.setFlag(0, S2IdepixConstants.IDEPIX_CLOUD), IDEPIX_CLOUD_DESCR_TEXT); flagCoding.addFlag("IDEPIX_CLOUD_AMBIGUOUS", BitSetter.setFlag(0, S2IdepixConstants.IDEPIX_CLOUD_AMBIGUOUS), IDEPIX_CLOUD_AMBIGUOUS_DESCR_TEXT); flagCoding.addFlag("IDEPIX_CLOUD_SURE", BitSetter.setFlag(0, S2IdepixConstants.IDEPIX_CLOUD_SURE), IDEPIX_CLOUD_SURE_DESCR_TEXT); flagCoding.addFlag("IDEPIX_CLOUD_BUFFER", BitSetter.setFlag(0, S2IdepixConstants.IDEPIX_CLOUD_BUFFER), IDEPIX_CLOUD_BUFFER_DESCR_TEXT); flagCoding.addFlag("IDEPIX_CLOUD_SHADOW", BitSetter.setFlag(0, S2IdepixConstants.IDEPIX_CLOUD_SHADOW), IDEPIX_CLOUD_SHADOW_DESCR_TEXT); flagCoding.addFlag("IDEPIX_SNOW_ICE", BitSetter.setFlag(0, S2IdepixConstants.IDEPIX_SNOW_ICE), IDEPIX_SNOW_ICE_DESCR_TEXT); flagCoding.addFlag("IDEPIX_BRIGHT", BitSetter.setFlag(0, S2IdepixConstants.IDEPIX_BRIGHT), IDEPIX_BRIGHT_DESCR_TEXT); flagCoding.addFlag("IDEPIX_WHITE", BitSetter.setFlag(0, S2IdepixConstants.IDEPIX_WHITE), IDEPIX_WHITE_DESCR_TEXT); flagCoding.addFlag("IDEPIX_COASTLINE", BitSetter.setFlag(0, S2IdepixConstants.IDEPIX_COASTLINE), IDEPIX_COASTLINE_DESCR_TEXT); flagCoding.addFlag("IDEPIX_LAND", BitSetter.setFlag(0, S2IdepixConstants.IDEPIX_LAND), IDEPIX_LAND_DESCR_TEXT); flagCoding.addFlag("IDEPIX_CIRRUS_SURE", BitSetter.setFlag(0, S2IdepixConstants.IDEPIX_CIRRUS_SURE), IDEPIX_CIRRUS_SURE_DESCR_TEXT); flagCoding.addFlag("IDEPIX_CIRRUS_AMBIGUOUS", BitSetter.setFlag(0, S2IdepixConstants.IDEPIX_CIRRUS_AMBIGUOUS), IDEPIX_CIRRUS_AMBIGUOUS_DESCR_TEXT); flagCoding.addFlag("IDEPIX_CLEAR_LAND", BitSetter.setFlag(0, S2IdepixConstants.IDEPIX_CLEAR_LAND), IDEPIX_CLEAR_LAND_DESCR_TEXT); flagCoding.addFlag("IDEPIX_CLEAR_WATER", BitSetter.setFlag(0, S2IdepixConstants.IDEPIX_CLEAR_WATER), IDEPIX_CLEAR_WATER_DESCR_TEXT); flagCoding.addFlag("IDEPIX_WATER", BitSetter.setFlag(0, S2IdepixConstants.IDEPIX_WATER), IDEPIX_WATER_DESCR_TEXT); flagCoding.addFlag("IDEPIX_BRIGHTWHITE", BitSetter.setFlag(0, S2IdepixConstants.IDEPIX_BRIGHTWHITE), IDEPIX_BRIGHTWHITE_DESCR_TEXT); flagCoding.addFlag("IDEPIX_VEG_RISK", BitSetter.setFlag(0, S2IdepixConstants.IDEPIX_VEG_RISK), IDEPIX_VEG_RISK_DESCR_TEXT); flagCoding.addFlag("IDEPIX_MOUNTAIN_SHADOW", BitSetter.setFlag(0, S2IdepixConstants.IDEPIX_MOUNTAIN_SHADOW), IDEPIX_MOUNTAIN_SHADOW_DESCR_TEXT); return flagCoding; }
@Override public void initialize() throws OperatorException { String pname = aotProduct.getName(); String ptype = aotProduct.getProductType(); rasterWidth = aotProduct.getSceneRasterWidth(); rasterHeight = aotProduct.getSceneRasterHeight(); targetProduct = new Product(pname, ptype, rasterWidth, rasterHeight); FlagCoding aotFlagCoding = new FlagCoding(AotConsts.aotFlags.name); aotFlagCoding.addFlag("aot_climatology", BitSetter.setFlag(0, F_CLIM), "aot from climatology only"); aotFlagCoding.addFlag("aot_interp", BitSetter.setFlag(0, F_INTERP), "aot spatially interpolated"); targetProduct.getFlagCodingGroup().add(aotFlagCoding); AerosolUtils.createFlagMasks(targetProduct); Band targetBand = AerosolUtils.createTargetBand(AotConsts.aotFlags, rasterWidth, rasterHeight); targetBand.setSampleCoding(aotFlagCoding); targetProduct.addBand(targetBand); ProductUtils.copyBand(AotConsts.aot.name, aotProduct, targetProduct, false); ProductUtils.copyBand(AotConsts.aotErr.name, aotProduct, targetProduct, false); setTargetProduct(targetProduct); }
final FlagCoding biophysicalVariableFlagCoding = new FlagCoding(flagBandName); for (BiophysicalFlag flagDef : BiophysicalFlag.values()) { biophysicalVariableFlagCoding.addFlag(flagDef.getName(), flagDef.getFlagValue(), flagDef.getDescription());