1

I'm looking to map (for the sake of the example) all memorials to Lincoln in California using QGIS' QuickOSM plugin.

The query I can easily set up

[out:xml] [timeout:25];
 {{geocodeArea:California}} -> .area_0;
(
    node["memorial"]["name"="Lincoln"](area.area_0);
);
(._;>;);
out body;

looks for the exact match in the name tag. As a result, QuickOSM returns me the message Successful query, but no result, even though California definitely has a memorial with "Lincoln" in the name (the "Abraham Lincoln War Memorial" in Oakland, at least).

How do I formulate the query so that it only checks if the name tag contains this string?

I found a feature request on Github for Overpass API, and a discussion here proposing to use "LIKE", which is however apparently not working for QuickOSM:

[out:xml] [timeout:25];
 {{geocodeArea:California}} -> .area_0;
(
    node["memorial"]["name" LIKE "%Lincoln%"](area.area_0);

);
(._;>;);
out body;

returns Bad request OverpassAPI.

6
  • If it it close to plain SQL then try "'%Lincoln%'".
    – user30184
    Feb 10 at 7:34
  • Your first query doesn't return any data if you copy/paste in overpass-turbo.eu as well which is using the same database in the backend. I haven't debug your query, maybe you are not in the correct "geocoded area".
    – etrimaille
    Feb 10 at 9:18
  • @etrimaille Yes exactly, because this is the syntax for an exact match in the name tag. If I change the query to include the full name (i.e. "name"="Abraham Lincoln War Memorial"), then both QuickOSM and overpass-turbo.eu return one result (that one in Oakland). My question is about how I can search for a partial match in the name tag.
    – DK2AX
    Feb 10 at 17:08
  • @user30184 When I try this in QuickOSM or overpass-turbo.eu, I get the same message ("Successful query, but no result"), so it seems the % symbol doesn't act as a wildcard in this case.
    – DK2AX
    Feb 10 at 17:10
  • Sorry, the question was maybe not clear
    – etrimaille
    Feb 10 at 18:22

1 Answer 1

1

The solution turned out to be relatively simple: it's sufficient to replace the = with a ~. This apparently looks for partial matches.

Using the original example:

[out:xml] [timeout:25];
 {{geocodeArea:California}} -> .area_0;
(
    node["memorial"]["name" ~ "Lincoln"](area.area_0);
);
(._;>;);
out body;

now successfully returns three memorials to Lincoln in California, including the one in Oakland.

Your Answer

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

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