Skip to content


July 7, 2012

This blog has moved to For those with feed readers, the feed is now here.

Measuring Urban Mobility and Accessibility Using OpenTripPlanner Analyst

April 29, 2012

Thumbnail of the poster

I presented a poster (above) at the California Geographical Society, hosted by UC Davis, this weekend demonstrating some of the analytics possible with OpenTripPlanner Analyst. The full poster and maps are available here.

Elevators in OpenTripPlanner

April 1, 2012

I’ve been working on the OpenTripPlanner project quite a bit lately. One thing I did a month or so ago was to implement elevator support in the routing engine. I decomposed OSM nodes tagged highway=elevator by their constituent levels, and built edges between them to represent boarding, riding on, and alighting from an elevator. I was very impressed with the friendliness and responsiveness of the community.

One challenge was parsing OSM levels. They can come from multiple sources—level_map relations, level tags or layer tags. I wanted to support all of these, or any combination (on a single elevator). I originally did this by noting the source and adding 0, 1000 or 2000 to the level, but Andrew Byrd has made an OSMLevel class which handles this much more neatly. Level maps allow levels to be named, which is quite nice: “take elevator to garage” instead of “take elevator to -1.” So, for all OSM mappers out there, here is a quick guide to making routable elevators:

  • Tag your elevator nodes highway=elevator
  • Add access restrictions—wheelchair=yes and bicycle=yes tags
  • Use an OSM Level Map relation if there is any possibility that level names would not be clear.

EDIT: To clarify, the level annotations are always on the ways connecting to the elevators, not the elevator nodes themselves.

BART Shocker: First Inner-Core Infill Station Since Embarcadero

April 1, 2012

BART shocked Bay Area transit enthusiasts this morning with an announcement that it plans to build a new infill station, to serve all San Francisco lines, at Treasure Island.

“Treasure Island has long been underserved by transit,” said a BART employee, who is heading the project and acting as a liaison between the agencies involved. “The residents have long been frustrated that they live within a mile of rail rapid transit but cannot access it.”

The announcement has met with mixed results. While most residents of Treasure Island are ecstatic, East Bay commuters are not so pleased. One person, who lives in Castro Valley but commutes via BART daily to his job as a web designer in San Francisco’s Mission, complained that it will slow service. “BART travels at up to 80 mph in the Transbay Tube, crossing the Bay in just a few minutes. By adding a stop in the middle of that, you not only add the 20-30 seconds of time at the stop, but also the time it takes to accelerate and decelerate to that stop.”

Cyclists, however,  are happy about the project. The new eastern span of the Bay Bridge will sport a bike path, but the western span, not scheduled for replacement, does not. By allowing a quick connection between the Yerba Buena Island and San Francisco, a cyclist can ride to Yerba Buena, then catch BART for a quick ride into the city. Responding to the head of the Greater Golden Gate, Gough and Geary Boulevard Cyclists’ Association, a BART employee confirmed that the cycle link is a critical part of the project, and that the station will have new electronic bike lockers, as well as easy bicycle access from the bridge.

For anyone who hasn’t caught it yet, note date of issue.

And if you still haven’t caught it, read this article.

Happy April Fools’ Day!

Conditionals in the QGIS raster calculator

March 31, 2012

I needed to do some conditionals in the QGIS raster calculator, but it doesn’t support that—or at least doesn’t seem to. But it does support logical operators, with a result of either 0 or 1. For instance, here’s the script I wrote:

# Subtract them
((DavisQuad2012-02-25T16_00_00Z@1  -  DavisQuad2012-02-29T16_00_00Z@1)*
# Multiply by 1 if neither is 255 (NoData), 0 otherwise
(DavisQuad2012-02-25T16_00_00Z@1 != 255 AND DavisQuad2012-02-29T16_00_00Z@1 != 255))
# Subtract 32768 if either one was NoData, giving us -32768 for NoData.
(32768*(DavisQuad2012-02-25T16_00_00Z@1 = 255 OR DavisQuad2012-02-29T16_00_00Z@1 = 255))

Of course, you can’t actually put the comments in. But what it does is this: First, I subtract one raster from the other and multiply that by the logical operation that neither one contains NoData. That gives me the difference of the rasters, or 0 if either one contains NoData. Then I subtract 32768 multiplied by the inverse of the aforementioned logical operation, so any pixel with a NoData value in either of the original rasters is -32768 in the new one.

Note: I expanded on an idea from the GDAL script.

Conditional Labels in QGIS

March 3, 2012

I fairly commonly find myself in a situation where I would like to display one label for certain features and another for other features in the same layer. QGIS doesn’t have an official way to split labels up into categories, and until now I’d resorted to having two layers to render otherwise identical features. But, in the new, excellent expression based labeling from Nathan Woodrow, I realized one can use an SQL CASE statement. For instance, one time I need to use two types labels is when labeling roads in OpenStreetMap: I want to use the name tag, unless the feature has a ref tag defined (a name tag might be ‘Capital City Freeway’, while the ref tag would be ‘US 50’). Here’s how I solved that particular problem:

    ELSE name

For now, anyhow, you’ll need to be running the dev build of QGIS. Happy GISing!

More Basemaps in QGIS

February 2, 2012

One of the more popular posts on this blog has been my piece on adding basemaps to QGIS. While the OpenLayer plugin is great, one of the things that I find dissatisfying is that it requires reprojecting your data to match the EPSG:3857 basemap. I often work in State Plane, and I’d just as soon have my data stay in that projection, which will also minimize local distortion. Well, as it turns out, one can add tiled map services as GDAL raster layers, with all the benefits that entails (e.g. reprojection). What you need to do is create an XML file like the following (which is lifted almost verbatim from the GDAL website, specifically this file):

  <Service name="TMS">
    <!-- note: if you use this file verbatim, you *must* credit MapQuest and OpenStreetMap! -->

Change the ServerUrl to your Tiled Map Service server (this one is for MapQuest Open Tiles), then go into QGIS, Layer->Add Raster Layer and select the XML file.

A few caveats:

  • The OpenLayers plugin automatically adds the required attributions, at least for OSM. This can be nice or not—nice in that you don’t have to remember to add the attribution, not so nice in that you can’t choose where to place the attribution; it’s always in the lower-right.
  • Reprojecting layers with text may yield strange skewing and distortion.
  • You need to be sure that you use these services legally (as you did with OpenLayers plugin).

Have fun!

You can also convert tiles to GeoTIFF using gdal_translate, but I suspect most TMS providers would prefer you didn’t.