Class: QgsNominatimGeocoder

class qgis.core.QgsNominatimGeocoder

Bases: QgsGeocoderInterface

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.

New in version 3.18.

QgsNominatimGeocoder(countryCodes: str = ‘’, endpoint: str = ‘’) 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.

QgsNominatimGeocoder(QgsNominatimGeocoder)

Methods

appendedFields

rtype:

QgsFields

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.

flags

rtype:

QgsGeocoderInterface.Flags

geocodeString

param string:

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.

wkbType

rtype:

Qgis.WkbType

appendedFields(self) QgsFields
Return type:

QgsFields

countryCodes(self) str

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

Return type:

str

endpoint(self) str

Returns the API endpoint used for requests.

See also

setEndpoint()

Return type:

str

flags(self) QgsGeocoderInterface.Flags
Return type:

QgsGeocoderInterface.Flags

geocodeString(self, string: str, context: QgsGeocoderContext, feedback: QgsFeedback = None) List[QgsGeocoderResult]
Parameters:
Return type:

List[QgsGeocoderResult]

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

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

Parameters:

json (Dict[str) –

Return type:

QgsGeocoderResult

requestUrl(self, address: str, bounds: QgsRectangle = QgsRectangle()) QUrl

Returns the URL generated for geocoding the specified address.

Parameters:
  • address (str) –

  • bounds (QgsRectangle = QgsRectangle()) –

Return type:

QUrl

requestsPerSecond(self) float

Returns the number of requests per seconds to the endpoint.

Return type:

float

setCountryCodes(self, countryCodes: str)

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 (str) –

setEndpoint(self, endpoint: str)

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

See also

endpoint()

Parameters:

endpoint (str) –

setRequestsPerSecond(self, number: float)

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

wkbType(self) Qgis.WkbType
Return type:

Qgis.WkbType