> ## 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_Values

Returns the values at the given points or grid coordinates in the raster. If no band number is specified it defaults to 1.

RS\_Values is similar to RS\_Value but operates on an array of points or grid coordinates.
RS\_Values can be significantly faster since a raster only has to be loaded once for several points.

<Note>
  Since `v1.5.1`, if the coordinate reference system (CRS) of the input `points` geometries differs from that of the `raster`, then `points` will be transformed to match the CRS of the `raster`. If the `raster` or `points` doesn't have a CRS then it will default to `4326/WGS84`.
</Note>

## Signatures

```sql theme={"system"}
RS_Values (raster: Raster, points: ARRAY[Geometry])
```

```sql theme={"system"}
RS_Values (raster: Raster, points: ARRAY[Geometry], band: Integer)
```

```sql theme={"system"}
RS_Values (raster: Raster, xCoordinates: ARRAY[Integer], yCoordinates: ARRAY[Integer], band: Integer)
```

## Parameters

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

<ParamField body="xCoordinates" type="ARRAY[Integer]">
  The x coordinates value.
</ParamField>

<ParamField body="yCoordinates" type="ARRAY[Integer]">
  The y coordinates value.
</ParamField>

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

<ParamField body="points" type="ARRAY[Geometry]">
  The points value.
</ParamField>

## Return type

<ResponseField type="Array<Double>">
  An array of double values.
</ResponseField>

## Examples

* For Array of Point geometries:

```sql theme={"system"}
SELECT RS_Values(raster, Array(ST_Point(-1307.5, 400.8), ST_Point(-1403.3, 399.1)))
FROM raster_table
```

* For Arrays of grid coordinates:

```sql theme={"system"}
SELECT RS_Values(raster, Array(4, 5), Array(3, 2), 1) FROM raster_table
```

```
Array(5.0, 3.0)
```

Spark SQL example for joining a point dataset with a raster dataset:

```scala theme={"system"}
val pointDf = sedona.read...
val rasterDf = sedona.read.format("binaryFile").load("/some/path/*.tiff")
  .withColumn("raster", expr("RS_FromGeoTiff(content)"))
  .withColumn("envelope", expr("RS_Envelope(raster)"))

// Join the points with the raster extent and aggregate points to arrays.
// We only use the path and envelope of the raster to keep the shuffle as small as possible.
val df = pointDf.join(rasterDf.select("path", "envelope"), expr("ST_Within(point_geom, envelope)"))
  .groupBy("path")
  .agg(collect_list("point_geom").alias("point"), collect_list("point_id").alias("id"))

df.join(rasterDf, "path")
  .selectExpr("explode(arrays_zip(id, point, RS_Values(raster, point))) as result")
  .selectExpr("result.*")
  .show()
```

```
+----+------------+-------+
| id | point      | value |
+----+------------+-------+
|  4 | POINT(1 1) |   3.0 |
|  5 | POINT(2 2) |   7.0 |
+----+------------+-------+
```
