> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wherobots.com/llms.txt
> Use this file to discover all available pages before exploring further.

# RS_MinConvexHull

Returns the min convex hull geometry of the raster **excluding** the NoDataBandValue band pixels, in the given band.
If no band is specified, all the bands are considered when creating the min convex hull of the raster.
The created geometry representing the min convex hull has world coordinates of the raster in its CRS as the corner coordinates.

<img src="https://mintcdn.com/wherobots/AayJA2u8CknIeTgt/images/sql-functions/RS_MinConvexHull/RS_MinConvexHull.svg?fit=max&auto=format&n=AayJA2u8CknIeTgt&q=85&s=40a9b801aa229e0e02df6f9055197e47" alt="RS_MinConvexHull" width="700" height="400" data-path="images/sql-functions/RS_MinConvexHull/RS_MinConvexHull.svg" />

<Note>
  If the specified band does not exist in the raster, RS\_MinConvexHull throws an IllegalArgumentException
</Note>

## Signatures

```sql theme={"system"}
RS_MinConvexHull(raster: Raster)
```

```sql theme={"system"}
RS_MinConvexHull(raster: Raster, band: Integer)
```

## Parameters

<ParamField body="raster" type="Raster" required>
  The input raster.
</ParamField>

<ParamField body="band" type="Integer">
  The band index.
</ParamField>

## Return type

<ResponseField type="Geometry">
  The resulting geometry.
</ResponseField>

## Examples

```scala theme={"system"}
val inputDf = Seq((Seq(0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0),
        Seq(0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0))).toDF("values2", "values1")
inputDf.selectExpr("ST_AsText(RS_MinConvexHull(RS_AddBandFromArray(" +
        "RS_AddBandFromArray(RS_MakeEmptyRaster(2, 5, 5, 0, 0, 1, -1, 0, 0, 0), values1, 1, 0), values2, 2, 0))) as minConvexHullAll").show()
```

```sql theme={"system"}
+----------------------------------------+
|minConvexHullAll                        |
+----------------------------------------+
|POLYGON ((0 -1, 4 -1, 4 -5, 0 -5, 0 -1))|
+----------------------------------------+
```

```scala theme={"system"}
val inputDf = Seq((Seq(0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0),
        Seq(0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0))).toDF("values2", "values1")
inputDf.selectExpr("ST_AsText(RS_MinConvexHull(RS_AddBandFromArray(" +
  "RS_AddBandFromArray(RS_MakeEmptyRaster(2, 5, 5, 0, 0, 1, -1, 0, 0, 0), values1, 1, 0), values2, 2, 0), 1)) as minConvexHull1").show()
```

```sql theme={"system"}
+----------------------------------------+
|minConvexHull1                          |
+----------------------------------------+
|POLYGON ((1 -1, 4 -1, 4 -5, 1 -5, 1 -1))|
+----------------------------------------+
```

```sql theme={"system"}
SELECT RS_MinConvexHull(raster, 3) from rasters;
```

```sql theme={"system"}
Provided band index 3 does not lie in the raster
```
