DEV Community

Cover image for How to get streets data using overpass Api
Daniel Torres
Daniel Torres

Posted on • Edited on

How to get streets data using overpass Api

I will show you a simple and fastly way to get the streets geometry and another information from OSM(open streeet maps), to do this, we will use Overpass turbo.

According the wiki of open street maps, Overpass turbo is is a web based data mining tool for OpenStreetMap that run runs any kind of Overpass API query and shows the results on an interactive map.

  1. Go to https://overpass-turbo.eu/.
  2. Select in Wizard
  3. Write highway=* and type:way
  4. Click on build and run query

Overpass turbo will create automatically the following query



[out:json][timeout:25];
(
    way["highway"]({{bbox}});
);
out body;
>;
out skel qt;


Enter fullscreen mode Exit fullscreen mode

And now you can run it and see all the streets geometries drawn on the map.

Cuautla streets on overpass turbo

Now, you can click on Export and click on GeoJSON download button.

Also, you can use the Query Wizard to find another type of places, the following query have been generated writing only the word "shop", and it returns the shops places.



[out:json][timeout:25];
(
    node["shop"]({{bbox}});
    way["shop"]({{bbox}});
    relation["shop"]({{bbox}});
);
out body;
>;
out skel qt;


Enter fullscreen mode Exit fullscreen mode

In addition, if you don't want to get only the streets selected on the web IU, you can replace {{bbox}} to your manually selected coordinates.



[out:json][timeout:25];
(
    way["highway"](
        18.806908708848084,
        -98.95872831344604,
        18.825777549841018,
        -98.94263505935669
    );
);
out body;
>;
out skel qt;


Enter fullscreen mode Exit fullscreen mode

Now, you can use another tool to show this information such as:

In case you need to obtain many more geometries, I recommend you to use a tool like osm2po.

For know more about this topic, please check the documentation:

Top comments (0)