4

In using QGIS, I would like to select several values at once within the same key in QuickOSM.

I'm not at all familiar with coding!

Can someone suggest a simple point-by-point method to do this?

An example would be:

  • In Quick Queries, I select "amenities" under Key. Under Value, I'd like to select colleges, schools, hospitals.

Is there a way to do this, so that I don't have to do one at a time?

3 Answers 3

3

The QuickOSM plugin dialogue also has an option to use a query from the Overpass Turbo API.

http://overpass-turbo.eu/

Here I can construct a query to find amenities = bench and townhall using the wizard:

amenity = bench or amenity = townhall

The query runs and the results show, but the code to run this shows on the side:

/*
This has been generated by the overpass-turbo wizard.
The original search was:
“amenity = bench or amenity = townhall”
*/
[out:json][timeout:25];
// gather results
(
  // query part for: “amenity=bench”
  node["amenity"="bench"]({{bbox}});
  way["amenity"="bench"]({{bbox}});
  relation["amenity"="bench"]({{bbox}});
  // query part for: “amenity=townhall”
  node["amenity"="townhall"]({{bbox}});
  way["amenity"="townhall"]({{bbox}});
  relation["amenity"="townhall"]({{bbox}});
);
// print results
out body;
>;
out skel qt;

Simply copy and paste that query code into the Query pane in QuickOSM, then click Run Query:

enter image description here

If you don't get all the geometry types returning, open up the 'advanced' section to ensure all geometry types are set. At first all geometry types weren't returned. When I opened the 'advanced' tab - without changing anything - and ran the query again, all geometry types came back.

9
  • I tried this method, but it only yielded points. (I'm searching for hospitals, schools, and colleges as polygons.) When I used "Advanced" to specify Multipolygons, there were no results. Yet when I run the Quick Query on any one of these, I do get polygons. What am I leaving out?
    – CSyrett
    Commented Apr 22, 2017 at 17:49
  • @CSyrett have you used OSM to determine those are the exact tags? Commented Apr 22, 2017 at 18:54
  • I have no idea what a "tag" is. All I know is that the query shows the polygons, points, and lines on the Overpass Turbo display, but the same query, copy-pasted to Quick Query, only yields points. It appears that the same query behaves differently from one to the other.
    – CSyrett
    Commented Apr 22, 2017 at 19:06
  • @CSyrett can you share the query you're using? Commented Apr 22, 2017 at 20:11
  • here it is: The original search was: “amenity = college or amenity = school” */ [out:json][timeout:25]; // gather results ( // query part for: “amenity=college” node["amenity"="college"]({{bbox}}); way["amenity"="college"]({{bbox}}); relation["amenity"="college"]({{bbox}}); // query part for: “amenity=school” node["amenity"="school"]({{bbox}}); way["amenity"="school"]({{bbox}}); relation["amenity"="school"]({{bbox}}); ); // print results out body; >; out skel qt;
    – CSyrett
    Commented Apr 22, 2017 at 20:27
1

One workaround could be:

  1. Generate query with the Quick query menu and one of the values, e.g. Key:amenity, Value:college.
  2. Switch to the Query window, copy and paste the query tags and replace the parameter v="college" with v="school".
  3. Repeat with v="hospital"
    See example (only for nodes):
<osm-script output="xml" timeout="25">
    <union>
        <query type="node">
            <has-kv k="amenity" v="college"/>
            <bbox-query {{bbox}}/>
        </query>
<query type="node">
            <has-kv k="amenity" v="school"/>
            <bbox-query {{bbox}}/>
        </query>
<query type="node">
            <has-kv k="amenity" v="hospital"/>
            <bbox-query {{bbox}}/>
        </query>
        <query type="way">
            <has-kv k="amenity" v="college"/>
            <bbox-query {{bbox}}/>
        </query>
        <query type="relation">
            <has-kv k="amenity" v="college"/>
            <bbox-query {{bbox}}/>
        </query>
    </union>
    <union>
        <item/>
        <recurse type="down"/>
    </union>
    <print mode="body"/>
</osm-script>

Hope this helps

0

For future look outs: you are looking in the wrong place with your query. You want to query for buildings.

<osm-script output="xml" timeout="25">
    <id-query {{geocodeArea:Oldenburg, Germany}} into="area_0"/>
    <union>
        <query type="node">
            <has-kv k="building" v="hotel"/>
            <area-query from="area_0"/>
        </query>
        <query type="way">
            <has-kv k="building" v="hotel"/>
            <area-query from="area_0"/>
        </query>
        <query type="relation">
            <has-kv k="building" v="hotel"/>
            <area-query from="area_0"/>
        </query>
    </union>
    <union>
        <item/>
        <recurse type="down"/>
    </union>
    <print mode="body"/>
</osm-script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.