Skip to main content
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.
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.
The default geocodes collection derives from the Overture datasets. The available layers are: 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

ST_ReverseGeocode (geom: Geometry, layer: String)

Parameters

geom
Geometry
required
The input geometry.
layer
String
required
The layer to search. Use ST_GetReverseGeocodingLayers to see available layers.

Return type

A struct containing location (the name or address found), layer (the resulting layer), and geometry (the geometry of the result).

Example

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)}