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

# ST_ReverseGeocode

Return a reverse geocode result struct for the given geometry and layer.

If no result is found for a layer, the result contains a null geometry and location field. The geometry provided should
be in the WGS84 (EPSG:4326) coordinate system, i.e. lon/lat coordinates. The layers must correspond to the layers in the
reverse geocode database. You can use `ST_GetReverseGeocodingLayers` to get a list of available layers.

You can change the geocodes table or view used by setting `spark.sedona.reverse.geocode.table` in the spark config.

You can set the distance thresholds (in degrees) for reverse geocoding by setting
`spark.sedona.reverse.geocode.distance.<layerName>`. The value for layers without a specific configuration is set by
`spark.sedona.reverse.geocode.distance.default`. When unset the values are `0.0006` (\~67 meters on the equator) for
places, `0.0003` for addresses, and `0.0` for all other layers.

<Note>
  Do not pass duplicate input rows. Passing duplicate input rows has undefined behavior. The concept of a duplicate
  row is based on the columns input to the function call. At the time of writing the behavior is to deduplicate.
</Note>

The default geocodes collection derives from the Overture datasets. The available layers are:

* `addresses`: Street addresses
* `places`: aka points of interest
* `divisions-locality`: See [Overture documentation](https://docs.overturemaps.org/schema/reference/divisions/division_area/)
* `divisions-country`: See [Overture documentation](https://docs.overturemaps.org/schema/reference/divisions/division_area/)
* `divisions-dependency`: See [Overture documentation](https://docs.overturemaps.org/schema/reference/divisions/division_area/)
* `divisions-localadmin`: See [Overture documentation](https://docs.overturemaps.org/schema/reference/divisions/division_area/)
* `divisions-macrohood`: See [Overture documentation](https://docs.overturemaps.org/schema/reference/divisions/division_area/)
* `divisions-county`: See [Overture documentation](https://docs.overturemaps.org/schema/reference/divisions/division_area/)
* `divisions-microhood`: See [Overture documentation](https://docs.overturemaps.org/schema/reference/divisions/division_area/)
* `divisions-neighborhood`: See [Overture documentation](https://docs.overturemaps.org/schema/reference/divisions/division_area/)
* `divisions-region`: See [Overture documentation](https://docs.overturemaps.org/schema/reference/divisions/division_area/)

`ST_ReverseGeocode` includes the following parameters:

* `geom: Geometry`: The location that you're querying. Provide a geometry object in  accordance with the WGS84 coordinate system (using longitude and latitude).
* `layer: String`: Specifies which "layer" of information you want to search. Layers correspond to different categories of data in the reverse geocode database.

## Signatures

```sql theme={"system"}
ST_ReverseGeocode (geom: Geometry, layer: String)
```

## Parameters

<ParamField body="geom" type="Geometry" required>
  The input geometry.
</ParamField>

<ParamField body="layer" type="String" required>
  The layer to search. Use `ST_GetReverseGeocodingLayers` to see available layers.
</ParamField>

## Return type

<ResponseField type="Struct">
  A struct containing `location` (the name or address found), `layer` (the resulting layer), and `geometry` (the geometry of the result).
</ResponseField>

## Example

```sql theme={"system"}
SELECT ST_ReverseGeocode(ST_GeomFromText('POINT (13.040766 47.812924)'), 'addresses')
```

In the example:

* `ST_GeomFromText('POINT (13.040766 47.812924)')` creates a point geometry in Salzburg Austria.
* `'addresses'` is used to specify that we want to find addresses (as opposed to e.g. places or neighborhoods).

A struct that includes:

* `location`: The name or address found at that location (e.g., "1600 Amphitheatre Parkway, Mountain View, CA" or "Google").
* `layer`: The resulting layer (e.g., "address" or "place").
* `geometry`: The geometry of the result.

```
{Stauffenstraße 14 5020 Salzburg AUSTRIA, addresses, POINT (13.0407699 47.8129819)}
```
