Skip to content

RT_BBoxClip takes a raster column and four numeric values and returns a raster column. The four numeric values represent the minimum and maximum x,y-coordinates of an axis-aligned rectangle, also known as an envelope. The input raster is clipped using the area specified by these x,y-coordinates.

FunctionSyntax
Pythonbbox_clip(raster_col, xmin, ymin, xmax, ymax)
SQLRT_BBoxClip(raster_col, xmin, ymin, xmax, ymax)
ScalabBoxClip(raster, xmin, ymin, xmax, ymax)

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

Examples

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

from geoanalytics.raster import functions as RT

data = [(list(range(4)), )]
df = spark.createDataFrame(data, ["pixels"]) \
     .withColumn("raster", RT.srid(RT.create_raster("pixels", 2, 2, "float32"), 4326)) \
     .withColumn("extent", RT.set_extent("raster", xmin=-122.57, ymin=47.34, xmax=-121.77, ymax=48.14))

# Clip raster and show pixel values of clipped raster
df_bbox_clip = df.select(RT.bbox_clip("extent", xmin=-122.57, ymin=47.90, xmax=-121.77, ymax=48.01).alias("bbox_clip"))
df_bbox_clip.withColumn("bbox_clip_pixels", RT.band_values("bbox_clip", 1)).show(truncate=False)
Result
Use dark colors for code blocksCopy
1
2
3
4
5
+-------------------------+----------------+
|bbox_clip                |bbox_clip_pixels|
+-------------------------+----------------+
|SqlRaster(1x2x1, Float32)|[0.0, 1.0]      |
+-------------------------+----------------+

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.