2

I am trying to get a road entire coordinates using this code

<osm-script output="json">
  <id-query ref="32809713" type="way"/>
  <!-- added by auto repair -->
  <union>
    <item/>
    <recurse type="down"/>
  </union>
  <!-- end of auto repair -->
  <print/>
</osm-script>

The problem with this code is, it only takes part of a road, not entire road. What is wrong?

  • Are you sure your whole road has the same ID? – BradHards Dec 13 '14 at 5:18
  • The road is I5, shouldn't the entire road have same Id? you can run this in overpass-turbo.eu and check – Muhammad Umar Dec 13 '14 at 5:24
  • @BradHards you are right, for I5 There are diff osm ids, what should i do to get complete I5? – Muhammad Umar Dec 13 '14 at 5:54
  • What is a complete road in your case? All ways of a road having the same name? Or the same ref? Something else? – scai Dec 13 '14 at 10:03
1

since the road named I5 is segmented in OSM, you have to query the ref value instead of the id of a segment:

/*
This has been generated by the overpass-turbo wizard.
The original search was:
“ref="I 5"”
*/
[out:json][timeout:25];
// gather results
(
  // query part for: “ref="I 5"”
  node["ref"="I 5"];
  way["ref"="I 5"];
  relation["ref"="I 5"];
);
// print results
out body;
>;
out skel qt;

You will get some data from Europe as well, which you can filter out by setting a bbox or area selection.

If your road has no reference number, but a name, you can search for that too:

/*
This has been generated by the overpass-turbo wizard.
The original search was:
“name="Eastshore Freeway"”
*/
[out:json][timeout:25];
// gather results
(
  // query part for: “name="Eastshore Freeway"”
  node["name"="Eastshore Freeway"];
  way["name"="Eastshore Freeway"];
  relation["name"="Eastshore Freeway"];
);
// print results
out body;
>;
out skel qt;
  • What about some roads that are not segmented. Let's say a simple highway – Muhammad Umar Dec 13 '14 at 6:02
  • You can never be sure about the non-segmentation. Just having two lanes mapped separately spoils the id-solution. – AndreJ Dec 13 '14 at 6:06
  • I am trying to get road name using reverse geo coding, and one name i get is Eastshore Freeway. Its not working with your code, if i replace I5. Reverse geocding using nominatim.openstreetmap.org – Muhammad Umar Dec 13 '14 at 7:29
  • If you know the name of the road then just query for the name, not the ID. The name will be unique among all segments, the ID won't. – scai Dec 13 '14 at 10:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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