RT_Materialize takes a raster column and returns a raster column. Raster columns returned by the datasource may be lazily evaluated reference rasters, only holding the source file path and a tile offset. This function will force evaluation of that reference and load its pixels into memory. This is useful for repeated calculations like RT_ZonalStatistics where the same raster may be needed for multiple polygons and materializing the raster ahead of the statistics calculation will avoid duplicate reads. For more information see raster references.
| Function | Syntax |
|---|---|
| Python | materialize(raster |
| SQL | RT |
| Scala | materialize(raster) |
For more details, go to the GeoAnalytics Engine API reference for materialize.
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_materialize = df.select(RT.materialize("raster").alias("materialize"))
df_materialize.withColumn("materialize_pixels", RT.band_values("materialize", 1)).show(truncate=False)+-------------------------+--------------------+
|materialize |materialize_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 |