You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sedona.apache.org by ji...@apache.org on 2023/09/20 07:55:36 UTC
[sedona] branch master updated: [SEDONA-396] Add RS_SetValues Geometry variant (#1022)
This is an automated email from the ASF dual-hosted git repository.
jiayu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sedona.git
The following commit(s) were added to refs/heads/master by this push:
new dad4d9973 [SEDONA-396] Add RS_SetValues Geometry variant (#1022)
dad4d9973 is described below
commit dad4d99734ded7d55e9bcaf08b1a3bc4e90741d0
Author: Furqaanahmed Khan <46...@users.noreply.github.com>
AuthorDate: Wed Sep 20 03:55:30 2023 -0400
[SEDONA-396] Add RS_SetValues Geometry variant (#1022)
---
.../sedona/common/raster/PixelFunctionEditors.java | 164 ++++++++++++++++++++-
.../sedona/common/raster/FunctionEditorsTest.java | 46 ++++++
docs/api/sql/Raster-operators.md | 30 +++-
.../expressions/raster/PixelFunctionEditors.scala | 3 +-
.../org/apache/sedona/sql/rasteralgebraTest.scala | 20 +++
5 files changed, 252 insertions(+), 11 deletions(-)
diff --git a/common/src/main/java/org/apache/sedona/common/raster/PixelFunctionEditors.java b/common/src/main/java/org/apache/sedona/common/raster/PixelFunctionEditors.java
index b5c47af95..e09595e63 100644
--- a/common/src/main/java/org/apache/sedona/common/raster/PixelFunctionEditors.java
+++ b/common/src/main/java/org/apache/sedona/common/raster/PixelFunctionEditors.java
@@ -19,7 +19,13 @@
package org.apache.sedona.common.raster;
import org.apache.sedona.common.utils.RasterUtils;
+import org.geotools.coverage.grid.GridCoordinates2D;
import org.geotools.coverage.grid.GridCoverage2D;
+import org.geotools.geometry.DirectPosition2D;
+import org.locationtech.jts.geom.Coordinate;
+import org.locationtech.jts.geom.Geometry;
+import org.opengis.referencing.FactoryException;
+import org.opengis.referencing.operation.TransformException;
import javax.media.jai.RasterFactory;
import java.awt.*;
@@ -29,18 +35,25 @@ import java.awt.image.WritableRaster;
public class PixelFunctionEditors {
+ /**
+ * Returns a raster by replacing the values of pixels in a specified rectangular region.
+ * @param raster Raster to be edited
+ * @param band Band of the raster to be edited
+ * @param colX UpperLeftX of the region
+ * @param rowY UpperLeftY of the region
+ * @param width Width of the said region
+ * @param height Height of the said region
+ * @param values Array of values to be inserted into the said region
+ * @param keepNoData To keep No Data value or add the given value to the raster
+ * @return An updated Raster
+ */
public static GridCoverage2D setValues(GridCoverage2D raster, int band, int colX, int rowY, int width, int height, double[] values, boolean keepNoData) {
RasterUtils.ensureBand(raster, band);
if (values.length != width * height) {
throw new IllegalArgumentException("Shape of 'values' doesn't match provided width and height.");
}
- RenderedImage originalImage = raster.getRenderedImage();
- Raster rasterTemp = RasterUtils.getRaster(originalImage);
- Point location = rasterTemp.getBounds().getLocation();
- WritableRaster wr = RasterFactory.createBandedRaster(rasterTemp.getDataBuffer().getDataType(), originalImage.getWidth(), originalImage.getHeight(), raster.getNumSampleDimensions(), location);
-
- WritableRaster rasterCopied = raster.getRenderedImage().copyData(wr);
+ WritableRaster rasterCopied = makeCopiedRaster(raster);
Double noDataValue = null;
if (keepNoData) {
@@ -64,18 +77,153 @@ public class PixelFunctionEditors {
iterator++;
}
}
- return RasterUtils.create(wr, raster.getGridGeometry(), raster.getSampleDimensions());
+ return RasterUtils.create(rasterCopied, raster.getGridGeometry(), raster.getSampleDimensions());
}
+ /**
+ * Returns a raster by replacing the values of pixels in a specified rectangular region. Convenience function without keepNoData parameter.
+ * @param raster Raster to be edited
+ * @param band Band of the raster to be edited
+ * @param colX UpperLeftX of the region
+ * @param rowY UpperLeftY of the region
+ * @param width Width of the said region
+ * @param height Height of the said region
+ * @param values Array of values to be inserted into the said region
+ * @return An updated Raster
+ */
public static GridCoverage2D setValues(GridCoverage2D raster, int band, int colX, int rowY, int width, int height, double[] values) {
return setValues(raster, band, colX, rowY, width, height, values, false);
}
-
+
+ /**
+ * Returns a raster by replacing the values of pixels in a specified geometry region. It converts the Geometry to a raster using RS_AsRaster.
+ * @param raster Raster to be edited
+ * @param band Band of the raster to be edited
+ * @param geom Geometry region to update
+ * @param value Value to updated in the said region
+ * @param keepNoData To keep no data value or not
+ * @return An updated raster
+ * @throws FactoryException
+ * @throws TransformException
+ */
+ public static GridCoverage2D setValues(GridCoverage2D raster, int band, Geometry geom, double value, boolean keepNoData) throws FactoryException, TransformException {
+ RasterUtils.ensureBand(raster, band);
+
+ String bandDataType = RasterBandAccessors.getBandType(raster, band);
+
+ GridCoverage2D rasterizedGeom;
+ Double noDataValue = null;
+
+ if (keepNoData) {
+ noDataValue = RasterBandAccessors.getBandNoDataValue(raster, band);
+ rasterizedGeom = RasterConstructors.asRaster(geom, raster, bandDataType, value, noDataValue);
+ } else {
+ rasterizedGeom = RasterConstructors.asRaster(geom, raster, bandDataType, value);
+ }
+
+ Raster rasterizedGeomData = RasterUtils.getRaster(rasterizedGeom.getRenderedImage());
+ double colX = RasterAccessors.getUpperLeftX(rasterizedGeom), rowY = RasterAccessors.getUpperLeftY(rasterizedGeom);
+ int height = RasterAccessors.getHeight(rasterizedGeom), width = RasterAccessors.getWidth(rasterizedGeom);
+ int heightOriginalRaster = RasterAccessors.getHeight(raster), widthOriginalRaster = RasterAccessors.getWidth(raster);
+ WritableRaster rasterCopied = makeCopiedRaster(raster);
+
+ String geometryType = geom.getGeometryType();
+
+ // Taking a shortcut if the provided geometry is a Point or MultiPoint, then taking the lat lon
+ if (geometryType.equalsIgnoreCase(Geometry.TYPENAME_POINT) || geometryType.equalsIgnoreCase(Geometry.TYPENAME_MULTIPOINT)) {
+ Coordinate[] coordinates = geom.getCoordinates();
+ for (Coordinate pointCoordinate: coordinates) {
+ int[] pointLocation = raster.getGridGeometry().worldToGrid(new DirectPosition2D(pointCoordinate.x, pointCoordinate.y)).getCoordinateValues();
+ double[] pixel = rasterCopied.getPixel(pointLocation[0], pointLocation[1], (double[]) null);
+ pixel[band - 1] = rasterizedGeomData.getPixel(0, 0, (double[]) null)[0];
+ rasterCopied.setPixel(pointLocation[0], pointLocation[1], pixel);
+ }
+ }
+ // Converting geometry to raster and then iterating through them
+ else {
+ // Starting pixel location on the given raster
+ int[] pixelLocation = RasterUtils.getGridCoordinatesFromWorld(raster, colX, rowY);
+ int x = pixelLocation[0], y = pixelLocation[1];
+
+ // lower-bound if the rasterized geometry starts at more north or west from the given raster than move rasterized geometry starting pixel accordingly.
+ if (x < 0) {
+ x = Math.abs(x);
+ }
+ if (y < 0) {
+ y = Math.abs(y);
+ }
+ // i & j is for main raster
+ // k & l is for rasterized geom
+ // added an upperbound if the rasterized geometry is bigger than provided raster
+ for (int j = 0, l = y; j < heightOriginalRaster && l < height; j++, l++) {
+ for (int i = 0, k = x; i < widthOriginalRaster && k < width; i++, k++) {
+ double[] pixel = rasterCopied.getPixel(i, j, (double[]) null);
+ // [0] as only one band in the rasterized Geometry
+ double pixelNew = rasterizedGeomData.getPixel(k, l, (double[]) null)[0];
+ if (pixelNew == 0 || keepNoData && noDataValue == pixel[band - 1]) {
+ continue;
+ } else {
+ pixel[band - 1] = pixelNew;
+ }
+ rasterCopied.setPixel(i, j, pixel);
+ }
+ }
+ }
+
+ return RasterUtils.create(rasterCopied, raster.getGridGeometry(), raster.getSampleDimensions());
+ }
+
+ /**
+ * Returns a raster by replacing the values of pixels in a specified geometry region. It converts the Geometry to a raster using RS_AsRaster. A convenience function with keepNoData as false.
+ * @param raster Input raster to be updated
+ * @param band Band of the raster to be edited
+ * @param geom Geometry region to update
+ * @param value Value to updated in the said region
+ * @return An updated raster
+ * @throws FactoryException
+ * @throws TransformException
+ */
+ public static GridCoverage2D setValues(GridCoverage2D raster, int band, Geometry geom, double value) throws FactoryException, TransformException {
+ return setValues(raster, band, geom, value, false);
+ }
+
+ /**
+ * Return a raster by updated the pixel specified by pixel location.
+ * @param raster Input raster to be edited
+ * @param band Band of the raster to be updated
+ * @param colX Column of the pixel
+ * @param rowY Row of the pixel
+ * @param newValue New value to be updated
+ * @return An updated raster
+ */
public static GridCoverage2D setValue(GridCoverage2D raster, int band, int colX, int rowY, double newValue) {
return setValues(raster, band, colX, rowY, 1, 1, new double[]{newValue}, false);
}
+ /**
+ * Return a raster by updated the pixel specified by pixel location.
+ * @param raster Input raster to be edited
+ * @param colX Column of the pixel
+ * @param rowY Row of the pixel
+ * @param newValue New value to be updated
+ * @return An updated raster
+ */
public static GridCoverage2D setValue(GridCoverage2D raster, int colX, int rowY, double newValue) {
return setValues(raster, 1, colX, rowY, 1, 1, new double[]{newValue}, false);
}
+
+
+ /**
+ * It copies the raster given to a new WritableRaster object.
+ * @param raster Raster to be copied
+ * @return A WritableRaster object
+ */
+ private static WritableRaster makeCopiedRaster(GridCoverage2D raster) {
+ RenderedImage originalImage = raster.getRenderedImage();
+ Raster rasterTemp = RasterUtils.getRaster(originalImage);
+ Point location = rasterTemp.getBounds().getLocation();
+ WritableRaster wr = RasterFactory.createBandedRaster(rasterTemp.getDataBuffer().getDataType(), originalImage.getWidth(), originalImage.getHeight(), raster.getNumSampleDimensions(), location);
+
+ return raster.getRenderedImage().copyData(wr);
+ }
}
diff --git a/common/src/test/java/org/apache/sedona/common/raster/FunctionEditorsTest.java b/common/src/test/java/org/apache/sedona/common/raster/FunctionEditorsTest.java
index c5292dd39..9258d6e18 100644
--- a/common/src/test/java/org/apache/sedona/common/raster/FunctionEditorsTest.java
+++ b/common/src/test/java/org/apache/sedona/common/raster/FunctionEditorsTest.java
@@ -18,9 +18,15 @@
*/
package org.apache.sedona.common.raster;
+import org.apache.sedona.common.Constructors;
import org.geotools.coverage.grid.GridCoverage2D;
import org.junit.Test;
+import org.locationtech.jts.geom.Geometry;
+import org.locationtech.jts.io.ParseException;
import org.opengis.referencing.FactoryException;
+import org.opengis.referencing.operation.TransformException;
+
+import java.util.Arrays;
import static org.junit.Assert.*;
@@ -43,6 +49,46 @@ public class FunctionEditorsTest extends RasterTestBase {
assertArrayEquals(actual, expected, 0.0);
}
+ @Test
+ public void testSetValuesGeomVariant() throws FactoryException, ParseException, TransformException {
+ GridCoverage2D emptyRaster = RasterConstructors.makeEmptyRaster(1, 4, 6, 1, -1, 1, -1, 0, 0, 0);
+ double[] values = new double[] {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
+ emptyRaster = MapAlgebra.addBandFromArray(emptyRaster, values, 1);
+ Geometry geom = Constructors.geomFromWKT("LINESTRING(1 -1, 1 -4, 2 -2, 3 -3, 4 -4, 5 -4, 6 -6)", 0);
+ GridCoverage2D raster = PixelFunctionEditors.setValues(emptyRaster, 1, geom, 4235, false);
+ double[] actual = MapAlgebra.bandAsArray(raster, 1);
+ double[] expected = new double[] {4235.0, 0.0, 0.0, 0.0, 4235.0, 4235.0, 0.0, 0.0, 4235.0, 4235.0, 4235.0, 0.0, 4235.0, 0.0, 0.0, 4235.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
+ assertArrayEquals(expected, actual, 0.1d);
+
+ // Point
+ geom = Constructors.geomFromWKT("POINT(5 -5)", 0);
+ raster = PixelFunctionEditors.setValues(emptyRaster, 1, geom, 35);
+ actual = MapAlgebra.bandAsArray(raster, 1);
+ expected = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 35.0, 0.0, 0.0, 0.0, 0.0};
+ assertArrayEquals(expected, actual, 0.1d);
+
+ // MultiPoint
+ geom = Constructors.geomFromWKT("MULTIPOINT((2 -2), (2 -1), (3 -3), (4 -7))", 0);
+ raster = PixelFunctionEditors.setValues(emptyRaster, 1, geom, 400, false);
+ actual = MapAlgebra.bandAsArray(raster, 1);
+ expected = new double[] {0.0, 400.0, 0.0, 0.0, 0.0, 400.0, 0.0, 0.0, 0.0, 0.0, 400.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 400.0};
+ assertArrayEquals(expected, actual, 0.1d);
+
+ // Polygon
+ geom = Constructors.geomFromWKT("POLYGON((1 -1, 3 -3, 6 -6, 4 -1, 1 -1))", 0);
+ raster = PixelFunctionEditors.setValues(emptyRaster, 1, geom, 255, false);
+ actual = MapAlgebra.bandAsArray(raster, 1);
+ expected = new double[] {255.0, 255.0, 255.0, 0.0, 0.0, 255.0, 255.0, 255.0, 0.0, 0.0, 255.0, 255.0, 0.0, 0.0, 0.0, 255.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
+ assertArrayEquals(expected, actual, 0.1d);
+
+ // Polygon bigger than raster
+ geom = Constructors.geomFromWKT("POLYGON((-1 1, 3 4, 4 -4, 5 -5, 9 -9, -1 1))", 0);
+ raster = PixelFunctionEditors.setValues(emptyRaster, 1, geom, 56);
+ actual = MapAlgebra.bandAsArray(raster, 1);
+ expected = new double[] {56.0, 56.0, 56.0, 0.0, 0.0, 56.0, 56.0, 0.0, 0.0, 0.0, 56.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
+ assertArrayEquals(expected, actual, 0.1d);
+ }
+
@Test
public void testSetValueWithEmptyRaster() throws FactoryException {
GridCoverage2D emptyRaster = RasterConstructors.makeEmptyRaster(1, 5, 5, 0, 0, 1, -1, 0, 0, 0);
diff --git a/docs/api/sql/Raster-operators.md b/docs/api/sql/Raster-operators.md
index 6398d8a97..0ded80392 100644
--- a/docs/api/sql/Raster-operators.md
+++ b/docs/api/sql/Raster-operators.md
@@ -1060,11 +1060,17 @@ Format:
RS_SetValues(raster: Raster, bandIndex: Integer, colX: Integer, rowY: Integer, width: Integer, height: Integer, newValues: Array<Double>, keepNoData: Boolean = false)
```
+```
+RS_SetValues(raster: Raster, bandIndex: Integer, geom: Geometry, newValue: Double, keepNoData: Boolean = false)
+```
+
Since: `v1.5.0`
The `colX`, `rowY`, and `bandIndex` are 1-indexed. If `keepNoData` is `true`, the pixels with NoData value will not be
set to the corresponding value in `newValues`. The `newValues` should be provided in rows.
+The geometry variant of this function accepts all types of Geometries and it sets the `newValue` in the specified region under the `geom`.
+
!!!note
If the shape of `newValues` doesn't match with provided `width` and `height`, `IllegalArgumentException` is thrown.
@@ -1078,7 +1084,7 @@ SELECT RS_BandAsArray(
RS_SetValues(
RS_AddBandFromArray(
RS_MakeEmptyRaster(1, 5, 5, 0, 0, 1, -1, 0, 0, 0),
- [1,1,1,0,0,0,1,2,3,3,5,6,7,0,0,3,0,0,3,0,0,0,0,0,0], 1, 0d
+ Array(1,1,1,0,0,0,1,2,3,3,5,6,7,0,0,3,0,0,3,0,0,0,0,0,0), 1, 0d
),
1, 2, 2, 3, 3, [11,12,13,14,15,16,17,18,19]
)
@@ -1088,7 +1094,27 @@ SELECT RS_BandAsArray(
Output:
```
-[1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 11.0, 12.0, 13.0, 3.0, 5.0, 14.0, 15.0, 16.0, 0.0, 3.0, 17.0, 18.0, 19.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
+Array(1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 11.0, 12.0, 13.0, 3.0, 5.0, 14.0, 15.0, 16.0, 0.0, 3.0, 17.0, 18.0, 19.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)
+```
+
+Spark SQL Example:
+
+```sql
+SELECT RS_BandAsArray(
+ RS_SetValues(
+ RS_AddBandFromArray(
+ RS_MakeEmptyRaster(1, 5, 5, 1, -1, 1, -1, 0, 0, 0),
+ Array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), 1
+ ),
+ 1, ST_GeomFromWKT('POLYGON((1 -1, 3 -3, 6 -6, 4 -1, 1 -1))'), 255, false
+ )
+ )
+```
+
+Output:
+
+```
+Array(255.0, 255.0, 255.0, 0.0, 0.0, 0.0, 255.0, 255.0, 255.0, 0.0, 0.0, 0.0, 255.0, 255.0, 0.0, 0.0, 0.0, 0.0, 255.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)
```
### RS_SetSRID
diff --git a/spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/expressions/raster/PixelFunctionEditors.scala b/spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/expressions/raster/PixelFunctionEditors.scala
index 824f9a7b2..e191fc9d5 100644
--- a/spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/expressions/raster/PixelFunctionEditors.scala
+++ b/spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/expressions/raster/PixelFunctionEditors.scala
@@ -25,7 +25,8 @@ import org.apache.spark.sql.sedona_sql.expressions.InferredExpression
case class RS_SetValues(inputExpressions: Seq[Expression]) extends InferredExpression(
inferrableFunction8(PixelFunctionEditors.setValues),
- inferrableFunction7(PixelFunctionEditors.setValues)
+ inferrableFunction7(PixelFunctionEditors.setValues), inferrableFunction5(PixelFunctionEditors.setValues),
+ inferrableFunction4(PixelFunctionEditors.setValues)
) {
protected def withNewChildrenInternal(newChildren: IndexedSeq[Expression]) = {
copy(inputExpressions = newChildren)
diff --git a/spark/common/src/test/scala/org/apache/sedona/sql/rasteralgebraTest.scala b/spark/common/src/test/scala/org/apache/sedona/sql/rasteralgebraTest.scala
index 6f022df87..50b9d8f65 100644
--- a/spark/common/src/test/scala/org/apache/sedona/sql/rasteralgebraTest.scala
+++ b/spark/common/src/test/scala/org/apache/sedona/sql/rasteralgebraTest.scala
@@ -386,6 +386,26 @@ class rasteralgebraTest extends TestBaseScala with BeforeAndAfter with GivenWhen
assert(expected.equals(actual))
}
+ it("Passed RS_SetValues with empty raster geom variant") {
+ var inputDf = Seq((Seq(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0))).toDF("band")
+ inputDf = inputDf.selectExpr("RS_AddBandFromArray(RS_MakeEmptyRaster(1, 5, 5, 1, -1, 1, -1, 0, 0, 0), band, 1) as raster")
+ var actual = inputDf.selectExpr("RS_BandAsArray(RS_SetValues(raster, 1, ST_GeomFromWKT('LINESTRING(1 -1, 1 -4, 2 -2, 3 -3, 4 -4, 5 -4, 6 -6)'), 255), 1)").first().getSeq(0)
+ var expected = Seq(255.0, 0.0, 0.0, 0.0, 0.0, 255.0, 255.0, 0.0, 0.0, 0.0, 255.0, 255.0, 255.0, 0.0, 0.0, 255.0, 0.0, 0.0, 255.0, 255.0, 0.0, 0.0, 0.0, 0.0, 255.0)
+ assert(expected.equals(actual))
+
+ actual = inputDf.selectExpr("RS_BandAsArray(RS_SetValues(raster, 1, ST_GeomFromWKT('POINT(2 -2)'), 25), 1)").first().getSeq(0)
+ expected = Seq(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 25.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)
+ assert(expected.equals(actual))
+
+ actual = inputDf.selectExpr("RS_BandAsArray(RS_SetValues(raster, 1, ST_GeomFromWKT('MULTIPOINT((2 -2), (2 -1), (3 -3))'), 400), 1)").first().getSeq(0)
+ expected = Seq(0.0, 400.0, 0.0, 0.0, 0.0, 0.0, 400.0, 0.0, 0.0, 0.0, 0.0, 0.0, 400.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)
+ assert(expected.equals(actual))
+
+ actual = inputDf.selectExpr("RS_BandAsArray(RS_SetValues(raster, 1, ST_GeomFromWKT('POLYGON((1 -1, 3 -3, 6 -6, 4 -1, 1 -1))'), 150), 1)").first().getSeq(0)
+ expected = Seq(150.0, 150.0, 150.0, 0.0, 0.0, 0.0, 150.0, 150.0, 150.0, 0.0, 0.0, 0.0, 150.0, 150.0, 0.0, 0.0, 0.0, 0.0, 150.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)
+ assert(expected.equals(actual))
+ }
+
it("Passed RS_SetValue with empty raster") {
var inputDF = Seq((Seq(1, 1, 1, 0, 0, 0, 1, 2, 3, 3, 5, 6, 7, 0, 0, 3, 0, 0, 3, 0, 0, 0, 0, 0, 0))).toDF("band")
var df = inputDF.selectExpr("RS_AddBandFromArray(RS_MakeEmptyRaster(1, 5, 5, 0, 0, 1, -1, 0, 0, 0), " +