RT_Tiles takes a raster column and two numeric columns that represent the desired number of columns and rows in each tile of the raster. It returns a column with an array of rasters created by tiling the input raster into smaller sections. Each tile is defined by the specified number of columns and rows. Some tiles may contain fewer columns and rows than specified, depending on the remaining cells in the raster. This occurs when the total number of cells in the raster is not evenly divisible by the specified tile dimensions, resulting in smaller tiles at the edges of the raster. By default, the function will not overlap tiles. You can optionally specify an overlap greater than 0 for the tiles to overlap. The function will start tiling from the top left side of the raster.
| Function | Syntax |
|---|---|
| Python | tiles(raster |
| SQL | RT |
| Scala | tiles(raster, num |
For more details, go to the GeoAnalytics Engine API reference for tiles.
Examples
from geoanalytics.raster import functions as RT
data = [(list(range(100)), )]
df = spark.createDataFrame(data, ["pixels"]) \
.withColumn("raster", RT.create_raster("pixels", 10, 10, "float32"))
# Create four 5x5 tiles
df.select("raster", RT.tiles("raster", width_in_pixels=5, height_in_pixels=5).alias("tiles")).show(truncate=False)+---------------------------+------------------------------------------------------------------------------------------------------------+
|raster |tiles |
+---------------------------+------------------------------------------------------------------------------------------------------------+
|SqlRaster(1x10x10, Float32)|[SqlRaster(1x5x5, Float32), SqlRaster(1x5x5, Float32), SqlRaster(1x5x5, Float32), SqlRaster(1x5x5, Float32)]|
+---------------------------+------------------------------------------------------------------------------------------------------------+Version table
| Release | Notes |
|---|---|
2.0.0 | Python, SQL, and Scala functions introduced |