-
-
Notifications
You must be signed in to change notification settings - Fork 12
Location search & lookup
Raphaël Odini edited this page Sep 26, 2024
·
3 revisions
We need a location search engine to find the right OpenStreetMap elements (node, way or relation).
https://wiki.openstreetmap.org/wiki/Geocoding
https://nominatim.openstreetmap.org/search?addressdetails=1&limit=10&format=json
https://nominatim.openstreetmap.org/search?q=monoprix grenoble&addressdetails=1&limit=10&format=json
{
"place_id": 75882733,
"licence": "Data © OpenStreetMap contributors, ODbL 1.0. http://osm.org/copyright",
"osm_type": "way",
"osm_id": 32520537,
"lat": "45.1904063",
"lon": "5.728646372820163",
"class": "shop",
"type": "supermarket",
"place_rank": 30,
"importance": 9.99999999995449e-06,
"addresstype": "shop",
"name": "Monoprix",
"display_name": "Monoprix, Rue de la République, Hyper Centre, Secteur 2, Grenoble, Isère, Auvergne-Rhône-Alpes, France métropolitaine, 38000, France",
"address": {
"shop": "Monoprix",
"road": "Rue de la République",
"residential": "Hyper Centre",
"suburb": "Secteur 2",
"city": "Grenoble",
"municipality": "Grenoble",
"county": "Isère",
"ISO3166-2-lvl6": "FR-38",
"state": "Auvergne-Rhône-Alpes",
"ISO3166-2-lvl4": "FR-ARA",
"region": "France métropolitaine",
"postcode": "38000",
"country": "France",
"country_code": "fr"
},
"boundingbox": [
"45.1902033",
"45.1906146",
"5.7282055",
"5.7288708"
]
}
Good
- easy to set up, no authentication
- the most well known geocoder
Bad
- not very precise, only searches on the element names
- usage policy is quite limited if the number of users grow
photon.komoot.io/api/?q=monoprix grenoble
photon.komoot.io/api/?q=monoprix grenoble&lang=fr
{
"geometry": {
"coordinates": [
5.7153387,
45.1805534
],
"type": "Point"
},
"type": "Feature",
"properties": {
"osm_id": 652825274,
"country": "France",
"city": "Grenoble",
"countrycode": "FR",
"postcode": "38000",
"county": "Isère",
"type": "house",
"osm_type": "N",
"osm_key": "shop",
"street": "Boulevard Joseph Vallier",
"district": "Eaux-Claires",
"osm_value": "supermarket",
"name": "Monoprix",
"state": "Auvergne-Rhône-Alpes"
}
}
Good
- fast
- always up to date with OSM data
https://github.com/mocnik-science/osm-python-tools/blob/main/docs/nominatim.md
from OSMPythonTools.nominatim import Nominatim
client = Nominatim()
client.query("node/4825695211", lookup=True).toJSON()
[{
'place_id': 82899484,
'licence': 'Data © OpenStreetMap contributors, ODbL 1.0. http://osm.org/copyright',
'osm_type': 'node',
'osm_id': 4825695211,
'lat': '48.8789789',
'lon': '2.3563569',
'class': 'shop',
'type': 'supermarket',
'place_rank': 30,
'importance': 9.317235065227768e-05,
'addresstype': 'shop',
'name': 'Carrefour City',
'display_name': 'Carrefour City, Rue La Fayette, Quartier Saint-Vincent-de-Paul, Paris 10e Arrondissement, Paris, Île-de-France, France métropolitaine, 75010, France',
'address': {'shop': 'Carrefour City',
'road': 'Rue La Fayette',
'city_block': 'Quartier Saint-Vincent-de-Paul',
'suburb': 'Paris 10e Arrondissement',
'city_district': 'Paris',
'city': 'Paris',
'ISO3166-2-lvl6': 'FR-75C',
'state': 'Île-de-France',
'ISO3166-2-lvl4': 'FR-IDF',
'region': 'France métropolitaine',
'postcode': '75010',
'country': 'France',
'country_code': 'fr'},
'boundingbox': ['48.8789289', '48.8790289', '2.3563069', '2.3564069']
}]
https://github.com/mocnik-science/osm-python-tools/blob/main/docs/api.md
from OSMPythonTools.api import Api
client = Api()
client.query("node/4825695211")
<?xml version="1.0" encoding="UTF-8"?>
<osm version="0.6" generator="openstreetmap-cgimap 2.0.1 (1849 spike-06.openstreetmap.org)" copyright="OpenStreetMap and contributors" attribution="http://www.openstreetmap.org/copyright" license="http://opendatacommons.org/licenses/odbl/1-0/">
<node id="4825695211" visible="true" version="4" changeset="143388389" timestamp="2023-10-30T21:41:29Z" user="geisterwelt" uid="20505595" lat="48.8789789" lon="2.3563569">
<tag k="brand" v="Carrefour City"/>
<tag k="brand:wikidata" v="Q2940187"/>
<tag k="brand:wikipedia" v="fr:Carrefour City"/>
<tag k="check_date:opening_hours" v="2023-10-30"/>
<tag k="level" v="0"/>
<tag k="name" v="Carrefour City"/>
<tag k="opening_hours" v="Mo-Sa 07:00-22:00"/>
<tag k="operator" v="Groupe Carrefour"/>
<tag k="operator:wikidata" v="Q3117359"/>
<tag k="operator:wikipedia" v="fr:Groupe Carrefour"/>
<tag k="shop" v="supermarket"/>
<tag k="source" v="survey 01/2022"/>
</node>
</osm>
https://prices.openfoodfacts.org/api/v1/locations/1?app_name=Open+Prices+Web+App
{
"id": 1,
"osm_id": 652825274,
"osm_type": "NODE",
"osm_name": "Monoprix",
"osm_display_name": "Monoprix, Boulevard Joseph Vallier, Secteur 1, Grenoble, Isère, Auvergne-Rhône-Alpes, France métropolitaine, 38000, France",
"osm_tag_key": "shop",
"osm_tag_value": "supermarket",
"osm_address_postcode": "38000",
"osm_address_city": "Grenoble",
"osm_address_country": "France",
"osm_address_country_code": "FR",
"osm_lat": 45.1805534,
"osm_lon": 5.7153387,
"price_count": 0,
"created": "2024-08-09T12:14:12.818262Z",
"updated": "2024-08-09T12:14:12.839531Z"
}