Query nodes and attributes of parent waysOverpass API: Get coordinates of postal boundaryCorrect order of...

How to prevent cables getting intertwined

In windows systems, is renaming files functionally similar to deleting them?

How did Frodo know where the Bree village was?

What kind of chart is this?

Counterfeit check

Is using Legacy mode is a bad thing to do?

How "fast" do astronomical events occur?

How to write a nice frame challenge?

Leaving job close to major deadlines

How to ask if I can mow my neighbor's lawn

How do I become a better writer when I hate reading?

In a Fish that is not a Fish

Do battery electrons only move if there is a positive terminal at the end of the wire?

What is "dot" sign in •NO?

How much steel armor can you wear and still be able to swim?

Using roof rails to set up hammock

I wish, I yearn, for an answer to this riddle

How did space travel spread throughout the Star Wars galaxy?

Simplify, equivalent for (p ∨ ¬q) ∧ (¬p ∨ ¬q)

Is it a bad idea to have a pen name with only an initial for a surname?

Why we can't jump without bending our knees?

Does knowing the surface area of all faces uniquely determine a tetrahedron?

Credit card validation in C

How do credit card companies know what type of business I'm paying for?



Query nodes and attributes of parent ways


Overpass API: Get coordinates of postal boundaryCorrect order of nodes in Overpass queryHow can I get a relation with multiple ways as members in addition to the members with Overpass QL?Is there a Service to get only nodes from OSM?Query for WAY that connects two INTERSECTIONSA way to find all footway and street interesections in openstreetmapOverpass / Overpy: Getting Way IDs from NodesOverpass API - Multiple ways for same roadFetching node(nd) reference data of way in Overpass query resultRetrieving OpenStreetMap data (ways and its child nodes) by coordinates using Overpass API?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







1















Does the Overpass API provide a way to query a list of nodes and some attributes of their parent ways, and return the data in CSV format?



For example, the following will give me all motorway junctions:



[out:csv(ref, name, ::lat, ::lon)];
// gather results
(
// query part for: “highway=milestone”
node["highway"="motorway_junction"]({{bbox}});
);
// print results
out body;
>;
out skel qt;


Is there a way to query the ref=* tag of the roads of which the node is a member?










share|improve this question





























    1















    Does the Overpass API provide a way to query a list of nodes and some attributes of their parent ways, and return the data in CSV format?



    For example, the following will give me all motorway junctions:



    [out:csv(ref, name, ::lat, ::lon)];
    // gather results
    (
    // query part for: “highway=milestone”
    node["highway"="motorway_junction"]({{bbox}});
    );
    // print results
    out body;
    >;
    out skel qt;


    Is there a way to query the ref=* tag of the roads of which the node is a member?










    share|improve this question

























      1












      1








      1








      Does the Overpass API provide a way to query a list of nodes and some attributes of their parent ways, and return the data in CSV format?



      For example, the following will give me all motorway junctions:



      [out:csv(ref, name, ::lat, ::lon)];
      // gather results
      (
      // query part for: “highway=milestone”
      node["highway"="motorway_junction"]({{bbox}});
      );
      // print results
      out body;
      >;
      out skel qt;


      Is there a way to query the ref=* tag of the roads of which the node is a member?










      share|improve this question














      Does the Overpass API provide a way to query a list of nodes and some attributes of their parent ways, and return the data in CSV format?



      For example, the following will give me all motorway junctions:



      [out:csv(ref, name, ::lat, ::lon)];
      // gather results
      (
      // query part for: “highway=milestone”
      node["highway"="motorway_junction"]({{bbox}});
      );
      // print results
      out body;
      >;
      out skel qt;


      Is there a way to query the ref=* tag of the roads of which the node is a member?







      openstreetmap overpass-api






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 8 hours ago









      user149408user149408

      18017




      18017






















          1 Answer
          1






          active

          oldest

          votes


















          2














          Yes, that's possible:



          [out:csv(_ref, name, ::lat, ::lon)];
          node["highway"="motorway_junction"]({{bbox}});

          foreach { // iterate over nodes

          way(bn)[highway~"^(motorway|trunk)$"][ref] -> .ways; // find ways for each node
          if (ways.count(ways) > 0) { // check that at least 1 way was found
          convert result // assemble result
          ::id = id(), // use node id
          ::geom = center(geom()), // and node position
          _ref = ways.u(t["ref"]), // parent ref tag
          :: = ::; // all remaining tags of the node
          out geom; // print node
          }
          }





          share|improve this answer


























          • Thanks! I’ve edited the answer to include also trunk roads. There are still issues to be solved where multiple ways with different ref tags are involved: either different spellings (A8 vs. A 8), or the road name actually changes at the junction (A2 becoming S8). The solution to that probably depends on the use case: I would want two rows, one for each road, so it’s probably better to search for the roads and iterate over its junctions.

            – user149408
            7 hours ago








          • 1





            To have one single entry for each of the ".ways", you'd need to add another foreach loop and iterate over those ways.

            – mmd
            7 hours ago











          • So I’ve replaced the if with another foreach, and I get short of 200 results (which looks OK). Problem is, how can I refer to tags of the way from the inner foreach?

            – user149408
            6 hours ago






          • 1





            Try this one: overpass-turbo.eu/s/JY8

            – mmd
            6 hours ago











          • That did the trick. Thanks again!

            – user149408
            6 hours ago












          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "79"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f325914%2fquery-nodes-and-attributes-of-parent-ways%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2














          Yes, that's possible:



          [out:csv(_ref, name, ::lat, ::lon)];
          node["highway"="motorway_junction"]({{bbox}});

          foreach { // iterate over nodes

          way(bn)[highway~"^(motorway|trunk)$"][ref] -> .ways; // find ways for each node
          if (ways.count(ways) > 0) { // check that at least 1 way was found
          convert result // assemble result
          ::id = id(), // use node id
          ::geom = center(geom()), // and node position
          _ref = ways.u(t["ref"]), // parent ref tag
          :: = ::; // all remaining tags of the node
          out geom; // print node
          }
          }





          share|improve this answer


























          • Thanks! I’ve edited the answer to include also trunk roads. There are still issues to be solved where multiple ways with different ref tags are involved: either different spellings (A8 vs. A 8), or the road name actually changes at the junction (A2 becoming S8). The solution to that probably depends on the use case: I would want two rows, one for each road, so it’s probably better to search for the roads and iterate over its junctions.

            – user149408
            7 hours ago








          • 1





            To have one single entry for each of the ".ways", you'd need to add another foreach loop and iterate over those ways.

            – mmd
            7 hours ago











          • So I’ve replaced the if with another foreach, and I get short of 200 results (which looks OK). Problem is, how can I refer to tags of the way from the inner foreach?

            – user149408
            6 hours ago






          • 1





            Try this one: overpass-turbo.eu/s/JY8

            – mmd
            6 hours ago











          • That did the trick. Thanks again!

            – user149408
            6 hours ago
















          2














          Yes, that's possible:



          [out:csv(_ref, name, ::lat, ::lon)];
          node["highway"="motorway_junction"]({{bbox}});

          foreach { // iterate over nodes

          way(bn)[highway~"^(motorway|trunk)$"][ref] -> .ways; // find ways for each node
          if (ways.count(ways) > 0) { // check that at least 1 way was found
          convert result // assemble result
          ::id = id(), // use node id
          ::geom = center(geom()), // and node position
          _ref = ways.u(t["ref"]), // parent ref tag
          :: = ::; // all remaining tags of the node
          out geom; // print node
          }
          }





          share|improve this answer


























          • Thanks! I’ve edited the answer to include also trunk roads. There are still issues to be solved where multiple ways with different ref tags are involved: either different spellings (A8 vs. A 8), or the road name actually changes at the junction (A2 becoming S8). The solution to that probably depends on the use case: I would want two rows, one for each road, so it’s probably better to search for the roads and iterate over its junctions.

            – user149408
            7 hours ago








          • 1





            To have one single entry for each of the ".ways", you'd need to add another foreach loop and iterate over those ways.

            – mmd
            7 hours ago











          • So I’ve replaced the if with another foreach, and I get short of 200 results (which looks OK). Problem is, how can I refer to tags of the way from the inner foreach?

            – user149408
            6 hours ago






          • 1





            Try this one: overpass-turbo.eu/s/JY8

            – mmd
            6 hours ago











          • That did the trick. Thanks again!

            – user149408
            6 hours ago














          2












          2








          2







          Yes, that's possible:



          [out:csv(_ref, name, ::lat, ::lon)];
          node["highway"="motorway_junction"]({{bbox}});

          foreach { // iterate over nodes

          way(bn)[highway~"^(motorway|trunk)$"][ref] -> .ways; // find ways for each node
          if (ways.count(ways) > 0) { // check that at least 1 way was found
          convert result // assemble result
          ::id = id(), // use node id
          ::geom = center(geom()), // and node position
          _ref = ways.u(t["ref"]), // parent ref tag
          :: = ::; // all remaining tags of the node
          out geom; // print node
          }
          }





          share|improve this answer















          Yes, that's possible:



          [out:csv(_ref, name, ::lat, ::lon)];
          node["highway"="motorway_junction"]({{bbox}});

          foreach { // iterate over nodes

          way(bn)[highway~"^(motorway|trunk)$"][ref] -> .ways; // find ways for each node
          if (ways.count(ways) > 0) { // check that at least 1 way was found
          convert result // assemble result
          ::id = id(), // use node id
          ::geom = center(geom()), // and node position
          _ref = ways.u(t["ref"]), // parent ref tag
          :: = ::; // all remaining tags of the node
          out geom; // print node
          }
          }






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 7 hours ago









          user149408

          18017




          18017










          answered 8 hours ago









          mmdmmd

          2,3651616




          2,3651616













          • Thanks! I’ve edited the answer to include also trunk roads. There are still issues to be solved where multiple ways with different ref tags are involved: either different spellings (A8 vs. A 8), or the road name actually changes at the junction (A2 becoming S8). The solution to that probably depends on the use case: I would want two rows, one for each road, so it’s probably better to search for the roads and iterate over its junctions.

            – user149408
            7 hours ago








          • 1





            To have one single entry for each of the ".ways", you'd need to add another foreach loop and iterate over those ways.

            – mmd
            7 hours ago











          • So I’ve replaced the if with another foreach, and I get short of 200 results (which looks OK). Problem is, how can I refer to tags of the way from the inner foreach?

            – user149408
            6 hours ago






          • 1





            Try this one: overpass-turbo.eu/s/JY8

            – mmd
            6 hours ago











          • That did the trick. Thanks again!

            – user149408
            6 hours ago



















          • Thanks! I’ve edited the answer to include also trunk roads. There are still issues to be solved where multiple ways with different ref tags are involved: either different spellings (A8 vs. A 8), or the road name actually changes at the junction (A2 becoming S8). The solution to that probably depends on the use case: I would want two rows, one for each road, so it’s probably better to search for the roads and iterate over its junctions.

            – user149408
            7 hours ago








          • 1





            To have one single entry for each of the ".ways", you'd need to add another foreach loop and iterate over those ways.

            – mmd
            7 hours ago











          • So I’ve replaced the if with another foreach, and I get short of 200 results (which looks OK). Problem is, how can I refer to tags of the way from the inner foreach?

            – user149408
            6 hours ago






          • 1





            Try this one: overpass-turbo.eu/s/JY8

            – mmd
            6 hours ago











          • That did the trick. Thanks again!

            – user149408
            6 hours ago

















          Thanks! I’ve edited the answer to include also trunk roads. There are still issues to be solved where multiple ways with different ref tags are involved: either different spellings (A8 vs. A 8), or the road name actually changes at the junction (A2 becoming S8). The solution to that probably depends on the use case: I would want two rows, one for each road, so it’s probably better to search for the roads and iterate over its junctions.

          – user149408
          7 hours ago







          Thanks! I’ve edited the answer to include also trunk roads. There are still issues to be solved where multiple ways with different ref tags are involved: either different spellings (A8 vs. A 8), or the road name actually changes at the junction (A2 becoming S8). The solution to that probably depends on the use case: I would want two rows, one for each road, so it’s probably better to search for the roads and iterate over its junctions.

          – user149408
          7 hours ago






          1




          1





          To have one single entry for each of the ".ways", you'd need to add another foreach loop and iterate over those ways.

          – mmd
          7 hours ago





          To have one single entry for each of the ".ways", you'd need to add another foreach loop and iterate over those ways.

          – mmd
          7 hours ago













          So I’ve replaced the if with another foreach, and I get short of 200 results (which looks OK). Problem is, how can I refer to tags of the way from the inner foreach?

          – user149408
          6 hours ago





          So I’ve replaced the if with another foreach, and I get short of 200 results (which looks OK). Problem is, how can I refer to tags of the way from the inner foreach?

          – user149408
          6 hours ago




          1




          1





          Try this one: overpass-turbo.eu/s/JY8

          – mmd
          6 hours ago





          Try this one: overpass-turbo.eu/s/JY8

          – mmd
          6 hours ago













          That did the trick. Thanks again!

          – user149408
          6 hours ago





          That did the trick. Thanks again!

          – user149408
          6 hours ago


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Geographic Information Systems Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f325914%2fquery-nodes-and-attributes-of-parent-ways%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

          Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

          Ciclooctatetraenă Vezi și | Bibliografie | Meniu de navigare637866text4148569-500570979m