Skip to content

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.

FunctionSyntax
Pythontiles(raster_col, width_in_pixels, height_in_pixels, overlap=0)
SQLRT_Tiles(raster_col, width_in_pixels, height_in_pixels, overlap)
Scalatiles(raster, numColumns, numRows, overlap)

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

Examples

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

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)
Result
Use dark colors for code blocksCopy
1
2
3
4
5
+---------------------------+------------------------------------------------------------------------------------------------------------+
|raster                     |tiles                                                                                                       |
+---------------------------+------------------------------------------------------------------------------------------------------------+
|SqlRaster(1x10x10, Float32)|[SqlRaster(1x5x5, Float32), SqlRaster(1x5x5, Float32), SqlRaster(1x5x5, Float32), SqlRaster(1x5x5, Float32)]|
+---------------------------+------------------------------------------------------------------------------------------------------------+

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.