Search: “kml”

We found 28 results for your search.

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.

Converting shapefiles to GeoJSON, and other format conversions

To develop the Chicago Bike Map app, I had a problem I thought would be simple to solve: load train lines into a Leaflet-powered map. I had the train lines stored as a polyline shapefile but Leaflet can only read the GeoJSON format or a string of geographic coordinates representing lines.

I eventually found a solution (I can’t remember how) and I need to share it with you. The converter can do more than ESRI shapefiles to GeoJSON. It can reproject the data in the conversion. It can convert from several formats to several other formats.

The site is called MyGeodata Converter. You upload a ZIP file of geographic files – .shp and its companion files (.prj, .dbf, .shx), .kml, and .gpx. Let’s take the Chicago Transit Authority train lines shapefile straight from the City of Chicago’s open data portal. It downloads as a zipped collection of a shapefile and its buddies and we can take this file straight to the Converter and upload it. The Converter will unzip it and read the data; it will even identify the projection system (for Chicago-based geographic data, its common to use NAD83 Illinois StatePlane East FIPS 1201 Feet (SRID 102671, the same as SRID 3435).

The Converter will convert to one of the following formats, with same or new projection; accepts SQL statements to extract a subset of data:

  • ESRI shapefile
  • GML
  • KML, KMZ
  • GeoJSON
  • Microstation DGN
  • MapInfo File
  • GPX
  • CSV

BikeLock app based on dataset I opened up

Bike parking at Daley Plaza, downtown Chicago. 

It’s really cool to see work you did “go places”. A friend of mine who works at Groupon just linked me to an iOS app called BikeLock that finds bike racks near you on iPhones, iPads, and iPod touches. It’s based on bike rack location data in the City of Chicago’s Data Portal. (The data on there is old, while the data in the public API I built is real time.)

Download it from the iTunes Store for 99 cents. The developer is Mike Jahn, another Groupon staffer. You can get the same information for free, though, on my mostly mobile-friendly Can I bring my bike on Metra? web app, and a website I made for the Chicago Department of Transportation (CDOT).

A screenshot of the Can I bring my bike on Metra? bike rack finder website. 

That data comes straight from the Bike Parking Web Application I started developing in 2008 soon after I started working in the Chicago Bicycle Program. It was good that my supervisor had the same perspectives I did about open and transparent data and work. But it didn’t start like that; here’s the full story:

My first job at the Bicycle Parking Program was to deal with abandoned bikes, get them off the street. I was taught the existing method of keeping track of my work, but I used my programming skills (in PHP, MySQL, and with the Google Maps API) to develop a web application that tracked it faster and mapped out the abandoned bikes I had to visit and tag with a notice. I was using this for a few days or few weeks and then show my boss. His reaction was something like, “Great! Now make one for bike racks!”

Why? Well, let’s take this quote from Judy Baar Topinka, Illinois comptroller, speaking Tuesday about her office’s new website, The Ledger, which lists the state’s unpaid bills among other financial data.

“The object of the exercise is to make everything that we know of in the comptroller’s office public. If we know it, you’ll know it.” WBEZ

I made one for bike racks. I created two environments, one for private administration at the office (“Bike Parking Web Application”) and one for the public (“public interface”). A later feature I added to the public interface was the Advanced Search. This allows you to filter by Ward, Community Area, and Status. You can then choose your sorting method. A map will appear above the results. You can download the results as either an XLS file, and XLS file that’s designed to be imported in GIS programs (like QGIS), or a KML file.

I’m aware of just one other app that uses this data set: MassUp.us. I don’t know if MassUp uses the real-time API that my Metra bike rack finder uses.

Logan Square McDonald’s crash map

This is part of a series of articles on the issue of lifting the pedestrian street designation on a part of Milwaukee Avenue in Logan Square so that the McDonald’s franchise owner can demolish the building, build a new building, and build a double order point (“tandem”) drive through. Read the first post

At the hearing on December 13, 2011, Alderman Reilly asked if there was evidence of injuries or crashes due to the drive through. No one brought this data to the hearing. I cannot directly attribute the crashes to the existence of the drive through (unless I had the original crash reports), the drive through probably generates traffic that would not be there without the drive through, and it causes people to have to turn across a lane of traffic, either to enter the driveway on Milwaukee, or when exiting the driveway onto Sawyer, or when turning onto Milwaukee from Sawyer. I am looking for studies that research the impacts of drive throughs at fast food restaurants and pharmacies.

37 people were involved in 13 crashes within 100 feet of the center of the McDonald’s driveway from 2007-2010. Seven people were injured, one was a pedestrian. Double the search radius to 200 feet and we see 87 people involved in 35 crashes. Now, four pedestrians and cyclist were injured in addition to the 10 drivers and passengers injured.

Download the data in this map. View a larger map

This was my testimony at the zoning committee hearing (this may not be verbatim, but it’s really close):

Hello, my name is Steven Vance. I work as a consultant and writer on sustainable transportation advocacy and planning projects. The text amendment to modify the pedestrian street designation may negatively impact the continuity and safety in traffic of all modes along Milwaukee Avenue, which happens to be the city’s most popular bike route.

I ask that McDonald’s provide a traffic impact study before this matter is discussed further.

Lynn, a Logan Square neighbor, describes more of what happened at the hearing, as well as the next step at the Zoning Board of Appeals.

Here’s a map of all pedestrian streets in Chicago. View larger map.

Download a KML file of all the pedestrian streets. Download the shapefile of all the pedestrian streets. Thank you to Azad Amir-Ghassemi and Bill Vassilakis for their help in digitizing the table of pedestrian streets in the zoning code.

Update January 10, 2013

Driving danger

Crash data from the Illinois Department of Transportation show several crashes along Milwaukee Avenue from 2005 to 2011. If this location hadn’t been removed from the P-Street ordinance, McDonald’s would have been required to install both the drive-thru’s entrance and exit on Sawyer, where there is markedly less traffic than on Milwaukee (or not build them at all). This project has not only allowed a documented hazard to persist (despite the P-Street designation), but perhaps to be worsened.

From 2005-2011, there were 3 bike-automobile crashes and 5 pedestrian-automobile crashes within 200 feet of the drive-thru entrance, which includes the intersection of Sawyer and Milwaukee (where many people will drive back onto Milwaukee from the drive-thru exit). There were 82 car-car crashes in the same period. At a nearby intersection, Milwaukee/Dawson, an intersection with a similar retail makeup and traffic count, shows about half the number of crashes.