furqaankhan commented on code in PR #1001:
URL: https://github.com/apache/sedona/pull/1001#discussion_r1316550496


##########
common/src/main/java/org/apache/sedona/common/raster/RasterBandAccessors.java:
##########
@@ -134,6 +135,25 @@ public static double[] getSummaryStats(GridCoverage2D 
raster) {
 //        return getSummaryStats(raster, 1, excludeNoDataValue);
 //    }
 
+    public static GridCoverage2D getBand(GridCoverage2D rasterGeom, int[] 
bands) throws FactoryException {
+        double[] metadata = RasterAccessors.metadata(rasterGeom);
+        GridCoverage2D resultRaster = 
RasterConstructors.makeEmptyRaster(bands.length, (int) metadata[2], (int) 
metadata[3],
+                metadata[0], metadata[1], metadata[4], metadata[5], 
metadata[6], metadata[7], (int) metadata[8]);
+        double[] curBandData;
+        Double noDataValue;
+        for (int curBand: bands) {
+            RasterUtils.ensureBand(rasterGeom, curBand);
+            curBandData = MapAlgebra.bandAsArray(rasterGeom, curBand);
+            noDataValue = RasterBandAccessors.getBandNoDataValue(rasterGeom, 
curBand);
+            if (noDataValue != null) {
+                resultRaster = MapAlgebra.addBandFromArray(resultRaster, 
curBandData, curBand, noDataValue);

Review Comment:
   Sure, I was going to do that but I thought to reuse.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to