-
-
Notifications
You must be signed in to change notification settings - Fork 13
Location search & lookup
Raphaël Odini edited this page Dec 4, 2024
·
5 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://overpass-api.de/api/interpreter?data=[out:json];node(id:652825274);out;
{
"version": 0.6,
"generator": "Overpass API 0.7.62.4 2390de5a",
"osm3s": {
"timestamp_osm_base": "2024-12-03T14:30:45Z",
"copyright": "The data included in this document is from www.openstreetmap.org. The data is made available under ODbL."
},
"elements": [
{
"type": "node",
"id": 652825274,
"lat": 45.1805534,
"lon": 5.7153387,
"tags": {
"brand": "Monoprix",
"brand:wikidata": "Q3321241",
"brand:wikipedia": "en:Monoprix",
"check_date": "2024-05-16",
"contact:phone": "+33 4 76 96 20 09",
"contact:website": "https://www.monoprix.fr/200.html",
"name": "Monoprix",
"opening_hours": "Mo-Sa 08:00-21:00; Su 09:00-13:00",
"operator": "Groupe Casino",
"shop": "supermarket",
"wheelchair": "yes"
}
}
]
}
https://prices.openfoodfacts.org/api/v1/locations/1?app_name=Open+Prices+Web+App
{
"id": 1,
"type": "OSM",
"osm_id": 1392117416,
"osm_type": "NODE",
"osm_name": "L'Éléfàn",
"osm_display_name": "L'Éléfàn, 32, Avenue Marcelin Berthelot, Capuche, Secteur 4, Grenoble, Isère, Auvergne-Rhône-Alpes, France métropolitaine, 38100, France",
"osm_tag_key": "shop",
"osm_tag_value": "supermarket",
"osm_brand": null,
"osm_address_postcode": "38100",
"osm_address_city": "Grenoble",
"osm_address_country": "France",
"osm_address_country_code": "FR",
"osm_lat": 45.1750672,
"osm_lon": 5.7304083,
"osm_version": 20,
"website_url": null,
"price_count": 1223,
"user_count": 3,
"product_count": 1045,
"proof_count": 60,
"created": "2023-11-27T11:37:14.059085Z",
"updated": "2024-09-02T17:25:19.151270Z"
}