Introduction

AfriGIS SRW Reverse Geocode Stored Query API is part of the AfriGIS SRW API suite. The Reverse Geocode API uses coordinate input (as latitude and longitude) of a geographic feature/(s) to provide the human-readable address. It consists of Smart Reverse Geocode and Basic Reverse Geocode.

Overview

Making use of AfriGIS SRW Reverse Geocode Stored Query API, client applications/solutions can obtain a human-recognisable address, such as province, suburb or street address, for a coordinate point. The longitude and latitude are required parameters for both Smart and Basic geocode. The optional parameters differ between the two.

Smart geocode include optional parameters for the number of results to return (limit) as well as the address tile server level of results (level). The response fields not only include the human readable address but also information on the proximity of the spatial feature to the response coordinates.

Basic geocode has, in addition to the latitude and longitude, the required parameters for schema filtering of results to include only one of the available feature types. Optional parameters are the inclusion of results in a radius of a circle centred on the specific location and the option to limit the number of results to return.

API Authentication

This API makes use of OAuth2 – please refer to OAuth2 authentication

srw-reversegeocode-sq-api

View the API in Swagger UI

The reverse geocoding stored query allows you to look up a single pair of coordinates and returns the geographic feature(s) that exist at that location.

This service currently only supports the following African countries

  • South Africa
  • Namibia

Base URL: https://afrigis.services/srw-reversegeocode-sq/

Smart Reverse Geocode

GET /api/v3/storedquery/reversegeocode/smart

Matches geographic feature(s) that exists by using a single pair of coordinates

Parameters

NameInTypeRequiredDescription
longitudequerynumber(double)trueThe Longitude geographic coordinate that specifies the east–west position of the location.
latitudequerynumber(double)trueThe Latitude geographic coordinate that specifies the north–south position of the location.
limitqueryinteger(int32)falseThe maximum number of results to return. The value must be between 1 and 15.
levelqueryinteger(int32)falseThe zoom level corresponding to AfriGIS Tileserver. The value must be between 1 and 20.

API Response Structure

{
  "result": [
    {
      "place_id": "string",
      "seoid": "string",
      "sfid": "string",
      "formatted_address": "string",
      "confidence": 0,
      "location": {
        "lng": 0,
        "lat": 0,
        "distance": 0
      },
      "distance": 0,
      "landparcel_ind": "string"
    }
  ],
  "code": 0,
  "message": "string",
  "source": "string"
}

Example API Response:

{
    "result": [
        {
            "place_id": "2XIAs5De9f_eEXNFubwV-ZXI41F281017",
            "seoid": "2XIAs5De9f_eEXNFubwV-ZXI41F281017",
            "sfid": "5c3659ba-335b-5ebd-e053-0d05000aa120",
            "formatted_address": "446 Rigel Avenue South, Erasmusrand, Pretoria, Gauteng, 0181",
            "confidence": 1,
            "location": {
                "lng": 28.256111,
                "lat": -25.808699,
                "distance": 10.03
            },
            "distance": 0.0,
            "landparcel_ind": "Y"
        }
    ],
    "code": 200,
    "message": "OK",
    "source": "srw.api-storedquery-reversegeocode"
}

API Response Object:

The response to a Reverse Geocoding API request is an object that contains the following properties:

NameTypeRequiredRestrictionsDescription
resultstringfalsenonean object of returned results for the API request
codestringfalsenonea three digit http response status code
messagestringfalsenonea human-readable explanation of the response code
sourcestringfalsenonea human-readable description of the response source

The result property may have the following properties described below:

NameTypeRequiredRestrictionsDescription
place_idstringfalsenoneUnique internal identifier denoting a place and or geographic location
seoidstringfalsenoneUnique stable textual identifier denoting a place and or geographic location
sfidstringfalsenoneUnique spatial feature identifier denoting a geographic feature
formatted_addressstringfalsenoneThe complete formatted address presentation of an address
confidencenumber (int)falsenoneThe absolute level specifying the relative position to which the address location was captured
locationobjectfalsenoneAn object describing the location of the address
location.latnumber (double)falsenoneThe latitude coordinate associated with the location
location.lngnumber (double)falsenoneThe longitude coordinate associated with the location
location.distancenumber (int)falsenoneThe distance measured in meters from the supplied geographic coordinate to the location geographic coordinate
distancenumber (int)falsenoneThe distance measured in meters from the supplied geographic coordinate to the location spatial context
landparcel_indstringfalsenoneSpatial topology boolean indicator indicating if supplied geographic coordinate is within a land pacel

Response Codes

StatusMeaningDescription
200OKReverse Geocode results are successfully retrieved
400Bad RequestInvalid request (bad request; a required parameter is missing; invalid version; invalid format)
404Not FoundThe requested resource was not found
405Method Not AllowedMethod not allowed (non-GET request)
500Internal Server ErrorInternal system error has occurred

Basic Reverse Geocode

GET /api/v3/storedquery/reversegeocode/basic

Matches targeted geographic feature(s) that exists by using a single pair of coordinates

Parameters

NameInTypeRequiredDescription
longitudequerynumber(double)trueThe Longitude geographic coordinate that specifies the east–west position of the location.
latitudequerynumber(double)trueThe Latitude geographic coordinate that specifies the north–south position of the location.
schemaquerystringtrueFilter results to include only a subset (one) of the available feature types. Available values: adm_adminarea_l1, adm_locality, adm_sublocality, zaf_streetsegment, zaf_streetnode, zaf_landparcel_erven, zaf_landparcel_farm, zaf_landparcel_farmportion, zaf_landparcel_holding, zaf_landparcel_park, zaf_landparcel_street, zaf_nad, zaf_scheme
radiusquerynumber(double)falseThe radius of the circle centred on the specified location specified in meters. Feature types within this circle radius are considered to be a match.
limitqueryinteger(int32)falseThe maximum number of results to return. The value must be between 1 and 15.

API Response Structure

{
  "result": [
    {
      "place_id": "string",
      "seoid": "string",
      "sfid": "string",
      "formatted_address": "string",
      "confidence": 0,
      "location": {
        "lng": 0,
        "lat": 0,
        "distance": 0
      },
      "distance": 0,
      "landparcel_ind": "string"
    }
  ],
  "code": 0,
  "message": "string",
  "source": "string"
}

Example API Response:

{
    "result": [
        {
            "place_id": "2XIAs5De9f_eEXNFubwV-ZXI41F281017",
            "seoid": "2XIAs5De9f_eEXNFubwV-ZXI41F281017",
            "sfid": "5c3659ba-335b-5ebd-e053-0d05000aa120",
            "formatted_address": "446 Rigel Avenue South, Erasmusrand, Pretoria, Gauteng, 0181",
            "confidence": 1,
            "location": {
                "lng": 28.256111,
                "lat": -25.808699,
                "distance": 10.03
            },
            "distance": 0.0,
            "landparcel_ind": "Y"
        }
    ],
    "code": 200,
    "message": "OK",
    "source": "srw.api-storedquery-reversegeocode"
}

API Response Object:

The response to a Reverse Geocoding API request is an object that contains the following properties:

NameTypeRequiredRestrictionsDescription
resultstringfalsenonean object of returned results for the API request
codestringfalsenonea three digit http response status code
messagestringfalsenonea human-readable explanation of the response code
sourcestringfalsenonea human-readable description of the response source

The result property may have the following properties described below:

NameTypeRequiredRestrictionsDescription
place_idstringfalsenoneUnique internal identifier denoting a place and or geographic location
seoidstringfalsenoneUnique stable textual identifier denoting a place and or geographic location
sfidstringfalsenoneUnique spatial feature identifier denoting a geographic feature
formatted_addressstringfalsenoneThe complete formatted address presentation of an address
confidencenumber (int)falsenoneThe absolute level specifying the relative position to which the address location was captured
locationobjectfalsenoneAn object describing the location of the address
location.latnumber (double)falsenoneThe latitude coordinate associated with the location
location.lngnumber (double)falsenoneThe longitude coordinate associated with the location
location.distancenumber (int)falsenoneThe distance measured in meters from the supplied geographic coordinate to the location geographic coordinate
distancenumber (int)falsenoneThe distance measured in meters from the supplied geographic coordinate to the location spatial context
landparcel_indstringfalsenoneSpatial topology boolean indicator indicating if supplied geographic coordinate is within a land pacel

Response Codes

StatusMeaningDescription
200OKReverse Geocode results are successfully retrieved
400Bad RequestInvalid request (bad request; a required parameter is missing; invalid version; invalid format)
404Not FoundThe requested resource was not found
405Method Not AllowedMethod not allowed (non-GET request)
500Internal Server ErrorInternal system error has occurred

 

For the previous version 2 of this documentation, see this deprecated page.