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.
| Function | Syntax |
|---|---|
| Python | bbox |
| SQL | RT |
| Scala | b |
For more details, go to the GeoAnalytics Engine API reference for bbox_clip.
Examples
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
+-------------------------+----------------+
|bbox_clip |bbox_clip_pixels|
+-------------------------+----------------+
|SqlRaster(1x2x1, Float32)|[0.0, 1.0] |
+-------------------------+----------------+Version table
| Release | Notes |
|---|---|
2.0.0 | Python, SQL, and Scala functions introduced |