Skip to content

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_data_value 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.

FunctionSyntax
Pythoncreate_raster(pixels, num_cols, num_rows, pixel_type, no_data_value=None)
SQLRT_CreateRaster(pixels, num_cols, num_rows, pixel_type, no_data_value)
ScalacreateRaster(pixels, numCols, numRows, pixelType, noDataValue)

For more details, go to the GeoAnalytics Engine API reference for create_raster.

Examples

PythonPythonSQLScala
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8

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)
Result
Use dark colors for code blocksCopy
1
2
3
4
5
+-------------------------+--------------------+
|raster                   |pixels              |
+-------------------------+--------------------+
|SqlRaster(1x2x2, Float32)|[1.0, 2.0, 3.0, 4.0]|
+-------------------------+--------------------+

Version table

ReleaseNotes

2.0.0

Python, SQL, and Scala functions introduced

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.