Skip to main content
Data Connectors · Points of Interest

OSM Overpass

The node builds an Overpass QL query from an area selected on the map and a list of OpenStreetMap tags, sends it to the public Overpass API, converts the result to GeoJSON with osmtogeojson and emits the matched objects as OsmFeature objects. It is suited for points of interest such as playgrounds, drinking fountains, ice cream parlours or car parks within a municipality.

  • Data source
  • Trigger-based
  • OpenStreetMap
Node type
osm-overpass
Package
@htag/node-red-contrib-hypertegrity-pointofinterest
Inputs / outputs
1 / 1
Data source
OpenStreetMap via the public Overpass API

When to use this node​

OpenStreetMap (OSM) contains a large number of points of interest for almost every municipality, described by so-called tags, for example amenity=playground for playgrounds or amenity=drinking_water for drinking fountains. The Overpass API is the query interface to this data. The OSM Overpass node spares you writing the Overpass QL query language: you pick an area and the desired tags in the dialog, the node builds the query, runs it and delivers a result you can process.

Typical use cases are:

  • Points of interest of a city or district (playgrounds, benches, toilets, charging points) transferred into an NGSI-LD context broker.
  • Areas and buildings such as parks or schools provided with point and polygon geometry for map dashboards.
  • Inventory comparisons between municipal data and the OSM dataset at regular intervals.

How the node works​

1

Trigger

An incoming message starts the query. The node never polls the Overpass API on its own.

2

Build the query

Area (administrative area, bounding box or radius) and tags are turned into an Overpass QL query for nodes, ways and relations.

3

Query

The query is sent to up to four public Overpass servers (fallback servers) in turn, with up to ten attempts each.

4

Convert

The OSM JSON is converted to GeoJSON with osmtogeojson and mapped to flat OsmFeature objects with point geometry.

5

Emit

One message per tag (or per tag combination) leaves the node; msg.topic names the tag, msg.payload holds the matches.

Result: An array of OsmFeature objects per tag that can be passed directly to the NGSI-LD Builder.

The node is trigger-based. Combine it with an Inject node that fires, for example, once a day. OSM data rarely changes fast enough to warrant more frequent queries, and the Overpass servers are a community-run resource.

The generated query starts with [out:json][timeout:30], adds [bbox:S,W,N,E] for a bounding box, the filter (around:metres,lat,lon) for a radius and a block area(ID)->.searchArea for administrative areas. For every tag, node, way and relation are queried, followed by out body; >; out skel qt; so that the geometries of ways and relations are loaded completely.

Configuration​

The edit dialog has two tabs. The area fields are not typed in directly but filled through the map or the area search; they are stored as hidden fields in the dialog.

FieldTypeDefaultMeaning
NameTextemptyDisplay name of the node in the flow.
Area searchSearch field with "Search" buttonemptySearches Nominatim for cities, counties or suburbs. A hit with a boundary polygon is added as an administrative area; several areas can be added one after another and removed again as chips.
Query area (map)Leaflet map with drawing toolsGermany overviewUse the tools on the left edge of the map to draw a circle (radius) or a rectangle (bounding box). A new drawing replaces existing areas.
areaTypehidden (area, bbox, radius)emptySet by search or drawing; determines the kind of area filter.
areashidden (list)emptySelected administrative areas with name, osmId, osmType and searchId (Overpass area id: relation + 3600000000, way + 2400000000).
bboxS, bboxW, bboxN, bboxEhidden (decimal degrees)emptySouth, west, north and east boundary of the drawn rectangle.
radiusLat, radiusLon, radiusMetershidden (decimal degrees, metres)emptyCentre and radius of the drawn circle in metres.

Tab "Tags & Filters"​

FieldTypeDefaultMeaning
Geometry ModeSelect"Point Only (for Markers)"point: every object gets a point geometry only (for areas and lines the centre of the bounding box). split: the original geometry is emitted additionally in the field location_polygon.
Match ModeSelect"Match ANY tag (OR) - separate queries"or: every tag is queried separately and emitted as its own message. and: all tags must match at once; a single combined query and one message result.
OSM TagsEditable list (key, value)emptyKey and value of an OSM tag, for example amenity and cafe. Both fields offer auto-completion via the Taginfo API. If the value is left empty, all objects carrying this key are matched regardless of their value.
An area is mandatory

If you save the dialog without an area, the editor shows a warning. At runtime the node rejects messages as long as no area and at least one tag are configured.

Input​

The input serves only as a trigger. The node does not evaluate any message properties; all parameters come from the configuration. Properties of the incoming message are carried over to the output messages, only payload and topic are overwritten.

PropertyTypeMeaning
msg.payloadanyAny value triggers the query. The content is not evaluated.

Output​

The node sends one message per tag (mode OR) or per tag combination (mode AND) through its single output. msg.topic holds the tag in the form amenity=ice_cream, or just the key if the value is empty; in mode AND it reads for example amenity=cafe AND outdoor_seating=yes. msg.payload is an array of OsmFeature objects.

[
{
"id": "node:1234567890",
"type": "OsmFeature",
"osmtype": "node",
"location": {
"type": "GeoProperty",
"value": {"type": "Point", "coordinates": [7.7689, 49.4447]}
},
"amenity": "ice_cream",
"name": "Ice Cream Example",
"addr_street": "Market Street",
"addr_housenumber": "12",
"addr_postcode": "67655",
"opening_hours": "Mo-Su 11:00-21:00"
}
]
FieldMeaning
idOSM identifier made of type and number; the slash of the GeoJSON id is replaced by a colon (node:…, way:…, relation:…).
typeAlways OsmFeature.
osmtypeOSM object kind node, way or relation.
locationGeoProperty with point geometry. For polygons, multipolygons and lines this is the centre of the enclosing bounding box.
location_polygonOnly in geometry mode split and only for non-points: GeoProperty with the original GeoJSON geometry.
further fieldsAll OSM tags of the object. Characters other than letters, digits, _ and - in the key are replaced by _, so addr:street becomes addr_street.

In mode OR an object that carries several of the configured tags may appear in several messages. Objects that are part of the Overpass result only as geometry vertices and carry none of the tags are not emitted.

Example flow​

The package ships with an example flow. Import it in Node-RED via Menu → Import → Examples → @htag/node-red-contrib-hypertegrity-pointofinterest → osm-overpass. Alternatively download osm-overpass.json and import it via Menu → Import.

Step 1

Inject

An Inject node triggers the query manually or at a fixed interval.

Step 2

OSM Overpass

The node queries the tags amenity=ice_cream and cuisine=ice_cream within the administrative area of Kaiserslautern.

Step 3

Debug

A Debug node shows one array of OsmFeature objects per tag in the sidebar.

Show example flow as JSON
[
{"id": "tab1", "type": "tab", "label": "osm overpass", "disabled": false, "info": ""},
{"id": "inject1", "type": "inject", "z": "tab1", "name": "", "props": [{"p": "payload"}], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", "x": 140, "y": 120, "wires": [["osm1"]]},
{"id": "osm1", "type": "osm-overpass", "z": "tab1", "name": "", "areaType": "area", "areas": "[{\"name\":\"Kaiserslautern\",\"osmId\":62652,\"osmType\":\"relation\",\"searchId\":3600062652}]", "bboxS": "", "bboxW": "", "bboxN": "", "bboxE": "", "radiusLat": "", "radiusLon": "", "radiusMeters": "", "geometryMode": "point", "tagMatchMode": "or", "tags": [{"key": "amenity", "value": "ice_cream"}, {"key": "cuisine", "value": "ice_cream"}], "x": 400, "y": 120, "wires": [["debug1"]]},
{"id": "debug1", "type": "debug", "z": "tab1", "name": "Overpass data", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "x": 600, "y": 120, "wires": []}
]

Status and errors​

IndicatorMeaning
Blue dot "querying overpass-api.de (endpoint 1/4, try 1/10)..."The query is running against the named server; counters for server and attempt.
Green dot "connected to …"The server returned a valid result.
Blue dot "converting to geojson..."The OSM JSON is being converted with osmtogeojson.
Blue dot "mapping to ngsi-ld..."The GeoJSON features are being mapped to OsmFeature objects. Afterwards the status is cleared.
Red ring "Invalid config"No area, no tags or incomplete coordinates. The error message names the cause, for example "No tags specified for OSM query." or "Bounding box incomplete".
Red ring "failed"All servers failed or the conversion threw an error. The error message reads "All Overpass endpoints failed after 40 attempts. Last error: …".
Warning "Overpass endpoint … attempt n/10 failed: …"One attempt failed (HTTP status, timeout after 30 seconds or a remark message from the Overpass API). The next attempt follows after 1.5 seconds.
Warning "All 10 attempts failed for …, trying next endpoint..."The node switches to the next fallback server.

Errors are reported via done(error) and can be handled with a Catch node. Warnings appear in the debug sidebar.

Notes​

  • Terms of use and fair use: The Overpass servers used (overpass-api.de, overpass.osm.ch, overpass.openstreetmap.fr, overpass.kumi.systems) are community-run, free services with fair-use rules, including limits on parallel requests and daily data volume per IP address. The node sends an identifying User-Agent and limits every query to 30 seconds. Choose query intervals in the range of hours or days and keep areas and tag lists as small as necessary. The area search and the tag suggestions in the editor use Nominatim and Taginfo, which have usage policies of their own.
  • Data licence: OSM data is published under the Open Database License (ODbL). When publishing, for example in a dashboard, the attribution "© OpenStreetMap contributors" is required.
  • Large areas: Administrative areas are referenced in the query by their Overpass area id. Very large areas or tags with many matches (for example building) can exceed the 30-second timeout; the node then retries and switches servers, which can take a long time.
  • Output format: The objects are deliberately kept flat. The actual NGSI-LD entity is created downstream in the NGSI-LD Builder. The location field is already prepared as a GeoProperty.
  • Metric units: The radius is specified in metres and passed to the query as such.
  • Personal data: OSM objects usually contain no data about private individuals. Tags such as contact:phone, email or operator may, however, name contact persons of small businesses. Check which tags you forward before publishing.

References​