Skip to content

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.

FunctionSyntax
Pythonextent(raster_col, sr=None)
SQLRT_Extent(raster_col, sr)
Scalaextent(raster, sr)

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

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.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)
Result
Use dark colors for code blocksCopy
1
2
3
4
5
+---------------------------+---------------------------------------------------------------------------------------------+
|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

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.