notes on OSM queries

possible osm login: s@ilc osmcarrots display: wwturner

OsmAnd

OSMAND

  1. purchase & install OsmAnd
  2. d/l DC and MD maps
  3. plugins -> osm editing -> enable
  4. -> osm editing
  5. [info as above]
  6. video says to un-check "Snap to street", but couldn't find that config item

create a POI:

on my phone:

at location where you want to create a POI:

then in Create POI window:

    Name: <whatever>
    POI Type: start spelling "Public bookcase"
    -> to finish
    if certain, then:
    -> UPLOAD

Mapillary

after various attempts at "login via openstreetmap", may have logged in...

refs:

LearnOverpass(from youtube video): https://osmlab.github.io/learnoverpass//en/

Overpass API/Overpass QL https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL

Overpass API/Language Guide (good, but old): https://wiki.openstreetmap.org/wiki/Overpass_API/Language_Guide

Overpass API/Overpass API by Example: https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_API_by_Example

Overpass API: https://wiki.openstreetmap.org/wiki/Overpass_API

sandbox: https://overpass-turbo.eu/

Overpass API User's Manual: https://dev.overpass-api.de/overpass-doc/en/

Overpass Turbo; The standard tool to develop requests: https://dev.overpass-api.de/overpass-doc/en/targets/turbo.html

Loading Data from OpenStreetMap with Python and the Overpass API: https://towardsdatascience.com/loading-data-from-openstreetmap-with-python-and-the-overpass-api-513882a27fd0
Loading Data from OpenStreetMap with Python and the Overpass API: https://janakiev.com/blog/openstreetmap-with-python-and-overpass-api/

Python

install

     $ ~/usr/local/bin/pip3.7 install overpy

code:

#!/home/wendell/usr/local/bin/python3.7

import overpy

api = overpy.Overpass()

# fetch all ways and nodes
result = api.query("""
    way(50.746,7.154,50.748,7.157) ["highway"];
    (._;>;);
    out body;
    """)

for way in result.ways:
    print("Name: %s" % way.tags.get("name", "n/a"))
    print("  Highway: %s" % way.tags.get("highway", "n/a"))
    print("  Nodes:")
    for node in way.nodes:
        print("    Lat: %f, Lon: %f" % (node.lat, node.lon))

works fine.

osm2geojson.py

seems to work fine as import'ed file.

Issues (with OSM):

Q: HOW TO merge location-oriented d.b. (osm) with business-oriented ones (yp, wp business pg dir, restaurants.com, etc)

OverPass (Turbo?)

Their original:

/*
This shows the cycleway and cycleroute network.
*/

[out:json];

(
  // get cycle route relations
  relation[route=bicycle]({{bbox}});
  // get cycleways
  way[highway=cycleway]({{bbox}});
  way[highway=path][bicycle=designated]({{bbox}});
);

out body;
>;
out skel qt;

using: https://overpass-turbo.eu/

seems pretty good:

/*
my attempt at footpaths
*/

[out:json];

(
  // get cycle route relations
  relation[route=foot]({{bbox}});
  // get cycleways
  way[highway=pedestrian]({{bbox}});
  way[highway=path][foot=designated]({{bbox}});
  way[highway=path]({{bbox}});
  way[highway=footway]({{bbox}});
);

out body;
>;
out skel qt;

libraries

/* my attempt at libraries; looks ok */

[out:json];

(
  node[amenity=library]({{bbox}});
  way[amenity=library]({{bbox}});
  rel[amenity=library]({{bbox}});
  nwr[name=library];
  nw[name=library];
  nr[name=library];
  wr[name=library];
  derived[name=library];
  area[name=library];
);

/* Print all information necessary to use the data. These are
also tags for all elements and the roles for relation members.*/

out body;

/* Recurse down */

>;

/*Print the minimum information necessary for geometry; Sort by quadtile index */

out skel qt;

above, but concise:

[out:json][bbox:{{bbox}}];
( node[amenity=library];
  way[amenity=library];
  rel[amenity=library];
  nwr[name=library];
  nw[name=library];
  nr[name=library];
  wr[name=library];
  derived[name=library];
  area[name=library];
);
out body;
>;
out skel qt;

todo:

see how these are listed in:
openstreetmap
NOT: yellowpages (MOVE elsewhere)

openstreetmap tags

the definitions: https://taginfo.openstreetmap.org/

(semester thesis in informatics at the Geometa Lab, University for Applied Sciences Rapperswil (Switzerland))

    * fountain
        amenity=fountain         (done)
        !amenity=drinking_water
        fountain=*

    * roadside attraction:
        tourism=attraction
        tourism=museum           (done)
        attraction=animal
        attraction=maze
        attraction=train
        attraction=*
        tourism=*
        railway=preserved
        railway:preserved=* and usage=tourism

    * gardens
    (above, plus):
        leisure=garden
        garden:style=*

    * dairy
        landuse=animal_keeping
        landuse=farmyard

    * library
        amenity=library           (done)
        amenity=public_bookcase   (done)
        shop=books

    * shop
        shop=clothes
        shop=confectionery
        shop=farm
        shop=charity            (confirm)
        shop=second_hand        (done)

        shop=cheese          ;  3,234 records
        amenity=ice_cream    ; 28,618 records  (done)
        shop=ice_cream       ;  2,285 records  (done)
        ice_cream=*          ;    464 records
        charity=yes

yellow pages categories

obtained by looking at categories of specific restaurants & stores and reviewing related pages

https://www.yellowpages.com/

restaurants:
    asian
    vietnamese
    seafood
    seafood
    thai

thrift
    thrift shops
    resale shops
    second hand dealers
    consignment service
    social service organizations (goodwill)
    clothing - collectible, period, vintage

see also: https://www.yellowbook.com/

various templates

[out:json][bbox:{{bbox}}];
( node[amenity=public_bookcase];
  way[amenity=public_bookcase];
  rel[amenity=public_bookcase];
  nwr[name=public_bookcase];
  nw[name=public_bookcase];
  nr[name=public_bookcase];
  wr[name=public_bookcase];
  derived[name=public_bookcase];
  area[name=public_bookcase];
);
out body;
>;
out skel qt;

very few around C.P.

[out:json][bbox:{{bbox}}];
( node[attraction=summer_toboggan];
  way[attraction=summer_toboggan];
  rel[attraction=summer_toboggan];
  nwr[name=summer_toboggan];
  nw[name=summer_toboggan];
  nr[name=summer_toboggan];
  wr[name=summer_toboggan];
  derived[name=summer_toboggan];
  area[name=summer_toboggan];
);
out body;
>;
out skel qt;

3 in US, 716 in Germany

to converge the properties lists:

get just properties:

    sed  -n '/"properties": {/,/^ *}/p' all_gjson.jsn  > just_properties.txt
    awk '{print $1}' just_properties.txt  | sort | uniq -c | sort -n

native overpass (i.e., not turbo)

see: https://github.com/mvexel/overpass-api-python-wrapper

You can set the response type of your query using get()'s responseformat parameter to GeoJSON (geojson, the default), plain JSON (json), CSV (csv), and OSM XML (xml).

    response = api.get('node["name"="Salt Lake City"]', responseformat="xml")

We will construct a valid Overpass QL query from the parameters you set by default. This means you don't have to include 'meta' statements like [out:json], [timeout:60], [out body], etcetera. You just supply the meat of the query, the part that actually tells Overpass what to query for.

SO, the choices are:

May 7, 2020: rewrite multiple overpass queries into ONE query

guideline: https://github.com/mvexel/overpass-api-python-wrapper/issues/112

    [out:json]
    [timeout:600];
    {{geocodeArea:Oxfordshire}}->.searchArea;
    (
      node[name="McDonald's"][amenity=fast_food](area.searchArea);
      way[name="McDonald's"][amenity=fast_food](area.searchArea);
      relation[name="McDonald's"][amenity=fast_food](area.searchArea);
    );
    out body;

which would be:

[out:json]
[timeout:600]
[bbox:{{bbox}}];
(
  node[amenity=library];
  way[amenity=library];
  rel[amenity=library];
  nwr[name=library];
  nw[name=library];
  nr[name=library];
  wr[name=library];
  derived[name=library];
);
out body;
>;
out skel qt;

https://dev.overpass-api.de/blog/bounding_boxes.html

This is simplified to:

[bbox:{{bbox}}];
( node[amenity=restaurant];
  way[amenity=restaurant];
  rel[amenity=restaurant]; );
out center;

and that, together with this:

so: https://help.openstreetmap.org/questions/61923/grouping-multiple-categories-in-overpass-turbo

area["name"="London"]["admin_level"="6"];
node(area)["amenity"="cafe"]->.cafe;
node(area)["amenity"="bar"]->.bar;
(
.cafe;
.bar;
)->.all;
( .all; - ._; );
(._;);
out;

all together now:

here goes:

[out:json][timeout:600][bbox:{{bbox}}];
( node[amenity=library];
  way[amenity=library];
  rel[amenity=library];
  nwr[name=library];
  nw[name=library];
  nr[name=library];
  wr[name=library];
  derived[name=library];
)->.libs;
( node[amenity=ice_cream];
  way[amenity=ice_cream];
  rel[amenity=ice_cream];
  nwr[name=ice_cream];
  nw[name=ice_cream];
  nr[name=ice_cream];
  wr[name=ice_cream];
  derived[name=ice_cream];
)->.icec;
(
.libs;
.icec;
)->.all;
( .all; - ._; );
(._;);
out;

Well??? No,

but this DOES work:

[out:json][bbox:{{bbox}}];
( node[amenity=library];
  way[amenity=library];
  rel[amenity=library];
  nwr[name=library];
  nw[name=library];
  nr[name=library];
  wr[name=library];
  derived[name=library];
)->.libs;
( node[amenity=ice_cream];
  way[amenity=ice_cream];
  rel[amenity=ice_cream];
  nwr[name=ice_cream];
  nw[name=ice_cream];
  nr[name=ice_cream];
  wr[name=ice_cream];
  derived[name=ice_cream];
)->.icec;
( .libs; .icec; );
out body;
>;
out skel qt;

OK, now put this back into python:

gis/overpy_apr_2020/plain_overpass : mm.py

1) build=False

Nope. "[out:json];" is STILL getting inserted.

Yipee! mm.py works!

more (old?) notes:

For historical reasons, there is also another mechanism to set an initial bounding box everywhere. It has been designed to simplify using the Overpass API from OpenLayers.

https://stackoverflow.com/questions/40253241/does-bbox-query-return-ways-that-are-partially-in-the-bounding-box

These days, overpass turbo wizard creates Overpass QL instead, which reads as:

[out:xml][timeout:25];(way(43.64019,-79.39941,43.64120,-79.39798);node(43.64019,-79.39941,43.64120,-79.39798););(._;>;);out meta qt;

Overpass XML is the older language variant, all recent tutorials are mostly "Overpass QL first". As documentation I only use wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL, all others are more or less incomplete or based on some examples as you noted.

Barbecue

Hursey's:

    addr:city=Burlington
    addr:housenumber=1834
    addr:postcode=27215
    addr:state=NC
    addr:street=South Church Street
    amenity=restaurant
    building=yes
    capacity=100
    cuisine=barbecue
    name=Hursey’s Pig Pickin’ Bar–B–Q
    opening_hours=Su-Sa 11:00-21:00
    phone=+1-336-226-1694
    smoking=no
    website=https://hurseysbarbecue.com/

Zack's doesn't show up as anything.

Bar-B-Q Center

    addr:city=Thomasville
    addr:country=US
    addr:housenumber=900
    addr:state=NC
    addr:street=North Main Street
    amenity=restaurant
    cuisine=barbecue
    name=Bar-B-Q Center

Lexington #1:

    amenity=restaurant
    cuisine=regional
    name=Lexington BBQ

Stamey's Greensboro: just building=yes