Overpass API - remove nodes/points

Hi
I’m struggling to understand Overpass API

I’m trying to download a relation by it’s name & a bounding box in geojson format. I don’t want any meta data such as ‘version’ or ‘timestamp’ etc.

I also don’t want any nodes/points:'“id”: “node/xxxxx”.

Using this query in the Turbo front end, this query does what I require except it returns the nodes:

relation
[“name”=“Cycle route”]
[“ref”=“213”];
out skel;
._;

;
out;

Is there way to remove the nodes?

Second question:

Instead of using Overpass Turbo, I want to use my query in a windows script file (,bat)

From searching on the web I notice there are at least two ‘versions’ of overpass api: interpreter & xapi. I’ve read all the info about them but I’m still unclear what there differences are. Can anyone explain, in simple terms, what they each do & which is best to use?

Third question:

As said earlier I need the data in geojson format so I can use it in in my Leaflet JavaScript derived map. Within Turbo there’s an option to convert to geojson, but from reading the web page, it appears there are only three direct output formats ie [out:josn]. Is there a way to perform the conversion in my script?

Hope I’ve been clear.
Cheers
Dave F.

With your query I get an empty result, which is in fact good, as the tagging name=“Cycle route” sounds wrong. A cycle route should only be tagged this way if this is the actual name of the route, which I doubt in this case. See the wiki for proper tagging of cycle routes.

To get only ways and no nodes, use way(r) instead of >.

Hi
Thanks for the reply.

I wasn’t fully clear as to what I require. In geojson format I need all the nodes as they contain the co-ordinates. What isn’t required is the data for the nodes that have tags attached to them. In geojson they get listed as ‘Features’ & in Leaflet automatically get displayed with a marker. I wish to avoid that.

I posted generic names as previously when I gave specific data I got unfairly criticised for other edits I’d made in the area.

relation
[“name”=“Two Tunnels Greenway”]
“ref”=“244”;
(
._;

;
);
out;

Running this in Turbo, the nodes/points I wish to remove are displayed as blue circles on the output map & if saved as Geojson are listed at the end of the file like this:

{
“type”: “Feature”,
“id”: “node/3130349472”,
“properties”: {
@id”: “node/3130349472”,
“barrier”: “bollard”
},
“geometry”: {
“type”: “Point”,
“coordinates”: [
-2.3784883,
51.3737668
]
}
}

Cheers
Dave F.

Well… You could simply not display them, by using a custom style sheet :wink:
I suspect it’s not possible (or at least notably more complicated) to omit the tags of specific objects in OPAPIs response.

Possibly true, but I’m trying to learn OPAPI & much prefer (if possible) to obtain the most accurate data I can, at source.

Disappointing, if true. What I’m trying to do doesn’t appear, to me, to be that convoluted. :frowning:

Okay then: I would try to find all important data, output it normally, do a “>;” and output that with a mode (like “out meta;”) which keeps coordinates but omits tags. I’m not sure if it’s that easy, but that’s how I would start (after some thinking at least :wink: ).

Hi
I’ve done a lot of reading & thinking, but the wiki pages are confusingly structured. :frowning:

I’m struggling to find out how to use an ‘and’ operator - I wish to return a list of ways with their tags & co-ordinates for the relation named ‘Two Tunnels Circuit’ that are also tagged with oneway=yes.

Overpass appears to have it for multiple tags: http://wiki.openstreetmap.org/wiki/Overpass_API/Language_Guide#Multiple_tags, but I can’t find a way to do the same for different objects.

There also appears to be a ‘difference’ operator between multiple object types: http://forum.openstreetmap.org/viewtopic.php?id=22070 but if I swap the ‘-’ for ‘+’ it returns a syntax error!

I’m obviously missing something, so before I pull out the rest of my hair, could you please tell what it is? :slight_smile:
This is a far as I got but it’s performing an ‘or’ operation:

[bbox:51.38185,-2.36515,51.38294,-2.36166];
(
relation[name=“Two Tunnels Circuit”];
way[oneway=yes];
);
(._;>;);
out;

Thanks
Dave F.

Luckily there was a similar question in the german forum some days ago. I’ll try to adopt it to your question (without the bbox):


relation[name="Two Tunnels Circuit"]; /* get the relation */
way(r)[oneway=yes];                   /* get it's ways, but only those with oneway=yes (and thereby forget the relation) */
out meta;                              /* output this with meta data */
>;                                    /* get everything referenced by those ways */
out skel;                              /* output it, but only essential data */

That timed out at line 2 after 180 seconds, even after adding bbox so may have been collecting data from a wide spread area.

After searching the web I’ve finally worked out how to use & store into variables & came up with this:

relationname=“Two Tunnels Circuit” → .all;
way(r.all:“backward”)->.back;
way(r.all:“forward”)->.forw;
(.back; .forw;);
out ;

;
out ;

http://overpass-turbo.eu/s/5O0

It finds all the roles for the relation (backwards & forwards) & then combines them. I’m sure it can be simplified further, but does work for this instance.

For future uses, I’d still like to find out how to get [oneway=yes] to work though.

Thanks for sharing, might help me :wink:

Strange, because I just tried it (exactly as in my posting) and it worked. Maybe just try again or on a less frequently used server?

I tried

relationname=“Two Tunnels Circuit” → .all;
way(r.all)->.allways;
way.allways[oneway=“yes”]->.oneways;
(.oneways;);
out;

;
out;

and it seems to give the same result as your query. I think the quotes around the yes are important. It’s a string like any other value, so it requires quotes.

this gives the same result with 1 line less

relationname=“Two Tunnels Circuit” → .all;
way(r.all)->.allways;
(way.allways[oneway=“yes”];);
out;

;
out;

Trying to answer a few open points here:

Overpass Turbo provides a link to download raw data (Export → raw data directly from Overpass API). You can use this link along with a download tool like wget, etc.

Overpass API won’t return data in geojson format on its own, but there’s a dedicated javascript lib available to do this conversion (https://github.com/tyrasd/osmtogeojson) - just to name one example, there are many more. It’s the same lib which is used from within overpass turbo.

“+” as union operation doesn’t really exist. You should use


( .set1; .set2; .set3;);

instead.

These additional quotes for yes are not required.

That’s a bug, which is triggered by the way the statement is executed. Please consider creating an issue here.

However, the following query works without issue: (Important change: oneway=yes was replaced by a regular expression: oneway~“^yes$” to simply force a different evaluation sequence inside Overpass API. Functional wise this is exactly the same.)


relation[name="Two Tunnels Circuit"];
way(r)[oneway~"^yes$"];
out geom;

Link: http://overpass-turbo.eu/s/5Qv

Thanks to all. A great help for now & the future.

Well, I’ve just tried that converter, & spent a few hours in compete bafflement as it doesn’t return the same format! Turbo: lists all tags under 'properties & suffixes relations & id with ‘@’ symbols, while Osmtogeojson segregates tags into a separate child called ‘tags’ & doesn’t use ‘@’.

Is there a reason for these confusing differences?

Using this I was able to find ways with a relation that has it’s ‘role’ set from data converted by Osmtogeojson:

(feature.properties.relations[0].role) {

For future reference, how do I do the same for Turbo derived data?:

{
      "type": "Feature",
      "id": "way/269998332",
      "properties": {
        "@id": "way/269998332",
        "highway": "cycleway",
        "segregated": "no",
        "surface": "asphalt",
        "note": "blah",
	"@relations": [
          {
            "role": "",
            "rel": 4137412,
            "reltags": {
              "name": "Two Tunnels Circuit",
              "route": "bicycle",
              "type": "route"
            }
          }
        ]
      },... <snip>

This is as far as I got without getting an error:

(feature.properties['@relations'])

This doesn’t work :frowning:

(feature.properties['@relations'][0].role)

Any ideas?

L̶a̶s̶t̶l̶y̶,̶ ̶d̶o̶e̶s̶ ̶t̶h̶e̶ ̶’̶g̶e̶o̶m̶’̶ ̶o̶u̶t̶ ̶j̶u̶s̶t̶ ̶r̶e̶m̶o̶v̶e̶ ̶t̶h̶e̶ ̶r̶e̶l̶a̶t̶i̶o̶n̶ ̶d̶a̶t̶a̶ ̶w̶h̶e̶n̶ ̶c̶o̶m̶p̶a̶r̶e̶d̶ ̶w̶i̶t̶h̶ ̶’̶b̶o̶d̶y̶’̶?̶?̶ ̶I̶ ̶c̶a̶n̶t̶ ̶f̶i̶n̶d̶ ̶i̶t̶ ̶d̶e̶s̶c̶r̶i̶b̶e̶d̶ ̶i̶n̶ ̶t̶h̶e̶ ̶w̶i̶k̶i̶ ̶p̶a̶g̶e̶s̶.̶

Scrub that. Found it.

Found the solution - way(r) and out geom:

(relation ["name"="Two Tunnels Circuit"] (51.34669,-2.39021,51.39781,-2.30077);
 way(r);  
);
out geom;

http://overpass-turbo.eu/s/5Tp

Couldn’t be simpler. :wink: