This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

How To Retrieve All Highway By Certain Area With Relevant Values?

1

Hello Guys

I'm Newcomer Here. Recently I Have A Project Want To Use OSM With Overpass API. My Requirements Are:

  1. Retrieve All Streets (Highway) In A Specified Area. I Know This Is Possible By Kinds Of Ways. For Example Set Query Type As Boundary And Boundary Type = Admin Then Admin Level = N Or By Area With Area ID (Relation ID).

  2. I Need To Get A Lists Of All Highways With Way Type (For Example Motorway / Trunk / Primary / Secondary / Tertiar) And Availability Of Driving And Direction (For Example Is That Way A West-Eastward Way <horizontal> Or North-Southward Way <vertical>. My Question Is That Possible To List All Roads With All Required Values?

  3. I Also Need All Corresponding Nodes (Longitude / Latitude) In A Road (Highway). Does Overpass API Support To Get Nodes Relation Of A Highway? If I Need Only A Few Nodes In A Way Can I Set Parameter (Meter) As Wanted Distance Between Nodes (For Example Every N Meter For A Node)?

asked 12 Oct '20, 05:29

Bright's gravatar image

Bright
26112
accept rate: 0%

It sounds like you have half of it. Have you written any code a a basis?

(12 Oct '20, 16:25) DaveF

2 Answers:

2

Amended VIPINDAS K's answer so it runs. Pivot converts an area into an element. ^ and $ are part of regular expressions, defining the begining & ending of a string. In this example it searches for highways the are either 'trunk' or 'primary'. 'trunk_link' would not be returned,

{{geocodeArea:Malappuram}};
rel(pivot)->.District;
wr[highway~"^(trunk|primary)$"](area);
out geom; 
.District out geom;

{{style: 
way{
color: green;
fill-color: green;
text: name:en;
}
relation{
color: green;
fill-color: green;
text: name:en;
}
}}

answered 19 Oct '20, 13:27

DaveF's gravatar image

DaveF
3.3k8498133
accept rate: 16%

1

Sample code:
[out:json][timeout:25];
// fetch area “Malappuram" to search in
{{geocodeArea:Malappuram}}->.searchArea;
// gather results
(
//query part for: “boundary=Malappuram”;
wr["boundary"="administrative"]["name"="Malappuram"]["admin_level"="5"](area.searchArea);
way["highway"="trunk"](area.searchArea);
way["highway"="primary"](area.searchArea);
relation["highway"="trunk"](area.searchArea);
relation["highway"="primary"](area.searchArea);
//we can add more tags
way{
color: green;
fill-color: green;
text: name:en;
}
relation{
color: green;
fill-color: green;
text: name:en;
}
);
// print results
out body;
>;
out skel qt;

wizard helps to create codes.
Qgis helps to make customized map.

answered 19 Oct '20, 08:49

VIPINDAS%20K's gravatar image

VIPINDAS K
1257813
accept rate: 0%

edited 19 Oct '20, 08:59

Source code available on GitHub .