org.esa.beam.util
Class ProductUtils

java.lang.Object
  extended by org.esa.beam.util.ProductUtils

public class ProductUtils
extends Object

This class provides many static factory methods to be used in conjunction with data products.

See Also:
Product

Constructor Summary
ProductUtils()
           
 
Method Summary
static void addElementToHistory(Product product, MetadataElement elem)
          Adds a given elem to the history of the given product.
static GeneralPath areaToPath(Area negativeArea, double deltaX)
           
static boolean canGetPixelPos(Product product)
          Returns whether or not a product can return a pixel position from a given geographical position.
static boolean canGetPixelPos(RasterDataNode raster)
          Returns whether or not a raster can return a pixel position from a given geographical position.
static float[] computeMinMaxY(PixelPos[] pixelPositions)
          Computes the minimum and maximum y value of the given PixelPos array.
static PixelPos[] computeSourcePixelCoordinates(GeoCoding sourceGeoCoding, int sourceWidth, int sourceHeight, GeoCoding destGeoCoding, Rectangle destArea)
           
static GeneralPath convertToGeoPath(Shape shape, GeoCoding geoCoding)
          Converts a Shape given in pixel X/Y coordinates into a GeneralPath in geografic coordinates using the supplied geo coding.
static GeneralPath convertToPixelPath(GeneralPath geoPath, GeoCoding geoCoding)
          Converts a GeneralPath given in geographic lon/lat coordinates into a GeneralPath in pixel coordinates using the supplied geo coding.
static Band copyBand(String sourceBandName, Product sourceProduct, Product targetProduct)
          Deprecated. since BEAM 4.10, use copyBand(String, Product, Product, boolean) instead.
static Band copyBand(String sourceBandName, Product sourceProduct, Product targetProduct, boolean copySourceImage)
          Copies the named band from the source product to the target product.
static Band copyBand(String sourceBandName, Product sourceProduct, String targetBandName, Product targetProduct)
          Deprecated. since BEAM 4.10, use copyBand(String, Product, String, Product, boolean) instead.
static Band copyBand(String sourceBandName, Product sourceProduct, String targetBandName, Product targetProduct, boolean copySourceImage)
          Copies the named band from the source product to the target product.
static void copyBandsForGeomTransform(Product sourceProduct, Product targetProduct, boolean includeTiePointGrids, double defaultNoDataValue, Map<Band,RasterDataNode> targetToSourceMap)
          Adds raster data nodes of a source product as bands to the given target product.
static void copyBandsForGeomTransform(Product sourceProduct, Product targetProduct, double defaultNoDataValue, Map<Band,RasterDataNode> addedRasterDataNodes)
          Copies only the bands from source to target.
static void copyFlagBands(Product sourceProduct, Product targetProduct)
          Deprecated. since BEAM 4.10, use copyFlagBands(Product, Product, boolean) instead.
static void copyFlagBands(Product sourceProduct, Product targetProduct, boolean copySourceImage)
          Copies all bands which contain a flagcoding from the source product to the target product.
static FlagCoding copyFlagCoding(FlagCoding sourceFlagCoding, Product target)
          Copies the given source flag coding to the target product.
static void copyFlagCodings(Product source, Product target)
          Copies the flag codings from the source product to the target.
static void copyGeoCoding(Product sourceProduct, Product targetProduct)
          Copies the geocoding from the source product to target product.
static IndexCoding copyIndexCoding(IndexCoding sourceIndexCoding, Product target)
          Copies the given source index coding to the target product If it exists already, the method simply returns the existing instance.
static void copyMasks(Product sourceProduct, Product targetProduct)
          Copies the Masks from the source product to the target product.
static void copyMetadata(MetadataElement source, MetadataElement target)
          Copies all metadata elements and attributes of the source element to the target element.
static void copyMetadata(Product source, Product target)
          Copies all metadata elements and attributes of the source product to the target product.
static void copyOverlayMasks(Product sourceProduct, Product targetProduct)
          Copies the overlay Masks from the source product's raster data nodes to the target product's raster data nodes.
static void copyPreferredTileSize(Product sourceProduct, Product targetProduct)
          Copies the source product's preferred tile size (if any) to the target product.
static void copyRasterDataNodeProperties(RasterDataNode sourceRaster, RasterDataNode targetRaster)
          Copies all properties from source band to the target band.
static void copyRoiMasks(Product sourceProduct, Product targetProduct)
          Deprecated. since BEAM 4.10 (no replacement)
static void copySpectralBandProperties(Band sourceBand, Band targetBand)
          Copies the spectral properties from source band to target band.
static TiePointGrid copyTiePointGrid(String gridName, Product sourceProduct, Product targetProduct)
          Copies the named tie-point grid from the source product to the target product.
static void copyTiePointGrids(Product sourceProduct, Product targetProduct)
          Copies all tie point grids from one product to another.
static void copyVectorData(Product sourceProduct, Product targetProduct)
           
static BufferedImage createColorIndexedImage(RasterDataNode rasterDataNode, com.bc.ceres.core.ProgressMonitor pm)
          Creates a greyscale image from the given RasterDataNode.
static BufferedImage createDensityPlotImage(RasterDataNode raster1, float sampleMin1, float sampleMax1, RasterDataNode raster2, float sampleMin2, float sampleMax2, Mask roiMask, int width, int height, Color background, BufferedImage image, com.bc.ceres.core.ProgressMonitor pm)
          Creates a density plot image from two raster data nodes.
static GeoPos[] createGeoBoundary(Product product, int step)
          Creates the geographical boundary of the given product and returns it as a list of geographical coordinates.
static GeoPos[] createGeoBoundary(Product product, Rectangle region, int step)
          Creates the geographical boundary of the given region within the given product and returns it as a list of geographical coordinates.
static GeoPos[] createGeoBoundary(Product product, Rectangle region, int step, boolean usePixelCenter)
          Creates the geographical boundary of the given region within the given product and returns it as a list of geographical coordinates.
static GeoPos[] createGeoBoundary(RasterDataNode raster, Rectangle region, int step)
          Creates the geographical boundary of the given region within the given raster and returns it as a list of geographical coordinates.
static GeneralPath[] createGeoBoundaryPaths(Product product)
          Converts the geographic boundary entire product into one, two or three shape objects.
static GeneralPath[] createGeoBoundaryPaths(Product product, Rectangle region, int step)
          Converts the geographic boundary of the region within the given product into one, two or three shape objects.
static GeneralPath[] createGeoBoundaryPaths(Product product, Rectangle region, int step, boolean usePixelCenter)
          Converts the geographic boundary of the region within the given product into one, two or three shape objects.
static GeoTIFFMetadata createGeoTIFFMetadata(GeoCoding geoCoding, int width, int height)
           
static GeoTIFFMetadata createGeoTIFFMetadata(Product product)
           
static ImageInfo createImageInfo(RasterDataNode[] rasters, boolean assignMissingImageInfos, com.bc.ceres.core.ProgressMonitor pm)
          Creates image creation information.
static Point2D[] createMapBoundary(Product product, Rectangle rect, int step, MapTransform mapTransform)
           
static Point2D[] createMapEnvelope(Product product, Rectangle rect, int step, MapTransform mapTransform)
          Creates the boundary in map coordinates for the given product, source rectangle (in product pixel coordinates) and the given map transfromation.
static Point2D[] createMapEnvelope(Product product, Rectangle rect, MapTransform mapTransform)
          Creates the boundary in map coordinates for the given product, source rectangle (in product pixel coordinates) and the given map transfromation.
static PixelPos[] createPixelBoundary(Product product, Rectangle rect, int step)
          Creates a rectangular boundary expressed in pixel positions for the given source rectangle.
static PixelPos[] createPixelBoundary(Product product, Rectangle rect, int step, boolean usePixelCenter)
          Creates a rectangular boundary expressed in pixel positions for the given source rectangle.
static PixelPos[] createPixelBoundary(RasterDataNode raster, Rectangle rect, int step)
          Creates a rectangular boundary expressed in pixel positions for the given source rectangle.
static PixelPos[] createRectBoundary(Rectangle rect, int step)
          Creates a rectangular boundary expressed in pixel positions for the given source rectangle.
static PixelPos[] createRectBoundary(Rectangle rect, int step, boolean usePixelCenter)
          Creates a rectangular boundary expressed in pixel positions for the given source rectangle.
static BufferedImage createRgbImage(RasterDataNode[] rasters, ImageInfo imageInfo, com.bc.ceres.core.ProgressMonitor pm)
          Creates a RGB image from the given array of RasterDataNodes.
static MapInfo createSuitableMapInfo(Product product, MapProjection mapProjection, double orientation, double noDataValue)
          Retuns a suitable MapInfo instance for the given (geo-coded) product which includes the entire or a subset of the product's scene region for the given map projection.
static MapInfo createSuitableMapInfo(Product product, Rectangle rect, MapProjection mapProjection)
          Retuns a suitable MapInfo instance for the given (geo-coded) product which includes the entire or a subset of the product's scene region for the given map projection.
static void denormalizeGeoPolygon(GeoPos[] polygon)
          Denormalizes the longitude values which have been normalized using the normalizeGeoPolygon(org.esa.beam.framework.datamodel.GeoPos[]) method.
static void denormalizeGeoPos_old(GeoPos geoPos)
          Deprecated. 
static void denormalizeGeoPos(GeoPos geoPos)
           
static String findSuitableQuicklookBandName(Product product)
          Finds the name of a band in the given product which is suitable to product a good quicklook.
static double getAngleSum(GeoPos[] polygon)
           
static GeoPos getCenterGeoPos(Product product)
           
static double getGeophysicalSampleDouble(Band band, int pixelX, int pixelY, int level)
           
static long getGeophysicalSampleLong(Band band, int pixelX, int pixelY, int level)
           
static Point2D[] getMinMax(Point2D[] boundary)
           
static Dimension getOutputRasterSize(Product product, Rectangle rect, MapTransform mapTransform, double pixelSizeX, double pixelSizeY)
           
static int getRotationDirection(GeoPos[] polygon)
           
static ProductData.UTC getScanLineTime(Product product, double y)
           
static int normalizeGeoPolygon_old(GeoPos[] polygon)
          Deprecated. 
static int normalizeGeoPolygon(GeoPos[] polygon)
          Normalizes the given geographical polygon so that maximum longitude differences between two points are 180 degrees.
static BufferedImage overlayMasks(RasterDataNode raster, BufferedImage overlayBIm, com.bc.ceres.core.ProgressMonitor pm)
          Draws all the masks contained overlay mask group of the given raster to the ovelayBIm image.
static String[] removeInvalidExpressions(Product product)
          Validates all the expressions contained in the given (output) product.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProductUtils

public ProductUtils()
Method Detail

createImageInfo

public static ImageInfo createImageInfo(RasterDataNode[] rasters,
                                        boolean assignMissingImageInfos,
                                        com.bc.ceres.core.ProgressMonitor pm)
                                 throws IOException
Creates image creation information.

Parameters:
rasters - The raster data nodes.
assignMissingImageInfos - if true, it is ensured that to all RasterDataNodes a valid ImageInfo will be assigned.
pm - The progress monitor.
Returns:
image information
Throws:
IOException - if an I/O error occurs
Since:
BEAM 4.2

createRgbImage

public static BufferedImage createRgbImage(RasterDataNode[] rasters,
                                           ImageInfo imageInfo,
                                           com.bc.ceres.core.ProgressMonitor pm)
                                    throws IOException
Creates a RGB image from the given array of RasterDataNodes. The given array rasters containing one or three raster data nodes. If three rasters are given RGB image is created, if only one raster is provided a gray scale image created.

Parameters:
rasters - an array of one or three raster nodes.
imageInfo - the image info provides the information how to create the image
pm - a monitor to inform the user about progress
Returns:
the created image
Throws:
IOException - if the given raster data is not loaded and reload causes an I/O error
See Also:
RasterDataNode.setImageInfo(org.esa.beam.framework.datamodel.ImageInfo)

createColorIndexedImage

public static BufferedImage createColorIndexedImage(RasterDataNode rasterDataNode,
                                                    com.bc.ceres.core.ProgressMonitor pm)
                                             throws IOException
Creates a greyscale image from the given RasterDataNode.

The method uses the given raster data node's image information (an instance of ImageInfo) to create the image.

Parameters:
rasterDataNode - the raster data node, must not be null
pm - a monitor to inform the user about progress
Returns:
the color indexed image
Throws:
IOException - if the given raster data is not loaded and reload causes an I/O error
See Also:
RasterDataNode.getImageInfo()

createSuitableMapInfo

public static MapInfo createSuitableMapInfo(Product product,
                                            Rectangle rect,
                                            MapProjection mapProjection)
Retuns a suitable MapInfo instance for the given (geo-coded) product which includes the entire or a subset of the product's scene region for the given map projection. The position of the reference pixel will be the upper left pixel's center (0.5, 0.5).

Parameters:
product - the product, must not be null
rect - the rectangle in pixel coordinates of the product, if null the entire region is considered
mapProjection - the map projection, must not be null
Returns:
the map information instance

createSuitableMapInfo

public static MapInfo createSuitableMapInfo(Product product,
                                            MapProjection mapProjection,
                                            double orientation,
                                            double noDataValue)
Retuns a suitable MapInfo instance for the given (geo-coded) product which includes the entire or a subset of the product's scene region for the given map projection. The position of the reference pixel will be the scene center.

Parameters:
product - the product, must not be null
mapProjection - the map projection, must not be null
orientation - the orientation angle
noDataValue - the no-data value to be used
Returns:
the map information instance

getOutputRasterSize

public static Dimension getOutputRasterSize(Product product,
                                            Rectangle rect,
                                            MapTransform mapTransform,
                                            double pixelSizeX,
                                            double pixelSizeY)

createMapEnvelope

public static Point2D[] createMapEnvelope(Product product,
                                          Rectangle rect,
                                          MapTransform mapTransform)
Creates the boundary in map coordinates for the given product, source rectangle (in product pixel coordinates) and the given map transfromation. The method delegates to createMapEnvelope(product, rect, step, mapTransform) where step is the half of the minimum of the product scene raster width and height.

Parameters:
product - The product.
rect - The rectangle in pixel coordinates.
mapTransform - The map transformation.
Returns:
The boundary in map coordinates for the given product.

createMapEnvelope

public static Point2D[] createMapEnvelope(Product product,
                                          Rectangle rect,
                                          int step,
                                          MapTransform mapTransform)
Creates the boundary in map coordinates for the given product, source rectangle (in product pixel coordinates) and the given map transfromation. The method delegates to createMapBoundary(product, rect, step, mapTransform) where step is the half of the minimum of the product scene raster width and height.

Parameters:
product - The product.
rect - The rectangle in pixel coordinates.
step - The step size in pixels.
mapTransform - The map transformation.
Returns:
The boundary in map coordinates for the given product.

getMinMax

public static Point2D[] getMinMax(Point2D[] boundary)

createMapBoundary

public static Point2D[] createMapBoundary(Product product,
                                          Rectangle rect,
                                          int step,
                                          MapTransform mapTransform)

createGeoBoundary

public static GeoPos[] createGeoBoundary(Product product,
                                         int step)
Creates the geographical boundary of the given product and returns it as a list of geographical coordinates.

Parameters:
product - the input product, must not be null
step - the step given in pixels
Returns:
an array of geographical coordinates
Throws:
IllegalArgumentException - if product is null or if the product's GeoCoding is null

createGeoBoundary

public static GeoPos[] createGeoBoundary(Product product,
                                         Rectangle region,
                                         int step)
Creates the geographical boundary of the given region within the given product and returns it as a list of geographical coordinates.

This method delegates to createGeoBoundary(Product, Rectangle, int, boolean) and the additional boolean parameter usePixelCenter is true.

Parameters:
product - the input product, must not be null
region - the region rectangle in product pixel coordinates, can be null for entire product
step - the step given in pixels
Returns:
an array of geographical coordinates
Throws:
IllegalArgumentException - if product is null or if the product's GeoCoding is null
See Also:
createPixelBoundary(org.esa.beam.framework.datamodel.RasterDataNode, java.awt.Rectangle, int)

createGeoBoundary

public static GeoPos[] createGeoBoundary(Product product,
                                         Rectangle region,
                                         int step,
                                         boolean usePixelCenter)
Creates the geographical boundary of the given region within the given product and returns it as a list of geographical coordinates.

Parameters:
product - the input product, must not be null
region - the region rectangle in product pixel coordinates, can be null for entire product
step - the step given in pixels
usePixelCenter - true if the pixel center should be used to create the boundary
Returns:
an array of geographical coordinates
Throws:
IllegalArgumentException - if product is null or if the product's GeoCoding is null
See Also:
createPixelBoundary(org.esa.beam.framework.datamodel.Product, java.awt.Rectangle, int, boolean)

createGeoBoundary

public static GeoPos[] createGeoBoundary(RasterDataNode raster,
                                         Rectangle region,
                                         int step)
Creates the geographical boundary of the given region within the given raster and returns it as a list of geographical coordinates.

Parameters:
raster - the input raster, must not be null
region - the region rectangle in raster pixel coordinates, can be null for entire raster
step - the step given in pixels
Returns:
an array of geographical coordinates
Throws:
IllegalArgumentException - if raster is null or if the raster has no GeoCoding is null
See Also:
createPixelBoundary(org.esa.beam.framework.datamodel.RasterDataNode, java.awt.Rectangle, int)

createGeoBoundaryPaths

public static GeneralPath[] createGeoBoundaryPaths(Product product)
Converts the geographic boundary entire 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.

The geographic boundary of the given product are returned as shapes comprising (longitude,latitude) pairs.

Parameters:
product - the input product
Returns:
an array of shape objects
Throws:
IllegalArgumentException - if product is null or if the product's GeoCoding is null
See Also:
createGeoBoundary(org.esa.beam.framework.datamodel.Product, int)

createGeoBoundaryPaths

public static GeneralPath[] createGeoBoundaryPaths(Product product,
                                                   Rectangle region,
                                                   int step)
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.

This method delegates to createGeoBoundaryPaths(Product, Rectangle, int, boolean) and the additional parameter usePixelCenter is true.

The geographic boundary of the given product are returned as shapes comprising (longitude,latitude) pairs.

Parameters:
product - the input product
region - the region rectangle in product pixel coordinates, can be null for entire product
step - the step given in pixels
Returns:
an array of shape objects
Throws:
IllegalArgumentException - if product is null or if the product's GeoCoding is null
See Also:
createGeoBoundary(org.esa.beam.framework.datamodel.Product, java.awt.Rectangle, int)

createGeoBoundaryPaths

public static GeneralPath[] createGeoBoundaryPaths(Product product,
                                                   Rectangle region,
                                                   int step,
                                                   boolean usePixelCenter)
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.

The geographic boundary of the given product are returned as shapes comprising (longitude,latitude) pairs.

Parameters:
product - the input product
region - the region rectangle in product pixel coordinates, can be null for entire product
step - the step given in pixels
usePixelCenter - true if the pixel center should be used to create the pathes
Returns:
an array of shape objects
Throws:
IllegalArgumentException - if product is null or if the product's GeoCoding is null
See Also:
createGeoBoundary(org.esa.beam.framework.datamodel.Product, java.awt.Rectangle, int, boolean)

createPixelBoundary

public static PixelPos[] createPixelBoundary(Product product,
                                             Rectangle rect,
                                             int step)
Creates a rectangular boundary expressed in pixel positions for the given source rectangle. If the source rect is 100 x 50 pixels and step is 10 the returned array will countain exactly 2 * 10 + 2 * (5 - 2) = 26 pixel positions.

This method is used for an intermediate step when determining a product boundary expressed in geographical co-ordinates.

This method delegates to createPixelBoundary(Product, Rectangle, int, boolean) and the additional boolean parameter usePixelCenter is true.

Parameters:
product - the product
rect - the source rectangle
step - the mean distance from one pixel position to the other in the returned array
Returns:
the rectangular boundary

createPixelBoundary

public static PixelPos[] createPixelBoundary(Product product,
                                             Rectangle rect,
                                             int step,
                                             boolean usePixelCenter)
Creates a rectangular boundary expressed in pixel positions for the given source rectangle. If the source rect is 100 x 50 pixels and step is 10 the returned array will countain exactly 2 * 10 + 2 * (5 - 2) = 26 pixel positions.

This method is used for an intermediate step when determining a product boundary expressed in geographical co-ordinates.

Parameters:
product - the product
rect - the source rectangle
step - the mean distance from one pixel position to the other in the returned array
usePixelCenter - true if the pixel center should be used to create the boundary
Returns:
the rectangular boundary

createPixelBoundary

public static PixelPos[] createPixelBoundary(RasterDataNode raster,
                                             Rectangle rect,
                                             int step)
Creates a rectangular boundary expressed in pixel positions for the given source rectangle. If the source rect is 100 x 50 pixels and step is 10 the returned array will countain exactly 2 * 10 + 2 * (5 - 2) = 26 pixel positions.

This method is used for an intermediate step when determining a raster boundary expressed in geographical co-ordinates.

Parameters:
raster - the raster
rect - the source rectangle
step - the mean distance from one pixel position to the other in the returned array
Returns:
the rectangular boundary

createRectBoundary

public static PixelPos[] createRectBoundary(Rectangle rect,
                                            int step)
Creates a rectangular boundary expressed in pixel positions for the given source rectangle. If the source rect is 100 x 50 pixels and step is 10 the returned array will countain exactly 2 * 10 + 2 * (5 - 2) = 26 pixel positions.

This method is used for an intermediate step when determining a product boundary expressed in geographical co-ordinates.

This method delegates to createRectBoundary(Rectangle, int, boolean) and the additional boolean parameter usePixelCenter is true.

Parameters:
rect - the source rectangle
step - the mean distance from one pixel position to the other in the returned array
Returns:
the rectangular boundary

createRectBoundary

public static PixelPos[] createRectBoundary(Rectangle rect,
                                            int step,
                                            boolean usePixelCenter)
Creates a rectangular boundary expressed in pixel positions for the given source rectangle. If the source rect is 100 x 50 pixels and step is 10 the returned array will countain exactly 2 * 10 + 2 * (5 - 2) = 26 pixel positions.

This method is used for an intermediate step when determining a product boundary expressed in geographical co-ordinates.

Parameters:
rect - the source rectangle
step - the mean distance from one pixel position to the other in the returned array
usePixelCenter - true if the pixel center should be used
Returns:
the rectangular boundary

copyFlagCodings

public static void copyFlagCodings(Product source,
                                   Product target)
Copies the flag codings from the source product to the target.

Parameters:
source - the source product
target - the target product

copyFlagCoding

public static FlagCoding copyFlagCoding(FlagCoding sourceFlagCoding,
                                        Product target)
Copies the given source flag coding to the target product. If it exists already, the method simply returns the existing instance.

Parameters:
sourceFlagCoding - the source flag coding
target - the target product
Returns:
The flag coding.

copyIndexCoding

public static IndexCoding copyIndexCoding(IndexCoding sourceIndexCoding,
                                          Product target)
Copies the given source index coding to the target product If it exists already, the method simply returns the existing instance.

Parameters:
sourceIndexCoding - the source index coding
target - the target product
Returns:
The index coding.

copyMasks

public static void copyMasks(Product sourceProduct,
                             Product targetProduct)
Copies the Masks from the source product to the target product.

IMPORTANT NOTE: This method should only be used, if it is known that all masks in the source product will also be valid in the target product. This method does not copy overlay masks from the source bands to the target bands. Also note that a source mask is not copied to the target product, when there already is a mask in the target product with the same name as the source mask.

Parameters:
sourceProduct - the source product
targetProduct - the target product

copyOverlayMasks

public static void copyOverlayMasks(Product sourceProduct,
                                    Product targetProduct)
Copies the overlay Masks from the source product's raster data nodes to the target product's raster data nodes.

IMPORTANT NOTE: This method should only be used, if it is known that all masks in the source product will also be valid in the target product. This method does not copy overlay masks, which are not contained in the target product's mask group.

Parameters:
sourceProduct - the source product
targetProduct - the target product

copyRoiMasks

@Deprecated
public static void copyRoiMasks(Product sourceProduct,
                                           Product targetProduct)
Deprecated. since BEAM 4.10 (no replacement)

Copies the ROI Masks from the source product's raster data nodes to the target product's raster data nodes.

IMPORTANT NOTE: This method should only be used, if it is known that all masks in the source product will also be valid in the target product. This method does not copy ROI masks, which are not contained in the target product's mask group.

Parameters:
sourceProduct - the source product
targetProduct - the target product

copyFlagBands

public static void copyFlagBands(Product sourceProduct,
                                 Product targetProduct,
                                 boolean copySourceImage)
Copies all bands which contain a flagcoding from the source product to the target product.

Parameters:
sourceProduct - the source product
targetProduct - the target product
copySourceImage - whether the source image of the source band should be copied.
Since:
BEAM 4.10

copyFlagBands

@Deprecated
public static void copyFlagBands(Product sourceProduct,
                                            Product targetProduct)
Deprecated. since BEAM 4.10, use copyFlagBands(Product, Product, boolean) instead.

Copies all bands which contain a flagcoding from the source product to the target product.

Parameters:
sourceProduct - the source product
targetProduct - the target product

copyTiePointGrid

public static TiePointGrid copyTiePointGrid(String gridName,
                                            Product sourceProduct,
                                            Product targetProduct)
Copies the named tie-point grid from the source product to the target product.

Parameters:
gridName - the name of the tie-point grid to be copied.
sourceProduct - the source product
targetProduct - the target product
Returns:
the copied tie-point grid, or null if the sourceProduct does not contain a tie-point grid with the given name.

copyBand

public static Band copyBand(String sourceBandName,
                            Product sourceProduct,
                            Product targetProduct,
                            boolean copySourceImage)
Copies the named band from the source product to the target product.

Parameters:
sourceBandName - the name of the band to be copied.
sourceProduct - the source product.
targetProduct - the target product.
copySourceImage - whether the source image of the source band should be copied.
Returns:
the copy of the band, or null if the sourceProduct does not contain a band with the given name.
Since:
BEAM 4.10

copyBand

public static Band copyBand(String sourceBandName,
                            Product sourceProduct,
                            String targetBandName,
                            Product targetProduct,
                            boolean copySourceImage)
Copies the named band from the source product to the target product.

Parameters:
sourceBandName - the name of the band to be copied.
sourceProduct - the source product.
targetBandName - the name of the band copied.
targetProduct - the target product.
copySourceImage - whether the source image of the source band should be copied.
Returns:
the copy of the band, or null if the sourceProduct does not contain a band with the given name.
Since:
BEAM 4.10

copyRasterDataNodeProperties

public static void copyRasterDataNodeProperties(RasterDataNode sourceRaster,
                                                RasterDataNode targetRaster)
Copies all properties from source band to the target band.

Parameters:
sourceRaster - the source band
targetRaster - the target band
See Also:
copySpectralBandProperties(org.esa.beam.framework.datamodel.Band, org.esa.beam.framework.datamodel.Band)

copyBand

@Deprecated
public static Band copyBand(String sourceBandName,
                                       Product sourceProduct,
                                       Product targetProduct)
Deprecated. since BEAM 4.10, use copyBand(String, Product, Product, boolean) instead.

Copies the named band from the source product to the target product.

Parameters:
sourceBandName - the name of the band to be copied.
sourceProduct - the source product.
targetProduct - the target product.
Returns:
the copy of the band, or null if the sourceProduct does not contain a band with the given name.

copyBand

@Deprecated
public static Band copyBand(String sourceBandName,
                                       Product sourceProduct,
                                       String targetBandName,
                                       Product targetProduct)
Deprecated. since BEAM 4.10, use copyBand(String, Product, String, Product, boolean) instead.

Copies the named band from the source product to the target product.

Parameters:
sourceBandName - the name of the band to be copied.
sourceProduct - the source product.
targetBandName - the name of the band copied.
targetProduct - the target product.
Returns:
the copy of the band, or null if the sourceProduct does not contain a band with the given name.

copySpectralBandProperties

public static void copySpectralBandProperties(Band sourceBand,
                                              Band targetBand)
Copies the spectral properties from source band to target band. These properties are:

Parameters:
sourceBand - the source band
targetBand - the target band
See Also:
copyRasterDataNodeProperties(org.esa.beam.framework.datamodel.RasterDataNode, org.esa.beam.framework.datamodel.RasterDataNode)

copyGeoCoding

public static void copyGeoCoding(Product sourceProduct,
                                 Product targetProduct)
Copies the geocoding from the source product to target product.

If the geo-coding in the source product is a TiePointGeoCoding or a PixelGeoCoding, the method expects existing latitude and longitude tie-point grids respectively existing latitude and longitude bands in the target product. The method will NOT automatically copy them as well. This behaviour may change in the future.

Parameters:
sourceProduct - the source product
targetProduct - the target product
Throws:
IllegalArgumentException - if one of the params is null.

copyTiePointGrids

public static void copyTiePointGrids(Product sourceProduct,
                                     Product targetProduct)
Copies all tie point grids from one product to another.

Parameters:
sourceProduct - the source product
targetProduct - the target product

copyVectorData

public static void copyVectorData(Product sourceProduct,
                                  Product targetProduct)

canGetPixelPos

public static boolean canGetPixelPos(Product product)
Returns whether or not a product can return a pixel position from a given geographical position.

Parameters:
product - the product to be checked
Returns:
true if the given product can return a pixel position

canGetPixelPos

public static boolean canGetPixelPos(RasterDataNode raster)
Returns whether or not a raster can return a pixel position from a given geographical position.

Parameters:
raster - the raster to be checked
Returns:
true if the given raster can return a pixel position

createDensityPlotImage

public static BufferedImage createDensityPlotImage(RasterDataNode raster1,
                                                   float sampleMin1,
                                                   float sampleMax1,
                                                   RasterDataNode raster2,
                                                   float sampleMin2,
                                                   float sampleMax2,
                                                   Mask roiMask,
                                                   int width,
                                                   int height,
                                                   Color background,
                                                   BufferedImage image,
                                                   com.bc.ceres.core.ProgressMonitor pm)
                                            throws IOException
Creates a density plot image from two raster data nodes.

Parameters:
raster1 - the first raster data node
sampleMin1 - the minimum sample value to be considered in the first raster
sampleMax1 - the maximum sample value to be considered in the first raster
raster2 - the second raster data node
sampleMin2 - the minimum sample value to be considered in the second raster
sampleMax2 - the maximum sample value to be considered in the second raster
roiMask - an optional mask to be used as a ROI for the computation
width - the width of the output image
height - the height of the output image
background - the background color of the output image
image - an image to be used as output image, if null a new image is created
pm - the progress monitor
Returns:
the density plot image
Throws:
IOException - when an error occurred.

overlayMasks

public static BufferedImage overlayMasks(RasterDataNode raster,
                                         BufferedImage overlayBIm,
                                         com.bc.ceres.core.ProgressMonitor pm)
Draws all the masks contained overlay mask group of the given raster to the ovelayBIm image.

Parameters:
raster - the raster data node which contains all the activated bitmask definitions
overlayBIm - the source image which is used as base image for all the overlays.
pm - a monitor to inform the user about progress
Returns:
the modified given overlayBImm which contains all the activated masks.
See Also:
RasterDataNode.getOverlayMaskGroup()

getCenterGeoPos

public static GeoPos getCenterGeoPos(Product product)

normalizeGeoPolygon

public static int normalizeGeoPolygon(GeoPos[] polygon)
Normalizes the given geographical polygon so that maximum longitude differences between two points are 180 degrees. The method operates only on the longitude values of the given polygon.

Parameters:
polygon - a geographical, closed polygon
Returns:
0 if normalizing has not been applied , -1 if negative normalizing has been applied, 1 if positive normalizing has been applied, 2 if positive and negative normalising has been applied
See Also:
denormalizeGeoPolygon(GeoPos[])

normalizeGeoPolygon_old

@Deprecated
public static int normalizeGeoPolygon_old(GeoPos[] polygon)
Deprecated. 


denormalizeGeoPolygon

public static void denormalizeGeoPolygon(GeoPos[] polygon)
Denormalizes the longitude values which have been normalized using the normalizeGeoPolygon(org.esa.beam.framework.datamodel.GeoPos[]) method. The method operates only on the longitude values of the given polygon.

Parameters:
polygon - a geographical, closed polygon

denormalizeGeoPos

public static void denormalizeGeoPos(GeoPos geoPos)

denormalizeGeoPos_old

@Deprecated
public static void denormalizeGeoPos_old(GeoPos geoPos)
Deprecated. 


getRotationDirection

public static int getRotationDirection(GeoPos[] polygon)

getAngleSum

public static double getAngleSum(GeoPos[] polygon)

convertToPixelPath

public static GeneralPath convertToPixelPath(GeneralPath geoPath,
                                             GeoCoding geoCoding)
Converts a GeneralPath given in geographic lon/lat coordinates into a GeneralPath in pixel coordinates using the supplied geo coding.

Parameters:
geoPath - a GeneralPath given in geographic lon/lat coordinates, as returned by the convertToGeoPath(Shape, GeoCoding) method
geoCoding - the geocoding used to convert the geographic coordinates into pixel coordinates.
Returns:
a GeneralPath given in pixel coordinates.
Throws:
IllegalArgumentException - if one of the given parameter is null.
IllegalStateException - if the given geoPath is not a geo referenced GeneralPath wich contains only SEG_MOVETO, SEG_LINETO, and SEG_CLOSE point types.
See Also:
convertToGeoPath(Shape, GeoCoding)

convertToGeoPath

public static GeneralPath convertToGeoPath(Shape shape,
                                           GeoCoding geoCoding)
Converts a Shape given in pixel X/Y coordinates into a GeneralPath in geografic coordinates using the supplied geo coding.

Parameters:
shape - a Shape given in pixel X/Y coordinates
geoCoding - the geo coding used to convert the pixel coordinates into geografic coordinates.
Returns:
a GeneralPath given in geografic coordinates
Throws:
IllegalArgumentException - if one of the given parameter is null or the given geo coding can not get geografic coordinates.
IllegalStateException - if this method was used with a java runtime version in which it is not guaranted that a PathIterator returned by Shape.getPathIterator(java.awt.geom.AffineTransform, double) returnes only SEG_MOVETO, SEG_LINETO, and SEG_CLOSE point types.
See Also:
GeoCoding.canGetGeoPos()

copyMetadata

public static void copyMetadata(Product source,
                                Product target)
Copies all metadata elements and attributes of the source product to the target product. The copied elements and attributes are deeply cloned.

Parameters:
source - the source product.
target - the target product.
Throws:
NullPointerException - if the source or the target product is null.

copyMetadata

public static void copyMetadata(MetadataElement source,
                                MetadataElement target)
Copies all metadata elements and attributes of the source element to the target element. The copied elements and attributes are deeply cloned.

Parameters:
source - the source element.
target - the target element.
Throws:
NullPointerException - if the source or the target element is null.

copyPreferredTileSize

public static void copyPreferredTileSize(Product sourceProduct,
                                         Product targetProduct)
Copies the source product's preferred tile size (if any) to the target product.

Parameters:
sourceProduct - The source product.
targetProduct - The target product.

createGeoTIFFMetadata

public static GeoTIFFMetadata createGeoTIFFMetadata(Product product)

createGeoTIFFMetadata

public static GeoTIFFMetadata createGeoTIFFMetadata(GeoCoding geoCoding,
                                                    int width,
                                                    int height)

areaToPath

public static GeneralPath areaToPath(Area negativeArea,
                                     double deltaX)

addElementToHistory

public static void addElementToHistory(Product product,
                                       MetadataElement elem)
Adds a given elem to the history of the given product. If the products metadata root does not contain a history entry a new one will be created.

Parameters:
product - the product to add the history element.
elem - the element to add to the products history. If null nothing will be added.

removeInvalidExpressions

public static String[] removeInvalidExpressions(Product product)
Validates all the expressions contained in the given (output) product. If an expression is not applicable to the given product, the related element is removed.

Parameters:
product - the (output) product to be cleaned up
Returns:
an array of messages which changes are done to the given product.

findSuitableQuicklookBandName

public static String findSuitableQuicklookBandName(Product product)
Finds the name of a band in the given product which is suitable to product a good quicklook. The method prefers bands with longer wavelengths, in order to produce good results for night-time scenes.

Parameters:
product - the product to be searched
Returns:
the name of a suitable band or null if the given product does not contain any bands

computeSourcePixelCoordinates

public static PixelPos[] computeSourcePixelCoordinates(GeoCoding sourceGeoCoding,
                                                       int sourceWidth,
                                                       int sourceHeight,
                                                       GeoCoding destGeoCoding,
                                                       Rectangle destArea)

computeMinMaxY

public static float[] computeMinMaxY(PixelPos[] pixelPositions)
Computes the minimum and maximum y value of the given PixelPos array.

Parameters:
pixelPositions - the PixelPos array
Returns:
an int array which containes the minimum and maximum y value of the given PixelPos array in the order:
    [0] - the minimum value
    [1] - the maximum value

or null if no minimum or maximum can be retrieved because there given array is empty.
Throws:
IllegalArgumentException - if the given pixelPositions are null.

copyBandsForGeomTransform

public static void copyBandsForGeomTransform(Product sourceProduct,
                                             Product targetProduct,
                                             double defaultNoDataValue,
                                             Map<Band,RasterDataNode> addedRasterDataNodes)
Copies only the bands from source to target.

See Also:
copyBandsForGeomTransform(org.esa.beam.framework.datamodel.Product, org.esa.beam.framework.datamodel.Product, boolean, double, java.util.Map)

copyBandsForGeomTransform

public static void copyBandsForGeomTransform(Product sourceProduct,
                                             Product targetProduct,
                                             boolean includeTiePointGrids,
                                             double defaultNoDataValue,
                                             Map<Band,RasterDataNode> targetToSourceMap)
Adds raster data nodes of a source product as bands to the given target product. This method is especially usefull if the target product is a geometric transformation (e.g. map-projection) of the source product.

If sourceBand.scalingApplied is true, this method will always create the related target band with the raw data type ProductData.TYPE_FLOAT32, regardless which raw data type the source band has. In this case, targetBand.scalingFactor will always be 1.0, targetBand.scalingOffset will always be 0.0 and targetBand.log10Scaled will be taken from the source band. This ensures that source pixel resampling methods operating on floating point data can be stored without loss in accuracy in the target band.

Furthermore, the targetBands.noDataValueSet and targetBands.noDataValueUsed properties will always be true for all added target bands. The targetBands.geophysicalNoDataValue, will be either the one from the source band, if any, or otherwise the one passed into this method.

Parameters:
sourceProduct - the source product as the source for the band specifications. Must be not null.
targetProduct - the destination product to receive the bands created. Must be not null.
includeTiePointGrids - if true, tie-point grids of source product will be included as bands in target product
defaultNoDataValue - the default, geophysical no-data value to be used if no no-data value is used by the source band.
targetToSourceMap - a mapping from a target band to a source raster data node, can be null

getScanLineTime

public static ProductData.UTC getScanLineTime(Product product,
                                              double y)

getGeophysicalSampleDouble

public static double getGeophysicalSampleDouble(Band band,
                                                int pixelX,
                                                int pixelY,
                                                int level)

getGeophysicalSampleLong

public static long getGeophysicalSampleLong(Band band,
                                            int pixelX,
                                            int pixelY,
                                            int level)


Copyright © 2002-2012 Brockmann Consult GmbH. All Rights Reserved.