Category: Transportation

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;

I grew up in the suburbs and it shows in early drawings

Vanceville 3 of 13

This panel has the light rail station next to an office complex that had the United Airlines headquarters and the office for “Steve Vance Enterprises – Western Region”.

I lived in suburbs until I was 22. The suburbs of Houston, of San Francisco, and of Chicago.

And from when I was 11 years old to about 15 years old I drew a municipality called “Vanceville” (and “Vancin” at one point) on 13 adjoining panels, each a standard size grade school poster. I started in fifth grade, within a couple of months of moving to Batavia, Illinois.

The first panel was drawn on the backside of a poster that displayed my study for class that counted cars on my street categorized by their manufacturer.

The suburban pattern of development was all I knew – and it really shows. I didn’t make it into the respective city centers that often, and when I did it was mostly by car. I think I drew the ultimate suburb of NIMBYs.

I don’t support this kind of development. Back then I thought I was designing the best city. I had no idea that what I was drawing wasn’t a sustainable way to develop places where people live.

You can see how four panels adjoin.

You can see how four panels adjoin.

I mean, just look at all the massive parking lots I drew. I seriously thought that that was how cities should be designed. I didn’t know that they paved over natural areas and caused dirty water to run off into the river I drew.

There are no multi-unit buildings. In fact, each single-family house is built on a huge lot. I gave each house a big garage, writing explicitly “2 + 1” and “2 + 1/2”.

I drew townhomes, a denser housing style than single-family, because I had a few friends who lived in them. This panel has my house in the lower-left corner.

Sidewalks are rare, but they become more prevalent in later design phases. You can forget bike lanes, but you may be lucky and find a bike path, again, in a later design phase. Those phases are also distinguished by smoother lines, fewer stray markings, and a lighter touch of the pencil.

People have to drive to the parks. Strip malls abound. Many of the shops are named for real businesses in Batavia.

Oh, wait, I drew in light rail tracks and stations. But I didn’t draw them because I knew or thought transit was a good thing. None of the places I lived had it. I drew the light rail because I loved trains.

Vanceville was so oriented to driving that some of the road lanes had “ATM” imprinted where a right-turn arrow would be, to signify that there was an upcoming turn off for a bank drive-through, with two lanes that had only ATMs. Even “Steve Vance Enterprises – Western Region” was connected to a 5-level car park.

There are just so many roads. I drew what appear to be interchanges between two “connector” roads within a residential neighborhood! That same panel seems to have as much asphalt as any other surface, be it developed or grass or water.

I’m not surprised this is the kind of city I drew.

If I still drew, the outcome would be completely different. It would probably look like a mix of Rotterdam, Madrid, and Houten.

What else do you see in the drawings? View the full album.

Vanceville 5 of 13

I drew these at a time when I was also obsessed with spy stories, which explains the CIA building.

Transportation infrastructure is for more than transportation’s sake

Transportation infrastructure should be designed for more than carrying people through places. It also needs to be about carrying people to places, because transportation is for moving people as much for commerce as it is for being social.

The Dutch consider “social safety” when designing and redesigning streets (they’re constantly upgrading streets, roads, and entire neighborhoods to standards that seem to be frequently updated).

Mark Waagenbuur posted a new video this week showing a new tunnel under Amsterdam Centraal, the main train station in Amsterdam, and he highlighted several of its social safety features.

The screen grab I embedded above – and posted on Twitter where it got a lot of shares and likes – shows an aspect that’s common across all cycling facilities in built-up areas: it’s wide enough to ride side by side with your friend, mother, or lover, with still enough room on your left for people to pass you in the same lane.

Another aspect of this tunnel is that it has sound-absorbing panels. Often tunnels have a disturbing echo that inhibit comfortable communication – my new home office has an echo and it makes it hard to have conversations on the phone here because I hear an annoying feedback. The communication is important to be able to hear people cycling with you, but also to hear what other people are doing.

The tunnel has a final feature that supports social safety: clear, wide, and open sight lines. Not just from end to end, but also to the sides. It’s hard to hide around the corner because the breadth of vision is so wide that you would see someone lurking in the corner.

For Chicagoans who use one of the many old tunnels under Lake Shore Drive connecting the “mainland” to the nation’s most popular trail along Lake Michigan, the feeling of claustrophobia and invisibility of what’s around the bend is too common. New tunnels, which I prefer to bridges because you go downhill first, should be a priority when the State of Illinois rebuilds Lake Shore Drive north of Grand Avenue in the next decade. This is what those tunnels look like; sometimes they have mirrors.

We can sell ads on the Lakefront Trail underpasses, but they're still shitty to walk through

People want more walkability and property developers can make it happen

Columbus Commons

The Columbus Commons in the tationty center. Photo by Brandon Bartoszek

This is my favorite part of Sam Schwartz’s book “Street Smart” so far. You’ll find it on page 117 following a discussion of Walk Score, a tool used mostly by realtors that measures “walkability” of any place in American cities based on the location and diversity of services, shops, and amenities nearby.

Every way you slice the data confirms that what all the polls say is true: people want more walkability.

Why, then, is there so little of it?

Why is there such a mismatch between the supply of, and the demand for, walkable neighborhoods?

Is it because, as one observer wrote, “Americans would like to live in places that don’t really exist”?

Do you live in a walkable place? Answer, and then check your Walk Score. I’m curious to know if they match.

Schwartz answers these questions with “not really”.

They want to live in places that do exist, but there are far too few of them.

Schwartz mentions that the housing prices in the most walkable cities – San Francisco, Washington, D.C., and New York City – are so expensive, but being walkable is what makes them the “coolest” cities.

Higher Walk Scores positively correlate with higher housing prices, “which is a problem”, Schwartz says.

[It’s] also an opportunity. By definition, only a few neighborhoods can be the coolest places to live. But that doesn’t mean we can’t make everywhere cooler.

Many pages later Schwartz describes how one city attempted to get property developers to make their proposed buildings or complexes more receptive to walking and biking (active transportation).

Columbus, Ohio, needed to lose some body weight. The city’s sprawling nature contributed to 59 percent of adults being obese or overweight, and 38 percent of children in the third grade (here’s the citation).

The Columbus Healthy Places program was formed in 2006 and implemented by the transportation and public health departments. Here’s one of the strategies they undertook to affect the built environment.

[The transportation and public health officials] persuaded the [buildings] department to grant them an opportunity to comment on all requests from developers to rezone a particular bit of land.

With that opportunity, Schwartz explained on page 133, they proposed that developments with shopping centers, bus stops, schools, park, libraries, drugstores, or grocery stores, within half a mile of residences, “include a suite of active transportation elements” like bike parking, connections to bike lanes and trails, and wider sidewalks.

It worked, he said. Before the program only seven percent of projects requesting a zoning change included active transportation elements, but after it was reviewed by the Columbus Healthy Places managers it “jumped” to 64 percent.

The new CTA budget

[I published an edited version of this post on Streetsblog Chicago.]

The Chicago Transit Authority gleefully tweeted that “fares [will] stay the same” and they’ll continue to “maintain/improve existing services”.

There are so many points to be made.

The medium on which they sent this message is irrelevant because Mayor Rahm Emanuel will parrot this at his press conference this afternoon at the Addison Blue Line station. He’ll say something that he’s holding fares down in order to support working families, yet he (because he runs the agency) can still get projects done, like renovating the Addison station to be accessible.

Fares should go up frequently, instead of making big jumps every 3-5 years. The price of things changes much more frequently and it’s what an agency providing such an important transportation service needs to do to be less constrained in making buses and trains run. And planning and funding for more buses and trains, under the strain of growing ridership. The CTA has the expertise to develop a long-term plan that sets out fare increases annually, removing the surprise, “Will this be the year?”

Fares should go up in increments smaller than quarters of a dollar! 0.25, 0.50, 0.75, and 1.00 are not the only choices available. Requiring riders who pay in cash – who become rarer each day – to pay with dollar bills and quarters isn’t a “convenience”, it’s annoying. It gives the CTA less flexibility in settling on the right price, and it means I can’t use these dimes and nickels that are piling on my nightstand. Quarters are for laundry.

“Fares will stay the same” is what Emanuel said two years ago when the price of passes was increased. Apparently causing people to spend more money to ride the train the same amount of times, if they have passes, is not a fare increase. This year none of the prices are changing. Hiking pass prices and keeping the base fare (single rides + transfers) the same can still hurt a low income rider: it puts the discounted fare further out of reach. Many Chicagoans are unable to put down $25 at a time for a ticket that would pay for all of their rides that week, so they pay per use, and end up paying more.

What holding the line on fare increases does is detrimental to riders and to CTA workers. It continues to defer fixing the problem of underfunded transit. The CTA, and its fellow transportation providers, Metra and Pace, are unable to pay for what people need them to do.

Additionally it’ll mean that, in order to keep costs in check, the CTA might freeze wages again. Because professionals providing Chicagoans with quality transportation services are the city’s and state’s piggy bank, and should sacrifice their wages due to “hard times”.

That’s the problem to be dealt with “soon”, but there’s an immediate problem, that Jon Hilkevitch explains in the Tribune:

The governor and lawmakers in Springfield have not agreed on a 2016 budget and the state still owes the CTA $221 million in capital-improvement funding that was expected in 2015, transit officials said.

But hey, “air quality” money is going to pay $18 million to widen a bunch of intersections so people can drive faster through them – until more people switch to driving through that fast intersection.