The RT_Extent function takes a raster column and returns a polygon column representing the axis-aligned bounding box of the raster. You can optionally specify a spatial reference so that the raster is projected into that spatial reference before its extent is calculated. The resulting polygon's coordinates are expressed in the defined spatial reference.
If the spatial reference is provided but the input raster has none, the function assumes that the raster's extent is already in that spatial reference.
If you want to set a new extent of a raster column, see RT_SetExtent.
| Function | Syntax |
|---|---|
| Python | extent(raster |
| SQL | RT |
| Scala | extent(raster, sr) |
For more details, go to the GeoAnalytics Engine API reference for extent.
Examples
from geoanalytics.raster import functions as RT
data = [(list(range(100)), )]
df = spark.createDataFrame(data, ["pixels"]) \
.withColumn("raster", RT.srid(RT.create_raster("pixels", 10, 10, "float32"), 4326))
df.select(RT.set_extent("raster", xmin=-122.57, ymin=47.34, xmax=-121.77, ymax=48.14).alias("set_extent")) \
.withColumn("extent", RT.extent("set_extent")).show(truncate=False)+---------------------------+---------------------------------------------------------------------------------------------+
|set_extent |extent |
+---------------------------+---------------------------------------------------------------------------------------------+
|SqlRaster(1x10x10, Float32)|{"rings":[[[-122.57,47.34],[-122.57,48.14],[-121.77,48.14],[-121.77,47.34],[-122.57,47.34]]]}|
+---------------------------+---------------------------------------------------------------------------------------------+Version table
| Release | Notes |
|---|---|
2.0.0 | Python, SQL, and Scala functions introduced |