Tag: Overpass Turbo

How to map where I traveled when I went to Gorinchem, NL

On Monday, December 4, 2023, I wanted to ride a line in the Netherlands that I hadn’t yet, which is called the “MerwedeLingelijn” and goes between Dordrecht and Geldermalsen. In the NS journey planner database it’s called “Stoptrein” which distinguishes it from “Sprinter” and “Intercity”. Those names distinguish the service types on the Dutch railway network. (This particular Stoptrein is also a diesel-electric trainset.)

From Rotterdam, where I was staying, it would require at least one transfer to get to Gorinchem. But I wanted to stop in Utrecht to say hi to a friend during his work break – this meant there would be two transfers.

Here’s the itinerary I traveled on Monday

  • Rotterdam Centraal to Utrecht Centraal via Gouda, Intercity (half-hourly service) – 55 km
  • Utrecht Centraal to Geldermalsen, Sprinter (10-20 minute service) – 26 km
  • Geldermalsen to Gorinchem, Stoptrein (half-hourly service) – 27 km
  • [lunch and walk in Gorinchem, distance not recorded]
  • Gorinchem to Dordrecht, Stoptrein (quarter-hourly service) – 24 km
  • Dordrecht to Rotterdam, Waterbus (hourly service) – 21 km

How I drew the map

I wasn’t about to draw the routes by hand (although I did record the Waterbus ride on Strava as a “sail”) so I grabbed the data from OpenStreetMap.

If you want data in bulk from OpenStreetMap a common way to get it is from the HotOSM export tool. But I wanted specific transit routes, for which I could find the “way” IDs and export only those. For that I used Overpass Turbo and wrote the following query:

[out:json][timeout:25];
// gather results
rel(id:324888,13060594,5301520,2785504);
way(r);
// print results
out geom;

Notes

Frequencies refer to the pattern in the hour I used the service. The itinerary doesn’t include a Rotterdam Metro ride or the roundtrip bike ride from the Schiebroek neighborhood to Rotterdam Centraal).

Starting on December 10, the NS (Dutch national railway operator) is adding over 1,800 train services each week.

Traffic calming around Chicago schools and parks

Reducing the number and speed of automobiles near schools and parks is a proven way to reduce the number of traffic crashes involving children, part of a practice known as “traffic calming”. In Chicago a key way to do that has been to “cul-de-sac” (which I’m using as a verb) a street to prevent through traffic (reducing the number) and preventing speeding (reducing the speed).

My study of this was inspired by the above tweet, where the person is accurate when they say, “it works with any street”. Indeed: Full access to the school or park and to every property on the block is maintained, but drivers are not able to go through while pedestrians and bicyclists can (another practice called “modal filtering“).

My favorite example in Chicago is Hadiya Pendleton Park, at 4345 S Calumet Ave. This project created two mid-block cul-de-sacs and a park in the middle of a block, using vacant city-owned land on both sides. Creating new open space is a common corresponding outcome of the cul-de-sac application, which is what occurred at Funston Elementary School (see the before and after aerial photos below).

two black and white aerial photos taken of Funston Elementary School, one in 1998 showing a 4-way intersection of McLean Ave and Central Park Ave and one in 2003 showing a cul-de-sac on McLean Ave west of the school and landscaped area between the cul-de-sac and the three-way intersection of McLean and Central Park.

Through Twitter I solicited additional examples of where the city has created traffic calming near schools and parks using cul-de-sacs. Examples were submitted by RolandEmily (who mentioned Funston), Matt, Steven, and another tweeter.

Using OpenStreetMap, Overpass Query Language, and Overpass Turbo, we can find all of the schools and parks that are within a specified distance of a cul-de-sac. It turns out there are 153 schools and parks in Chicago that are within 150 feet of a cul-de-sac. (This considers only schools, parks, and cul-de-sacs, tagged as “turning circles”, currently mapped in OSM, and I have not verified each of the 153 instances.)

Map showing parks, schools, and adjacent cul-de-sacs, the results of the Overpass Turbo query.
Map showing parks, schools, and adjacent cul-de-sacs, the results of the Overpass Turbo query. An inset map shows a zoomed in portion of the map to illustrate the different types of features captured in the Overpass Turbo query (specifically it shows Graham Elementary School and McInerney Park).

The query below will find all of the cul-de-sacs (mapped as “turning circles” in OSM parlance) that are in Chicago, all of the schools and parks in Chicago, and then all of the two categories of features that are within 45 meters of each other. (Run the query and show the map, which will always grab the latest data.)

/*
example from OSM wiki: https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_API_by_Example
*/
[out:json][timeout:25];
// fetch area “Chicago” to search in
{{geocodeArea:Chicago}}->.searchArea;

// get cul-de-sacs
(
  node["highway"="turning_circle"](area.searchArea);
)->.turning_circles;

// get parks and schools
(
  way["amenity"="school"](area.searchArea);
  way["leisure"="park"](area.searchArea);
)->.schoolsParks;

// find parks and schools near cul-de-sacs
(
  way.schoolsParks(around.turning_circles:45);
)->.matchingSchoolsParks;

// find cul-de-sacs near parks and schools
(
  node.turning_circles(around.schoolsParks:45);
)->.matchingTurningCircles;

// output results to the map
(.matchingSchoolsParks; .matchingTurningCircles;);
out geom;

Read the three other blog posts I’ve written about using Overpass Turbo to quickly sift through and extract desired mapping data from OpenStreetMap.

How to extract highways and subway lines from OpenStreetMap as a shapefile

It’s possible to use Overpass Turbo to extract any object from the OpenStreetMap “planet” and convert it from a GeoJSON or KML file to a shapefile for manipulation and analysis in GIS.

Say you want the subway lines for Mexico City, and you can’t find a GTFS file that you could convert to shapefile, and you can’t find the right files on Sistema de Transporte Colectivo’s website (I didn’t look for it).

Here’s how to extract the subway lines that are shown in OpenStreetMap and save them as a GIS shapefile.

This is my second tutorial to describe using Overpass Turbo. The first extracted places of worship in Cook County. I’ve also used Overpass Turbo to extract a map of campgrounds

Extract free and open source data from OpenStreetMap

  1. Open the Overpass Turbo website and, on the map, search for the city from which you want to extract data. (The Overpass query will be generated in such a way that it’ll only search for data in the current map view.)
  2. Click the “Wizard” button in the top toolbar. (Alternatively you can copy the code below and paste it into the text area on the website and click the “Run” button.)
  3. In the Wizard dialog box, type in “railway=subway” in order to find metro, subway, or rapid transit lines. (If you want to download interstate highways, or what they call motorways in the UK, use “highway=motorway“.) Then click the “build and run query” button.
  4. In a few seconds you’ll see lines and dots (representing the metro or subway stations) on the map, and a new query in the text area. Notice that the query has looked for three kinds of objects: node (points/stations), way (the subway tracks), relation (the subway routes).
  5. If you don’t want a particular kind of object, then delete its line from the query and click the “Run” button. (You probably don’t want relation if you’re just needing GIS data for mapping purposes, and because routes are not always well-defined by OpenStreetMap contributors.)
  6. Download the data by clicking the “Export” button. Choose from one of the first three options (GeoJSON, GPX, KML). If you’re going to use a desktop GIS software, or place this data in a web map (like Leaflet), then choose GeoJSON. Now, depending on what browser you’re using, a couple things could happen after you click on GeoJSON. If you’re using Chrome then clicking it will download a file. If you’re using Safari then clicking it will open a new tab and put the GeoJSON text in there. Copy and paste this text into TextEdit and save the file as “mexico_city_subway.geojson”.

Overpass Turbo screenshot 1 of 2

Screenshot 1: After searching for the city for which you want to extract data (Mexico City in this case), click the “Wizard” button and type “railway=subway” and click run.

Overpass Turbo screenshot 2

Screenshot 2: After building and running the query from the Wizard you’ll see subway lines and stations.

Overpass Turbo screenshot 3

Screenshot 3: Click the Export button and click GeoJSON. In Chrome, a file will download. In Safari, a new tab with the GeoJSON text will open (copy and paste this into TextEdit and save it as “mexico_city_subway.geojson”).

Convert the free and open source data into a shapefile

  1. After you’ve downloaded (via Chrome) or re-saved (Safari) a GeoJSON file of subway data from OpenStreetMap, open QGIS, the free and open source GIS desktop application for Linux, Windows, and Mac.
  2. In QGIS, add the GeoJSON file to the table of contents by either dragging the file in from the Finder (Mac) or Explorer (Windows), or by clicking File>Open and browsing and selecting the file.
  3. Convert it to GeoJSON by right-clicking on the layer in the table of contents and clicking “Save As…”
  4. In the “Save As…” dialog box choose “ESRI Shapefile” from the dropdown menu. Then click “Browse” to find a place to save this file, check “Add saved file to map”, and click the “OK” button.
  5. A new layer will appear in your table of contents. In the map this new layer will be layered directly above your GeoJSON data.

Overpass Turbo screenshot 4

Screenshot 4: The GeoJSON file exported from Overpass Turbo has now been loaded into the QGIS table of contents.

Overpass Turbo screenshot 5

Screenshot 5: In QGIS, right-click the layer, select “Save As…” and set the dialog box to have these settings before clicking OK.

Query for finding subways in your current Overpass Turbo map view

/*
This has been generated by the overpass-turbo wizard.
The original search was:
“railway=subway”
*/
[out:json][timeout:25];
// gather results
(
// query part for: “railway=subway”
node["railway"="subway"]({{bbox}});
way["railway"="subway"]({{bbox}});
relation["railway"="subway"]({{bbox}});
/*relation is for "routes", which are not always
well-defined, so I would ignore it*/
);
// print results
out body;
>;
out skel qt;

How to make a map of places of worship in Cook County using OpenStreetMap data

The screenshot shows the configuration you need to find and download places of worship in Cook County, Illinois, using the Overpass Turbo website.

If you’re looking to make a map of churches, mosques, synagogues and other places of worship, you’ll need data.

  • The Yellow Pages won’t help because you can’t download that.
  • And Google Maps doesn’t let you have a slice of their database, either.
  • There’s no open data* for this because churches don’t pay taxes, don’t have business licenses, and aren’t required to register in any way

This where OpenStreetMap (OSM) comes in. It’s a virtual planet that anyone can edit and anyone can have for free.

First we need to figure out what tag people use to identify these places. Sometimes on OSM there are multiple tags that identify the same kind of place. You should prefer the one that’s either more accurate (and mentioned as such in the wiki) or widespread.

The OSM taginfo website says that editors have added over 1.2 million places of worship to the planet using amenity=place_of_worship.

Now that we know which tag to look for, we need an app that will help us get those places, but only within our desired boundary. Open up Overpass Turbo, which is a website that helps construct calls to the Overpass API, which is one way to find and download data from OSM.

Tutorial

In the default Overpass Turbo query, there’s probably a tag in brackets that says [amenity=drinking_fountain]. Change that to say [amenity=place_of_worship] (without the quotes). Now change the viewport of the map to show only the area in which you want Overpass Turbo to look for these places of worship. In the query this argument is listed as ({{bbox}}).

The map has a search bar to find boundaries (cities, counties, principalities, neighborhoods, etc.) so type in “Cook County” and press Enter. The Cook County in Illinois, United States of America, will probably appear first. Select that one and the map will zoom to show the whole county in the viewport.

Now that we’ve set the tag to [amenity=place_of_worship] and moved the map to show Cook County we can click “Run”. In a few seconds you’ll see a circle over each place of worship.

It’s now simple to download: Click on the “Export” button and click “KML” to be able to load the data into Google Earth, “GeoJSON” to load it into a GIS app like QGIS, or “save GeoJSON to gist” to create an instant map within GitHub.

*You could probably get creative and ask a municipality for a list of certificates of occupancy or building permits that had marked “religious assembly” as the zoning use for the property.

Compiling and mapping Chicago-area campgrounds

I’m adding Chicago-area campgrounds to the Chicago Bike Guide to entice new users and to espouse the enjoyment of medium-distance bike camping (which I’ve now done officially once, earlier this year).

<The Chicago Bike Guide is available for Android and iOS.>

I’m taking a systematic approach to finding all the publicly-owned campgrounds in the area by looking at primary sources.

First, though, I’ve used Overpass Turbo to create a list of all existing campgrounds in OpenStreetMap. You can see a gist of these places.

Camp sites at Greene Valley forest preserve I mapped.

Camp sites at Greene Valley forest preserve I mapped.

The next method is to find out which campgrounds are operated by the county forest preserves, which are usually well-documented on their respective websites. Then I will look at state parks in Illinois, Indiana, and Wisconsin, operated by states’ respective Departments of Natural Resources (DNR). Next I will look at national parks and finally commercial campgrounds.

The app will display campground information such as alcohol rules, if cabins or lodging is available, and how you can get there (which trails or train lines).

I’ve so far mapped the campgrounds in two ways, as nodes and as areas. At the Greene Valley forest preserve in DuPage County, for example, I’ve mapped the 11 individual camp sites (see map), but at Blackwell forest preserve in the same county, I’ve mapped the area as the camp site (see map).

Blackwell has over 50 sites in a discrete area and it’s more efficient to map them as a single node, while Greene Valley had far fewer sites but scattered over a couple areas.

Cross-posted to Web Map Academy.