Class ProductUtils
- java.lang.Object
-
- org.esa.snap.core.util.ProductUtils
-
-
Constructor Summary
Constructors Constructor Description ProductUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addElementToHistory(Product product, MetadataElement elem)
Adds a given elem to the history of the given product.static boolean
areRastersEqualInSize(int width, int height, RasterDataNode... rasters)
This method checks whether the given rasters all have the same given width and height.static boolean
areRastersEqualInSize(Product product, String... rasterNames)
This method checks whether the rasters given by their names all have the same width and height.static boolean
areRastersEqualInSize(RasterDataNode... rasters)
This method checks whether the given rasters all have the same width and height.static ArrayList<GeneralPath>
assemblePathList(GeoPos[] geoPoints)
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 double[]
computeMinMaxY(PixelPos[] pixelPositions)
Computes the minimum and maximum y value of the givenPixelPos
array.static PixelPos[]
computeSourcePixelCoordinates(GeoCoding sourceGeoCoding, int sourceWidth, int sourceHeight, GeoCoding destGeoCoding, Rectangle destArea)
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 Band
copyBand(String sourceBandName, Product sourceProduct, 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, boolean copySourceImage)
Copies all bands which contain a flag-coding from the source product to the target product.static void
copyFlagBandsWithoutMasks(Product sourceProduct, Product targetProduct, boolean copySourceImage)
Copies all bands which contain a flag-coding from the source product to the target product, without copying all masksstatic 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 geo-coding from the source product to target product.static void
copyGeoCoding(Product sourceProduct, RasterDataNode targetRaster)
Deeply copies the geo-coding from the source raster data node to the target product.static void
copyGeoCoding(RasterDataNode sourceRaster, Product targetProduct)
Deeply copies the geo-coding from the source raster data node to the target product.static void
copyGeoCoding(RasterDataNode sourceRaster, RasterDataNode targetRaster)
Deeply copies the geo-coding from the source raster data node to the target raster data node.static void
copyImageGeometry(RasterDataNode sourceRaster, RasterDataNode targetRaster, boolean deepCopy)
Copies the geo-coding and image-to-model transformation from the source raster data node to the target raster data node.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
copyIndexCodings(Product source, Product target)
Copies the index codings from the source product to the target.static void
copyMasks(Product sourceProduct, Product targetProduct)
Copies theMask
s from the source product to the target product.static void
copyMasks(Product sourceProduct, Product targetProduct, String[] sourceMaskNames)
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 overlayMask
s 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
copyProductNodes(Product sourceProduct, Product targetProduct)
Copies all properties, except bands, from source product to the target product.static void
copyQuicklookBandName(Product source, Product target)
Copies the quicklook band name if not currently set and band also exists in targetstatic void
copyRasterDataNodeProperties(RasterDataNode sourceRaster, RasterDataNode targetRaster)
Copies all properties from source band to the target band.static void
copySampleCodingBands(Product sourceProduct, Product targetProduct, boolean copySourceImage)
Copies all bands which contain a flag-coding or an index-coding from the source product to the target product.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
copyTimeInformation(Product source, Product target)
Copies the time information of the source product to the target product.static void
copyVectorData(Product sourceProduct, Product targetProduct)
static VirtualBand
copyVirtualBand(Product target, VirtualBand srcBand, String name)
Copies a virtual band and keeps it as a virtual band The size of thesrcBand
is preserved .static VirtualBand
copyVirtualBand(Product target, VirtualBand srcBand, String name, boolean adaptToSceneRasterSize)
Copies a virtual band and keeps it as a virtual band Depending on the parameteradaptToSceneRasterSize
the size will either preserve the size of thesrcBand
or adapt the size of the target product.static BufferedImage
createColorIndexedImage(RasterDataNode rasterDataNode, ProgressMonitor pm)
Creates a greyscale image from the given{@link 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, ProgressMonitor pm)
Creates a density plot image from two raster data nodes.static GeoTIFFMetadata
createGeoTIFFMetadata(GeoCoding geoCoding, int width, int height)
static GeoTIFFMetadata
createGeoTIFFMetadata(Product product)
static ImageInfo
createImageInfo(RasterDataNode[] rasters, boolean assignMissingImageInfos, ProgressMonitor pm)
Creates image creation information.static BufferedImage
createRgbImage(RasterDataNode[] rasters, ImageInfo imageInfo, ProgressMonitor pm)
Creates a RGB image from the given array of{@link RasterDataNode}
s.static void
denormalizeGeoPolygon(GeoPos[] polygon)
Denormalizes the longitude values which have been normalized using thenormalizeGeoPolygon(GeoPos[])
method.static void
denormalizeGeoPos(GeoPos geoPos)
Denormalizes the longitude value of the given geographical position.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 String
getAvailableNodeName(String name, ProductNodeGroup<? extends ProductNode> nodeGroup)
Checks if the given name is already used within the specifiednodeGroup
, if so it returns a new name.static GeoPos
getCenterGeoPos(Product product)
static double
getGeophysicalSampleAsDouble(RasterDataNode raster, int pixelX, int pixelY, int level)
Gets the geophysical pixel value for the given raster at the given pixel coordinates for the given image pyramid level.static long
getGeophysicalSampleAsLong(RasterDataNode raster, int pixelX, int pixelY, int level)
Gets the geophysical pixel value for the given raster at the given pixel coordinates for the given image pyramid level.static ProductData.UTC
getPixelScanTime(Product product, double x, double y)
Gets the scan time of the current pixel, if available.static ProductData.UTC
getPixelScanTime(RasterDataNode node, double x, double y)
Gets the scan time of the current pixel, if available.static int
getRotationDirection(GeoPos[] polygon)
static ProductData.UTC
getScanLineTime(Product product, double y)
Gets the scan time of the specified line, if available.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, 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.
-
-
-
Method Detail
-
createImageInfo
public static ImageInfo createImageInfo(RasterDataNode[] rasters, boolean assignMissingImageInfos, ProgressMonitor pm)
Creates image creation information.- Parameters:
rasters
- The raster data nodes.assignMissingImageInfos
- iftrue
, it is ensured that to allRasterDataNode
s a validImageInfo
will be assigned.pm
- The progress monitor.- Returns:
- image information
- Since:
- BEAM 4.2
-
createRgbImage
public static BufferedImage createRgbImage(RasterDataNode[] rasters, ImageInfo imageInfo, ProgressMonitor pm) throws IOException
Creates a RGB image from the given array of{@link RasterDataNode}
s. The given arrayrasters
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 imagepm
- 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(ImageInfo)
-
createColorIndexedImage
public static BufferedImage createColorIndexedImage(RasterDataNode rasterDataNode, ProgressMonitor pm) throws IOException
Creates a greyscale image from the given{@link RasterDataNode}
.The method uses the given raster data node's image information (an instance of
{@link ImageInfo}
) to create the image.- Parameters:
rasterDataNode
- the raster data node, must not benull
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()
-
copyFlagCodings
public static void copyFlagCodings(Product source, Product target)
Copies the flag codings from the source product to the target.- Parameters:
source
- the source producttarget
- 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 codingtarget
- the target product- Returns:
- The flag coding.
-
copyIndexCodings
public static void copyIndexCodings(Product source, Product target)
Copies the index codings from the source product to the target.- Parameters:
source
- the source producttarget
- the target product
-
copyQuicklookBandName
public static void copyQuicklookBandName(Product source, Product target)
Copies the quicklook band name if not currently set and band also exists in target- Parameters:
source
- the source producttarget
- the target product
-
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 codingtarget
- the target product- Returns:
- The index coding.
-
copyMasks
public static void copyMasks(Product sourceProduct, Product targetProduct)
Copies theMask
s from the source product to the target product.The method does not copy any image geo-coding/geometry information. Use the
copyImageGeometry(RasterDataNode, RasterDataNode, boolean)
to do so.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 producttargetProduct
- the target product
-
copyMasks
public static void copyMasks(Product sourceProduct, Product targetProduct, String[] sourceMaskNames)
-
copyOverlayMasks
public static void copyOverlayMasks(Product sourceProduct, Product targetProduct)
Copies the overlayMask
s 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 producttargetProduct
- the target product
-
copyFlagBands
public static void copyFlagBands(Product sourceProduct, Product targetProduct, boolean copySourceImage)
Copies all bands which contain a flag-coding from the source product to the target product.- Parameters:
sourceProduct
- the source producttargetProduct
- the target productcopySourceImage
- whether the source image of the source band should be copied.- Since:
- BEAM 4.10
-
copyFlagBandsWithoutMasks
public static void copyFlagBandsWithoutMasks(Product sourceProduct, Product targetProduct, boolean copySourceImage)
Copies all bands which contain a flag-coding from the source product to the target product, without copying all masks- Parameters:
sourceProduct
- the source producttargetProduct
- the target productcopySourceImage
- whether the source image of the source band should be copied.
-
copySampleCodingBands
public static void copySampleCodingBands(Product sourceProduct, Product targetProduct, boolean copySourceImage)
Copies all bands which contain a flag-coding or an index-coding from the source product to the target product.- Parameters:
sourceProduct
- the source producttargetProduct
- the target productcopySourceImage
- whether the source image of the source band should be copied.- Since:
- SNAP 8.0
-
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.The method does not copy any image geo-coding/geometry information. Use the
copyImageGeometry(RasterDataNode, RasterDataNode, boolean)
to do so.- Parameters:
gridName
- the name of the tie-point grid to be copied.sourceProduct
- the source producttargetProduct
- 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.
-
copyVirtualBand
public static VirtualBand copyVirtualBand(Product target, VirtualBand srcBand, String name)
Copies a virtual band and keeps it as a virtual band The size of thesrcBand
is preserved .- Parameters:
target
- the target productto copy the virtual band to.srcBand
- the virtual band to copy.name
- the name of the new band.- Returns:
- the copy of the band.
-
copyVirtualBand
public static VirtualBand copyVirtualBand(Product target, VirtualBand srcBand, String name, boolean adaptToSceneRasterSize)
Copies a virtual band and keeps it as a virtual band Depending on the parameteradaptToSceneRasterSize
the size will either preserve the size of thesrcBand
or adapt the size of the target product.- Parameters:
target
- the target product to copy the virtual band to.srcBand
- the virtual band to copy.name
- the name of the new band.adaptToSceneRasterSize
- iftrue
the band will have the scene raster size of the target product, otherwise the size of thesrcBand
will be preserved- Returns:
- the copy of the band.
-
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.The method does not copy any image geo-coding/geometry information. Use the
copyImageGeometry(RasterDataNode, RasterDataNode, boolean)
to do so.- 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.The method does not copy any image geo-coding/geometry information. Use the
copyImageGeometry(RasterDataNode, RasterDataNode, boolean)
to do so.- 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 bandtargetRaster
- the target band- See Also:
copySpectralBandProperties(Band, Band)
-
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 bandtargetBand
- the target band- See Also:
copyRasterDataNodeProperties(RasterDataNode, RasterDataNode)
-
copyProductNodes
public static void copyProductNodes(Product sourceProduct, Product targetProduct)
Copies all properties, except bands, from source product to the target product. only those bands are copied which are used by copied properties. For example latitude and longitude bands of a pixel-based geo-coding.- Parameters:
sourceProduct
- the source producttargetProduct
- the target product
-
copyGeoCoding
public static void copyGeoCoding(Product sourceProduct, Product targetProduct)
Copies the geo-coding from the source product to target product.- Parameters:
sourceProduct
- the source producttargetProduct
- the target product- Throws:
IllegalArgumentException
- if one of the params isnull
.
-
copyGeoCoding
public static void copyGeoCoding(RasterDataNode sourceRaster, RasterDataNode targetRaster)
Deeply copies the geo-coding from the source raster data node to the target raster data node.- Parameters:
sourceRaster
- the source raster data nodetargetRaster
- the target raster data node- Throws:
IllegalArgumentException
- if one of the params isnull
.- Since:
- SNAP 2.0
-
copyGeoCoding
public static void copyGeoCoding(RasterDataNode sourceRaster, Product targetProduct)
Deeply copies the geo-coding from the source raster data node to the target product.- Parameters:
sourceRaster
- the source raster data nodetargetProduct
- the target product- Throws:
IllegalArgumentException
- if one of the params isnull
.- Since:
- SNAP 3.0
-
copyGeoCoding
public static void copyGeoCoding(Product sourceProduct, RasterDataNode targetRaster)
Deeply copies the geo-coding from the source raster data node to the target product.- Parameters:
sourceProduct
- the source producttargetRaster
- the target raster data node- Throws:
IllegalArgumentException
- if one of the params isnull
.- Since:
- SNAP 3.0
-
copyImageGeometry
public static void copyImageGeometry(RasterDataNode sourceRaster, RasterDataNode targetRaster, boolean deepCopy)
Copies the geo-coding and image-to-model transformation from the source raster data node to the target raster data node.- Parameters:
sourceRaster
- the source raster data nodetargetRaster
- the target raster data nodedeepCopy
- iftrue
copyGeoCoding(RasterDataNode, RasterDataNode)
is called, otherwise the target reference is set.- Since:
- SNAP 2.0
-
copyTiePointGrids
public static void copyTiePointGrids(Product sourceProduct, Product targetProduct)
Copies all tie point grids from one product to another.- Parameters:
sourceProduct
- the source producttargetProduct
- the target product
-
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, ProgressMonitor pm) throws IOException
Creates a density plot image from two raster data nodes.- Parameters:
raster1
- the first raster data nodesampleMin1
- the minimum sample value to be considered in the first rastersampleMax1
- the maximum sample value to be considered in the first rasterraster2
- the second raster data nodesampleMin2
- the minimum sample value to be considered in the second rastersampleMax2
- the maximum sample value to be considered in the second rasterroiMask
- an optional mask to be used as a ROI for the computationwidth
- the width of the output imageheight
- the height of the output imagebackground
- the background color of the output imageimage
- an image to be used as output image, ifnull
a new image is createdpm
- the progress monitor- Returns:
- the density plot image
- Throws:
IOException
- when an error occurred.
-
overlayMasks
public static BufferedImage overlayMasks(RasterDataNode raster, BufferedImage overlayBIm, 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 definitionsoverlayBIm
- 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()
-
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[])
-
denormalizeGeoPolygon
public static void denormalizeGeoPolygon(GeoPos[] polygon)
Denormalizes the longitude values which have been normalized using thenormalizeGeoPolygon(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)
Denormalizes the longitude value of the given geographical position.
-
getRotationDirection
public static int getRotationDirection(GeoPos[] polygon)
-
getAngleSum
public static double getAngleSum(GeoPos[] polygon)
-
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 isnull
.
-
copyTimeInformation
public static void copyTimeInformation(Product source, Product target)
Copies the time information of the source product to the target product.- Parameters:
source
- the source product.target
- the target product.- Throws:
NullPointerException
- if the source or the target product isnull
.- Since:
- SNAP 5.0
- See Also:
Product.getStartTime()
,Product.getEndTime()
,Product.getSceneTimeCoding()
-
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 isnull
.
-
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)
-
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. Ifnull
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.
-
getAvailableNodeName
public static String getAvailableNodeName(String name, ProductNodeGroup<? extends ProductNode> nodeGroup)
Checks if the given name is already used within the specifiednodeGroup
, if so it returns a new name.The new name is the given name appended by an index.
- Parameters:
name
- The name to check if it is already usednodeGroup
- The node group to check if it already contains thename
- Returns:
- The available name. Either the name given as argument it self or the name appended by an index.
-
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 double[] computeMinMaxY(PixelPos[] pixelPositions)
Computes the minimum and maximum y value of the givenPixelPos
array.- Parameters:
pixelPositions
- thePixelPos
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
ornull
if no minimum or maximum can be retrieved because there given array is empty. - Throws:
IllegalArgumentException
- if the given pixelPositions arenull
.
-
copyBandsForGeomTransform
public static void copyBandsForGeomTransform(Product sourceProduct, Product targetProduct, double defaultNoDataValue, Map<Band,RasterDataNode> addedRasterDataNodes)
Copies only the bands from source to target.
-
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 typeProductData.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 andtargetBand.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
andtargetBands.noDataValueUsed
properties will always be true for all added target bands. ThetargetBands.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 notnull
.targetProduct
- the destination product to receive the bands created. Must be notnull
.includeTiePointGrids
- iftrue
, tie-point grids of source product will be included as bands in target productdefaultNoDataValue
- 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 benull
-
assemblePathList
public static ArrayList<GeneralPath> assemblePathList(GeoPos[] geoPoints)
-
getScanLineTime
public static ProductData.UTC getScanLineTime(Product product, double y)
Gets the scan time of the specified line, if available. First thetime-coding
of the given product is used, if this doesn't provide time information or doesn't exist, theProduct.getStartTime()
andProduct.getEndTime()
are used.- Parameters:
product
- the product to look up the time information fromy
- the current y-location- Returns:
- the scan time of the pixel or
null
if no time information could be found.
-
getPixelScanTime
public static ProductData.UTC getPixelScanTime(RasterDataNode node, double x, double y)
Gets the scan time of the current pixel, if available. First thetime-coding
of the given node is used, if this doesn't provide time information the parent product is checked.- Parameters:
node
- the node to look up the time information fromx
- the current x-locationy
- the current y-location- Returns:
- the scan time of the pixel or
null
if no time information could be found.
-
getPixelScanTime
public static ProductData.UTC getPixelScanTime(Product product, double x, double y)
Gets the scan time of the current pixel, if available. First thetime-coding
of the given product is used, if this doesn't provide time information or doesn't exist, theProduct.getStartTime()
andProduct.getEndTime()
are used.- Parameters:
product
- the product to look up the time information fromx
- the current x-locationy
- the current y-location- Returns:
- the scan time of the pixel or
null
if no time information could be found.
-
getGeophysicalSampleAsDouble
public static double getGeophysicalSampleAsDouble(RasterDataNode raster, int pixelX, int pixelY, int level)
Gets the geophysical pixel value for the given raster at the given pixel coordinates for the given image pyramid level.- Parameters:
raster
- The raster.pixelX
- The pixel X coordinate within the image at the given image pyramid level.pixelY
- The pixel Y coordinate within the image at the given image pyramid level.level
- The image pyramid level.- Returns:
- The geophysical sample value as a 64-bit floating point value.
-
getGeophysicalSampleAsLong
public static long getGeophysicalSampleAsLong(RasterDataNode raster, int pixelX, int pixelY, int level)
Gets the geophysical pixel value for the given raster at the given pixel coordinates for the given image pyramid level.- Parameters:
raster
- The raster.pixelX
- The pixel X coordinate within the image at the given image pyramid level.pixelY
- The pixel Y coordinate within the image at the given image pyramid level.level
- The image pyramid level.- Returns:
- The geophysical sample value as a 64-bit integer value.
-
areRastersEqualInSize
public static boolean areRastersEqualInSize(RasterDataNode... rasters)
This method checks whether the given rasters all have the same width and height.- Parameters:
rasters
- The rasters to be checked.- Returns:
true
, if all rasters are equal in size.
-
areRastersEqualInSize
public static boolean areRastersEqualInSize(int width, int height, RasterDataNode... rasters)
This method checks whether the given rasters all have the same given width and height.- Parameters:
width
- The width that all rasters must have.height
- The height that all rasters must have.rasters
- The rasters to be checked.- Returns:
true
, if all rasters are equal in size.
-
areRastersEqualInSize
public static boolean areRastersEqualInSize(Product product, String... rasterNames) throws IllegalArgumentException
This method checks whether the rasters given by their names all have the same width and height.- Parameters:
product
- The product which contains the rasters.rasterNames
- The names of the rasters to be checked.- Returns:
true
, if all rasters are equal in size.- Throws:
IllegalArgumentException
-
-