Hi,
folgende Abfrage habe ich mir per KI generieren lassen, sie funzt aber nicht:
[out:json][timeout:60];
rel(155790)->.search_area; // OCHTRUP
node(area.search_area)["addr:housenumber"];
out qt geom;
Was ist da falsch?
Hi,
folgende Abfrage habe ich mir per KI generieren lassen, sie funzt aber nicht:
[out:json][timeout:60];
rel(155790)->.search_area; // OCHTRUP
node(area.search_area)["addr:housenumber"];
out qt geom;
Was ist da falsch?
Hmm, ich vermute zuerst das “Suchgebiet” und zum zweiten die Ausgabe:
[out:json][timeout:25];
// fetch area “Ochtrup” to search in
{{geocodeArea:Ochtrup}}->.searchArea;
// gather results
nwr["addr:housenumber"](area.searchArea);
// print results
out count;
funktioniert - und gibt Dir zusätzlich auch die Anzahl der Adressen aus, die Wegen und Relationen zugeordnet sind.
Eingeschränkt auf nodes entfallen vor allem die Adressen, die dem Gebäude zugeordnet sind.
Edit: Siehe Overpass API/Overpass QL - OpenStreetMap Wiki zu out count
Edit 2:
Mit der id der Relation geht es auch - Du musst nur 3600000000 dazuaddieren:
[out:json][timeout:25];
// fetch area “Ochtrup” to search in
// {{geocodeArea:Ochtrup}}->.searchArea;
area(3600155790); //Ochtrup = 360000000 + id der Relation von Ochtrup
// gather results
nwr["addr:housenumber"](area);
// print results
out count;
Quelle: Overpass query using administrative boundaries as the bounding 'box'? - #7 by eteb3
Hallo,
nimm doch einfach Postpass. Das ist viel schneller.
{{data:sql,server=https://postpass.geofabrik.de/api/0.2/,geojson=false}}
SELECT
count(1) AS hn_count
FROM
postpass_pointpolygon address,
postpass_polygon ochtrup
WHERE
address.tags?'addr:housenumber'
AND st_contains(ochtrup.geom, address.geom)
-- && operator to make better use of the spatial index
AND ochtrup.geom && address.geom
AND ochtrup.osm_id=155790 and ochtrup.osm_type='R'
Und wenn du Doppelungen eliminiert haben willst, weil jemand einem Laden (Node) und seinem Gebäude (Way) dieselbe Adresse gegeben hat:
{{data:sql,server=https://postpass.geofabrik.de/api/0.2/,geojson=false}}
SELECT
count(1) AS hn_count
FROM
(
SELECT
address.tags->>'addr:housenumber' AS housenumber,
address.tags->>'addr:street' AS street,
address.tags->>'addr:place' AS place
FROM
postpass_pointpolygon address,
postpass_polygon ochtrup
WHERE
address.tags?'addr:housenumber'
AND st_contains(ochtrup.geom, address.geom)
-- && operator to make better use of the spatial index
AND ochtrup.geom && address.geom
AND ochtrup.osm_id=155790 and ochtrup.osm_type='R'
GROUP BY housenumber, street, place
) AS a
Viele GrĂĽĂźe
Michael
Und wenn ich noch mehr Postpass-Advocacy betreiben darf, hier ist ein Overpass-Turbo-Query, der nicht speziell fĂĽr Ochtrup geht, sondern fĂĽr alle adminlevel-8-Orte im aktuell angeschauten Kartenausschnitt: overpass turbo
Gut, damit habe ich schonmal ein Paar Gemeinden mit wenigen Hausnummern in Niedersachsen gefunden.
| Lahn, | 16 |
|---|---|
| HĂĽven, | 19 |
| GroĂź BerĂźen, | 25 |
| Klein BerĂźen, | 38 |
| Scholen, | 88 |
You have two options:
Convert the relation to an area
[out:json][timeout:60];
rel(155790);map_to_area; // OCHTRUP
node(area)[“addr:housenumber”];
out qt geom;
or using the area command
[out:json][timeout:60];
area(3600155790); //map_to_area; // OCHTRUP
node(area)[“addr:housenumber”];
out qt geom;
Area ids are derived from existing OSM relations by adding 3600000000
Not all relation types have been converted to areas within the Overpass database. It’s “work in progress“, I believe. I’ve never seen a list of what has been completed.
If you’re only using a data set once & directly after, then it doesn’t require storing in a variable (.search_area).
Is there a page comparing (dis)advantages of OP-QL with SQL?