Package org.apache.sedona.common.raster
Class MapAlgebra
java.lang.Object
org.apache.sedona.common.raster.MapAlgebra
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic double[]add(double[] band1, double[] band2) static org.geotools.coverage.grid.GridCoverage2DaddBandFromArray(org.geotools.coverage.grid.GridCoverage2D rasterGeom, double[] bandValues) Adds a new band to the given raster, using the given array as the band values.static org.geotools.coverage.grid.GridCoverage2DaddBandFromArray(org.geotools.coverage.grid.GridCoverage2D rasterGeom, double[] bandValues, int bandIndex) static org.geotools.coverage.grid.GridCoverage2DaddBandFromArray(org.geotools.coverage.grid.GridCoverage2D rasterGeom, double[] bandValues, int bandIndex, Double noDataValue) Adds a new band to the given raster, using the given array as the band values.static double[]bandAsArray(org.geotools.coverage.grid.GridCoverage2D rasterGeom, int bandIndex) Returns the values of the given band as a 1D array.static double[]bitwiseAnd(double[] band1, double[] band2) static double[]bitwiseOr(double[] band1, double[] band2) static intcountValue(double[] band, double target) static double[]divide(double[] band1, double[] band2) static double[]fetchRegion(double[] band, int[] coordinates, int[] dimension) static double[]greaterThan(double[] band, double target) static double[]greaterThanEqual(double[] band, double target) static double[]lessThan(double[] band, double target) static double[]lessThanEqual(double[] band, double target) static double[]logicalDifference(double[] band1, double[] band2) static double[]logicalOver(double[] band1, double[] band2) static org.geotools.coverage.grid.GridCoverage2DmapAlgebra(org.geotools.coverage.grid.GridCoverage2D gridCoverage2D, String pixelType, String script) static org.geotools.coverage.grid.GridCoverage2DmapAlgebra(org.geotools.coverage.grid.GridCoverage2D gridCoverage2D, String pixelType, String script, Double noDataValue) Applies a map algebra script to the given raster.static org.geotools.coverage.grid.GridCoverage2DmapAlgebra(org.geotools.coverage.grid.GridCoverage2D rast0, org.geotools.coverage.grid.GridCoverage2D rast1, String pixelType, String script, Double noDataValue) static doublemean(double[] band) static double[]mode(double[] band) static double[]modulo(double[] band, double dividend) static double[]multiply(double[] band1, double[] band2) static double[]multiplyFactor(double[] band, double factor) static double[]normalize(double[] bandValues) static double[]normalizedDifference(double[] band1, double[] band2) static double[]squareRoot(double[] band) static double[]subtract(double[] band1, double[] band2)
-
Constructor Details
-
MapAlgebra
public MapAlgebra()
-
-
Method Details
-
bandAsArray
public static double[] bandAsArray(org.geotools.coverage.grid.GridCoverage2D rasterGeom, int bandIndex) Returns the values of the given band as a 1D array.- Parameters:
rasterGeom-bandIndex- starts at 1- Returns:
-
addBandFromArray
public static org.geotools.coverage.grid.GridCoverage2D addBandFromArray(org.geotools.coverage.grid.GridCoverage2D rasterGeom, double[] bandValues, int bandIndex, Double noDataValue) Adds a new band to the given raster, using the given array as the band values.- Parameters:
rasterGeom-bandValues-bandIndex- starts at 1, and no larger than numBands + 1- Returns:
-
addBandFromArray
public static org.geotools.coverage.grid.GridCoverage2D addBandFromArray(org.geotools.coverage.grid.GridCoverage2D rasterGeom, double[] bandValues, int bandIndex) -
addBandFromArray
public static org.geotools.coverage.grid.GridCoverage2D addBandFromArray(org.geotools.coverage.grid.GridCoverage2D rasterGeom, double[] bandValues) Adds a new band to the given raster, using the given array as the band values. The new band is appended to the end.- Parameters:
rasterGeom-bandValues-- Returns:
-
mapAlgebra
public static org.geotools.coverage.grid.GridCoverage2D mapAlgebra(org.geotools.coverage.grid.GridCoverage2D gridCoverage2D, String pixelType, String script, Double noDataValue) Applies a map algebra script to the given raster.- Parameters:
gridCoverage2D- The raster to apply the script topixelType- The pixel type of the output raster. If null, the pixel type of the input raster is used.script- The script to applynoDataValue- The no data value of the output raster.- Returns:
- The result of the map algebra script
-
mapAlgebra
-
mapAlgebra
-
add
public static double[] add(double[] band1, double[] band2) - Parameters:
band1- band valuesband2- band values- Returns:
- a sum of the provided band values
-
subtract
public static double[] subtract(double[] band1, double[] band2) - Parameters:
band1- band valuesband2- band values- Returns:
- result of subtraction of the two bands, (band2 - band1).
-
multiply
public static double[] multiply(double[] band1, double[] band2) - Parameters:
band1- band valuesband2- band values- Returns:
- result of multiplication of the two bands.
-
divide
public static double[] divide(double[] band1, double[] band2) - Parameters:
band1- band valuesband2- band values- Returns:
- result of subtraction of the two bands, (band1 / band2).
-
multiplyFactor
public static double[] multiplyFactor(double[] band, double factor) - Parameters:
band- band valuesfactor- multiplying factor- Returns:
- an array where all the elements has been multiplied with the factor given.
-
modulo
public static double[] modulo(double[] band, double dividend) - Parameters:
band- band valuesdividend- dividend for modulo- Returns:
- an array with modular remainders calculated from the given dividend
-
squareRoot
public static double[] squareRoot(double[] band) - Parameters:
band- band values- Returns:
- an array, where each pixel has been applied square root operation.
-
bitwiseAnd
public static double[] bitwiseAnd(double[] band1, double[] band2) - Parameters:
band1- band valuesband2- band values- Returns:
- an array, where each pixel is result of bitwise AND operator from provided 2 bands.
-
bitwiseOr
public static double[] bitwiseOr(double[] band1, double[] band2) - Parameters:
band1- band valuesband2- band values- Returns:
- an array, where each pixel is result of bitwise OR operator from provided 2 bands.
-
logicalDifference
public static double[] logicalDifference(double[] band1, double[] band2) - Parameters:
band1- band valuesband2- band values- Returns:
- an array; if a value at an index in band1 is different in band2 then band1 value is taken otherwise 0.
-
logicalOver
public static double[] logicalOver(double[] band1, double[] band2) - Parameters:
band1- band valuesband2- band values- Returns:
- an array; if a value at an index in band1 is not equal to 0 then band1 value will be taken otherwise band2's value
-
normalize
public static double[] normalize(double[] bandValues) - Parameters:
bandValues- band values- Returns:
- an array with normalized band values to be within [0 - 255] range
-
normalizedDifference
public static double[] normalizedDifference(double[] band1, double[] band2) - Parameters:
band1- band valuesband2- band values- Returns:
- an array with the normalized difference of the provided bands
-
mean
public static double mean(double[] band) - Parameters:
band- band values- Returns:
- mean of the band values
-
fetchRegion
public static double[] fetchRegion(double[] band, int[] coordinates, int[] dimension) - Parameters:
band- band valuescoordinates- defines the region by minX, maxX, minY, and maxY respectivelydimension- dimensions- Returns:
- an array of the specified region
-
mode
public static double[] mode(double[] band) - Parameters:
band- band values- Returns:
- an array with the most reoccurring value or if every value occurs once then return the provided array
-
greaterThan
public static double[] greaterThan(double[] band, double target) - Parameters:
band- band valuestarget- target to compare- Returns:
- an array; mark all band values 1 that are greater than target, otherwise 0
-
greaterThanEqual
public static double[] greaterThanEqual(double[] band, double target) - Parameters:
band- band valuestarget- target to compare- Returns:
- an array; mark all band values 1 that are greater than or equal to target, otherwise 0
-
lessThan
public static double[] lessThan(double[] band, double target) - Parameters:
band- band valuestarget- target to compare- Returns:
- an array; mark all band values 1 that are less than target, otherwise 0
-
lessThanEqual
public static double[] lessThanEqual(double[] band, double target) - Parameters:
band- band valuestarget- target to compare- Returns:
- an array; mark all band values 1 that are less than or equal to target, otherwise 0
-
countValue
public static int countValue(double[] band, double target) - Parameters:
band- band valuestarget- target to count- Returns:
- count of the target in the band values
-