RT_CreateRaster takes a list column, two numeric columns and a string column and returns a raster column.
The list represents the cell (pixel) values, the numeric colums represent the number of rows and columns in the raster and the string column represents the pixel type.
The function creates a raster using the specified input parameters. If no is specified, any pixel matching that value is treated as NoData in the resulting raster.
If the input values contain None values, they should be replaced with the NoData value prior to calling the RT_CreateRaster function, otherwise any None values
will become 0.0 by default, which may not be the NoData value.
The supported pixel types are: uint1, uint2, uint4, uint8, uint16, uint32, int8, int16, int32, float32 and float64.
The short version of pixel type is also supported. For example, u1 can be used instead of uint1 or f32 instead of float32.
Also, the pixel type representation is bit-based. For example, u1 is one bit and not one byte, which means that it uses one bit per pixel.
| Function | Syntax |
|---|---|
| Python | create |
| SQL | RT |
| Scala | create |
For more details, go to the GeoAnalytics Engine API reference for create_raster.
Examples
from geoanalytics.raster import functions as RT
data = [([1,2,3,4], )]
df = spark.createDataFrame(data, ["pixels"]) \
.withColumn("raster", RT.create_raster("pixels", 2, 2, "float32"))
df.select("raster").withColumn("pixels", RT.band_values("raster", 1)).show(truncate=False)+-------------------------+--------------------+
|raster |pixels |
+-------------------------+--------------------+
|SqlRaster(1x2x2, Float32)|[1.0, 2.0, 3.0, 4.0]|
+-------------------------+--------------------+Version table
| Release | Notes |
|---|---|
2.0.0 | Python, SQL, and Scala functions introduced |