prantogg commented on code in PR #1221: URL: https://github.com/apache/sedona/pull/1221#discussion_r1473332020
########## common/src/main/java/org/apache/sedona/common/raster/MapAlgebra.java: ########## @@ -437,6 +437,57 @@ public static double[] normalize(double[] band) { return result; } + /** + * + * @param rasterGeom Raster to be normalized + * @return a raster with all values in all bands normalized between [0 - 255] + */ + public static GridCoverage2D normalizeAll(GridCoverage2D rasterGeom) { + return normalizeAll(rasterGeom, 0d, 255d); + } + + /** + * + * @param rasterGeom Raster to be normalized + * @param minLim Lower limit of normalization range + * @param maxLim Upper limit of normalization range + * @return a raster with all values in all bands normalized between minLim and maxLim + */ + public static GridCoverage2D normalizeAll(GridCoverage2D rasterGeom, double minLim, double maxLim) { + if (minLim > maxLim) { + throw new IllegalArgumentException("minLim cannot be greater than maxLim"); + } + + int numBands = rasterGeom.getNumSampleDimensions(); + + for (int bandIndex = 1; bandIndex <= numBands; bandIndex++) { + // Get the band values as an array + double[] bandValues = bandAsArray(rasterGeom, bandIndex); + + // Find min and max values in the band + double minValue = Arrays.stream(bandValues).min().orElse(Double.NaN); + double maxValue = Arrays.stream(bandValues).max().orElse(Double.NaN); + System.out.println("minValue: "+minValue); + System.out.println("maxValue: "+maxValue); + + if (minValue == maxValue) { Review Comment: To handle all pixel data types, would having a pixelType argument like in RS_MapAlgebra help? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@sedona.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org