Skip to content
This repository has been archived by the owner on Jun 28, 2018. It is now read-only.

Code examples and tutorial on getting data out of OpenStreetMap

Notifications You must be signed in to change notification settings

datadesk/overpass-turbo-tutorial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 

Repository files navigation

overpass-turbo-turorial

OpenStreetMap has a ton of data...on some things. It's a good place to get "base map" data like roads, rivers or other features. Addresses, businesses and other amenties may not be complete. But you can improve the data to make them complete!

First, let's take a look at the interface.

Buttons:

  • Run fires off the code in the window. Result appears on the map to the right.
  • Share gives you a link of the current query to..umm...share
  • Export makes a sandwich. No! It allows you to download the result in GeoJSON, GPX, KML or XML.
  • Wizard helps your construct queries
  • Save keeps your query for the future
  • Load brings up any saved queries
  • Settings pick a new background, language and spin cycle
  • Help not as effective as 911

You can write a query to get anything in OpenStreetMap. The only real limit seems to be size and your ImAgInAtIoN. So, trying to download the nation's freeway system may not be possible. But you could for Los Angeles County.

A good start is defining what you want in terms of OSM's tags.

Get all drinking fountains in Griffith Park

For instance, to download all the water fountains in Griffith Park you'll need to use OSM's tag amenity=drinking_watter. A quick Google search of search of the OSM Wiki will help you.

The easiest thing to do is to drop amenity=drinking_watter into Overpass turbo's "Wizard" if the map is showing Griffith Park.

drinkingwater

Overpass turbo

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

Get all the freeways

River homeless map

One common problem is to create a line map of just the freeways for reference (and nothing else). The Census provides a file for primary roads, but it excludes highways like the 101.

screen shot 2016-08-23 at 1 39 55 pm Census primary roads

It takes a combination of secondary and primary roads to get all the "freeways" like the 101 and the 134.

screen shot 2016-08-23 at 1 41 05 pm

But the census file also includes roads like Santa Monica Boulevard which we wouldn't want to include.

The OSM tagging for freeways (and any roads or paths) is to use highway=

Freeways fit into highway=motorway

screen shot 2016-08-23 at 1 58 47 pm

Overpass turbo

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

Download everything!

You can leave the attributes out and just get anything that's a node, way or relation.

Overpass turbo

screen shot 2016-08-23 at 2 16 58 pm

Define your own bounds

By default the bounding box defaults to the boundaries of the map. {{box}}

But you can specify your own boundaries using this order (lat_min, lon_min, lat_max, lon_max)

Overpass turbo

/*
This has been generated by the overpass-turbo wizard.
The original search was:
“"Drinking Water"”
*/
[out:json][timeout:25];
// gather results
(
  // query part for: “"Drinking Water"”
  node(35.4808,-118.4676,35.6666,-118.2051);
  way(35.4808,-118.4676,35.6666,-118.2051);
  relation(35.4808,-118.4676,35.6666,-118.2051);
);
// print results
out body;
>;
out skel qt;

Drinking fountains of yore in Griffith Park (before Anthony added some more)

screen_shot_2016-08-23_at_1_23_35_pm

You can search for data in the past by adding a date next to the timeout. You'll also need to change out body; to out meta;

Overpass turbo

/*
This has been generated by the overpass-turbo wizard.
The original search was:
“amenity=drinking_water”
*/
[out:json][timeout:25][date:"2016-08-21T00:00:00Z"];
// gather results
(
  // query part for: “amenity=drinking_water”
  node["amenity"="drinking_water"]({{bbox}});
  way["amenity"="drinking_water"]({{bbox}});
  relation["amenity"="drinking_water"]({{bbox}});
);
// print results
out meta;
>;
out skel qt;

Request too big?

You can download straight out of Overpass turbo if you're request is too big.

More examples

http://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_API_by_Example

About

Code examples and tutorial on getting data out of OpenStreetMap

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published