I'm trying to get the road network in an area focusing on the smaller (1-2 lane ) roads using osm and node. Using the OSM overpass api, I used the following query:
const roadsOverpassQuery = `
[out:json];
(way[lanes=1](${bbox}); way[lanes=2](${bbox}); );
out;
`;
I was able to get many of the roads within a bounding box. I noticed that these roads when converted to geojson objects have nodes
{
"_id": {
"$oid": "643c3fd883215e96ece3be0a"
{,
"type": "way",
"id": 5053100,
"nodes": [
33979706,
33979705
],
"tags": {
"adot_name": "Tucson-Benson Highway",
"bicycle": "yes",
"hgv": "designated",
"highway": "motorway",
"lanes": "2",
"maxspeed": "75 mph",
"old_ref": "US 80 (old AZ 86)",
"oneway": "yes",
"ref": "I 10"
}
I passed these into the overpass api using
const overpassQuery = `
[out:json];
(
${nodeIds.map(id => `node(${id})`).join(';')};
);
out;
`;
These as geojson look like:
"features": [
{
"type": "Feature",
"id": "node/33979705",
"properties": {
"highway": "motorway_junction",
"ref": "292",
"id": "node/33979705"
},
"geometry": {
"type": "Point",
"coordinates": [
-110.5123291,
31.9766748
]
}
},
{
"type": "Feature",
"id": "node/33979706",
"properties": {
"id": "node/33979706"
},
"geometry": {
"type": "Point",
"coordinates": [
-110.5141282,
31.9773252
]
}
}
]
I notice that the geometry type is point. In other places I've seen roads made up of Linestrings:
{
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [
[-122.483696, 37.833818],
[-122.483482, 37.833174],
[-122.483396, 37.8327],
[-122.483568, 37.832056],
[-122.48404, 37.831141],
[-122.48404, 37.830497],
[-122.483482, 37.82992],
[-122.483568, 37.829548],
[-122.48507, 37.828802],
[-122.4861, 37.828387],
[-122.486958, 37.828138],
[-122.487001, 37.827885]
]
},
"properties": {
"name": "Example LineString"
}
}
How do I get the Linestring coordinates for the roads of interest?
[out:json]; way(5053100); convert item ::=::,::geom=geom(),_osm_type=type(); out geom;
Here's an example. Does that address your question? If so, I can write it up as an answer — if not, what am I missing?