3

I have read Overpass API by example, but still I am unable to adapt convert statement examples to my need. What I would like to do is to get all marked routes in the area using Overpass Turbo, drop some tags and synthesize some new tags.

My query looks like this:

relation[route][route!="power"][route!="road"]({{bbox}});

out body;
>;
out skel qt;

I would like to:

  • add tag color=green when osmc:symbol contains green or when tag kct_green exists
  • add tag color=blue when osmc:symbol contains blue or when tag kct_blue exists
  • add tag kind as a value of any tags of kct_green, kct_blue, kct_red, kct_green
  • remove some tags I no longer need to reduce output file size (like kct_green)

My initial naive attempt is:

relation[route][route!="power"][route!="road"]({{bbox}});

foreach (
  convert rel ::=::,
    ::id = id(),
    color=t["osmc:symbol"]
  ;

  out;
);

out body;
>;
out skel qt;

This kind of works, but lists relations without including their nodes. Moreover, I would like to perform a bit more processing on the color value:

  • I want the color to be created only osmc:symbol is present
  • I want to extract some information from osmc:symbol to color
  • I have no idea how to create the combined value from those kct_green... tags.

I guess I need something more complex, however I have found almost no documentation or examples about convert. Can someone point me in the right direction?

5
  • Some of the things you mentioned are only available with 0.7.55 (geometry via ::geom()) and are not yet documented (will follow soon). Otherwise, it's not quite clear what you mean by "osmc:symbol contains green". Is this meant as substring?
    – mmd
    May 14, 2018 at 8:11
  • Yes, as substring. If this is not possible, how about other things? What is critical is nodes needs to be present in the output relation - without this it makes no sense to convert them.
    – Suma
    May 14, 2018 at 18:59
  • Well, nodes are returned in a completely different format, as vertex: overpass-turbo.eu/s/yO2 - not sure if this helps. Also, substring processing is not possible yet as part of an expression, it's simply not implemented.
    – mmd
    May 15, 2018 at 7:10
  • The trouble with using the ::geom = geom() is when I export such data as GeoJSON, they are empty. I was able to include relation ways and nodes by using > or its building blocks (way(r), node(r), node(w)), however only when not using convert. As soon as I use convert, way(r) stops working.
    – Suma
    May 17, 2018 at 10:14
  • 1
    It sounds like you were better off downloading the relations, and do your own post processing locally.
    – mmd
    May 18, 2018 at 8:51

1 Answer 1

1

After some experimentation I have found at least a way to add and remove tags:

(
  relation[route][route="hiking"]({{bbox}});
  relation[route][route="foot"]({{bbox}});
  relation[route][route="mtb"]({{bbox}});
  relation[route][route="bicycle"]({{bbox}});
)->.routes;

foreach.routes (
  > -> .w;
  convert rel 
    ::id = id(),
    color=t["osmc:symbol"],
    !complete,
    !destinations,
    !type,
    ::=::
  ->.x;
  (.x;.w;);
  out;
);

out body;
>;
out skel qt;

If I will be able to achieve more, I will update the answer accordingly.

1
  • It shows this does not work as I expected. While it outputs the relation nodes, it does not output them as a part of the relation, but next to them :(
    – Suma
    May 17, 2018 at 12:17

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.