Skip to content

RS_MinConvexHull

Returns the footprint of the raster’s data pixels: the polygon over the smallest pixel-aligned rectangle of the grid that holds every pixel not equal to its band’s nodata value. Returns null if no pixel holds data.

Usage

geometry RS_MinConvexHull(rast: raster)
geometry RS_MinConvexHull(rast: raster, band: integer)

Arguments

  • rast (raster): Input raster
  • band (integer): Band index (1-based). When omitted, a pixel holds data if any band holds data there.

Description

RS_MinConvexHull is RS_ConvexHull with the nodata margin trimmed off. The rectangle is aligned to the raster’s grid, so on a rotated or skewed raster the result follows the grid axes, like RS_ConvexHull. A band without a nodata value holds data everywhere, so it spans the whole grid. Only 2-D rasters are supported.

Examples

SELECT RS_MinConvexHull(RS_Example());
┌──────────────────────────────────────────────────────────────────────────────┐
│                        rs_minconvexhull(rs_example())                        │
│                                    struct                                    │
╞══════════════════════════════════════════════════════════════════════════════╡
│ {item: POLYGON((43.08 79.07,171.07999999999998 143.07,203.07999999999998 20… │
└──────────────────────────────────────────────────────────────────────────────┘

Every pixel of RS_Example()’s first band but the upper-left one holds 1, so declaring 1 as its nodata value trims the footprint to that single cell:

SELECT RS_MinConvexHull(RS_SetBandNoDataValue(RS_Example(), 1, 1), 1);
┌──────────────────────────────────────────────────────────────────────────────┐
│ rs_minconvexhull(rs_setbandnodatavalue(rs_example(),Int64(1),Int64(1)),Int64 │
│                                     (1))…                                    │
╞══════════════════════════════════════════════════════════════════════════════╡
│ {item: POLYGON((43.08 79.07,45.08 80.07,46.08 82.07,44.08 81.07,43.08 79.07… │
└──────────────────────────────────────────────────────────────────────────────┘