Class: QgsNominatimGeocoder

A geocoder which uses the Nominatim geocoding API to retrieve results.

This geocoder utilizes the Nominatim geocoding API in order to geocode strings.

Warning

The user is responsible for respecting the usage policy when using the default OpenStreetMap-run server.

Added in version 3.18.

Class Hierarchy

Inheritance diagram of qgis.core.QgsNominatimGeocoder

Base classes

QgsGeocoderInterface

Interface for geocoders.

Methods

countryCodes

Returns the optional region bias which will be used to prioritize results in a certain region.

endpoint

Returns the API endpoint used for requests.

jsonToResult

Converts a JSON result returned from the Nominatim service to a geocoder result object.

requestUrl

Returns the URL generated for geocoding the specified address.

requestsPerSecond

Returns the number of requests per seconds to the endpoint.

setCountryCodes

Sets the optional region bias which will be used to prioritize results in a certain region.

setEndpoint

Sets a specific API endpoint to use for requests.

setRequestsPerSecond

Sets the number of request per seconds to the endpoint.

class qgis.core.QgsNominatimGeocoder[source]

Bases: QgsGeocoderInterface

__init__(countryCodes: str | None = '', endpoint: str | None = '')

Constructor for QgsNominatimGeocoder.

Optionally, countryCodes can be specified to restrict results to one or more countries. The codes must be in ISO 3166-1alpha2 code and comma-separated.

The optional endpoint argument can be used to specify a non-default endpoint to use for request.

Parameters:
  • countryCodes (Optional[str] = '')

  • endpoint (Optional[str] = '')

__init__(a0: QgsNominatimGeocoder)
Parameters:

a0 (QgsNominatimGeocoder)

countryCodes(self) str[source]

Returns the optional region bias which will be used to prioritize results in a certain region.

Return type:

str

endpoint(self) str[source]

Returns the API endpoint used for requests.

See also

setEndpoint()

Return type:

str

jsonToResult(self, json: Dict[str, Any]) QgsGeocoderResult[source]

Converts a JSON result returned from the Nominatim service to a geocoder result object.

Parameters:

json (Dict[str, Any])

Return type:

QgsGeocoderResult

requestUrl(self, address: str | None, bounds: QgsRectangle = QgsRectangle()) QUrl[source]

Returns the URL generated for geocoding the specified address.

Parameters:
  • address (Optional[str])

  • bounds (QgsRectangle = QgsRectangle())

Return type:

QUrl

requestsPerSecond(self) float[source]

Returns the number of requests per seconds to the endpoint.

Return type:

float

setCountryCodes(self, countryCodes: str | None)[source]

Sets the optional region bias which will be used to prioritize results in a certain region.

The region argument must be set to a two letter country code top-level domain value, e.g. “gb” for Great Britain.

See also

countryCodes()

Parameters:

countryCodes (Optional[str])

setEndpoint(self, endpoint: str | None)[source]

Sets a specific API endpoint to use for requests. This is for internal testing purposes only.

See also

endpoint()

Parameters:

endpoint (Optional[str])

setRequestsPerSecond(self, number: float)[source]

Sets the number of request per seconds to the endpoint.

Warning

Setting this to a value > 1 violates the nomatim terms of service. Only change this value if you are using a self-hosted nomatim service.

Parameters:

number (float)