RS_TileExplode¶
Introduction: Generates records containing raster tiles resulting from the split of the input raster based upon the desired dimensions of the output rasters.
Format: RS_TileExplode(raster: Raster, width: Int, height: Int, padWithNoData: Boolean = false, noDataVal: Double = null)
Format: RS_TileExplode(raster: Raster, bandIndex: Int, width: Int, height: Int, padWithNoData: Boolean = false, noDataVal: Double = null)
Format: RS_TileExplode(raster: Raster, bandIndices: Array[Int], width: Int, height: Int, padWithNoData: Boolean = false, noDataVal: Double = null)
Return type: Struct<x: Integer, y: Integer, tile: Raster>
Since: v1.5.0
width and height specifies the size of generated tiles. If bandIndices is NULL or not specified, all bands will be included in the output tiles,
otherwise bands specified by bandIndices will be included. bandIndex can be specified if there is only one selected band, which is equivalent to
specifying bandIndices as ARRAY(bandIndex).Band indices are 1-based.
If padWithNoData = false, edge tiles on the right and bottom sides of the raster may have different dimensions than the rest of
the tiles. If padWithNoData = true, all tiles will have the same dimensions with the possibility that edge tiles being padded with
NODATA values. If raster band(s) do not have NODATA value(s) specified, one can be specified by setting noDataVal.
The returned records have the following schema:
x: The index of the tile along X axis (0-based).y: The index of the tile along Y axis (0-based).tile: The tile.
For large GeoTIFFs in a binaryFile DataFrame, nest RS_FromGeoTiff directly inside RS_TileExplode:
SELECT RS_TileExplode(RS_FromGeoTiff(content), 256, 256)
FROM binary_rasters
Here, binary_rasters is a view of the binaryFile DataFrame. RS_TileExplode accepts a Raster, so raw TIFF bytes such as content must first pass through RS_FromGeoTiff. Nesting the calls avoids serializing the whole raster as one value. Materializing the whole raster first, for example by caching or writing it, can exceed the single raster size limit before tiling runs. Each resulting tile must also fit within that limit.
SQL example:
WITH raster_table AS (SELECT RS_MakeEmptyRaster(1, 6, 6, 300, 400, 10) rast)
SELECT RS_TileExplode(rast, 2, 2) FROM raster_table
Output:
+---+---+--------------------+
| x| y| tile|
+---+---+--------------------+
| 0| 0|GridCoverage2D["g...|
| 1| 0|GridCoverage2D["g...|
| 2| 0|GridCoverage2D["g...|
| 0| 1|GridCoverage2D["g...|
| 1| 1|GridCoverage2D["g...|
| 2| 1|GridCoverage2D["g...|
| 0| 2|GridCoverage2D["g...|
| 1| 2|GridCoverage2D["g...|
| 2| 2|GridCoverage2D["g...|
+---+---+--------------------+