Some Bits: Nelson's log

17 posts about openstreetmap

OpenStreetMap: temporary road closures

I made another complex OSM edit, marking a road closed for construction. Details of the closure are on page 2 here. Nevada Street Bridge (OSM) is closed to cars until Nov 1 2024 or so.

As with all things OSM, how to actually do something this complex is not clear and there are many ways in the free-form schema.

First as a practical matter, serious mapping apps aren’t just relying on OSM for road information. They are pulling road closures from other sources. Google Maps has the closure and is routing around it. The fanciest OSM routing app I know, OsmAnd, does not (yet) know about the closure.

I chose to do the edit the aggressive way. I changed the way from highway=tertiary to highway=construction and construction=tertiary. Ordinarily this is the kind of thing you’d do for a new road being built. But I think it will have the effect I want, I just have to remember to go back and edit it again in November when the road is open. As a bonus I was able to tag it foot=yes which captures that you can still walk through the area, just not drive.

The other option was to just add a Conditional Restriction to the way, as seen here or here. A tag like motor_vehicle:conditional=no @ (2018 May 22-2018 Oct 7). I didn’t do this. One reason is this tag seems mostly useful for tagging permanent things with relative timestamps, like “road closed to cars 8am to 10am evey weekday”. I was also worried that most OSM users don’t process such a complex tag and will default to showing the road open. And finally that date range syntax I pulled as an example is really hinky. The ISO 8601 syntax would be 2018-05-22/2018-10-07 but near as I can tell OSM does not have an ironclad standard to use ISO 8601 for dates everywhere. I haven’t seen ISO 8601 slash syntax for time intervals in any of the docs.

End of the day I just want it to look right on the map. This is good enough.

Update: a day later OsmAnd routes around the closure, I think because it picked up my edit. Both Valhalla and OSRM on the OSM website still show a route through the closed road. I have no idea if they have updated data or not, but I’m guessing not. Update 2: it took most of a week but now the routing on the OSM website bypasses the closed bridge.

City reference map

From page 2 of the newsletter. The blue area is closed.

Don’t route me through a river (OSM and fords)

Yesterday Google Maps tried to get me killed, sending me on a route near Grass Valley, CA that had me driving through this flowing creek. OpenStreetMap based maps want me to go that way too.

I’m not the only one Google routes this way. And the ford claims victims. On March 1 2024 someone had to be rescued from this same creek coming from the other side. Back in 2012 too.

Here’s a link to Google Maps routing for the area. And openstreetmap.org’s website. Both show you going over Sharmiden Way which is a ford. During the rainy season the crossing at Wolf Creek is not safe. It’s never really a good route, even if the road is dry it’s still unpaved and awkward. You really would rather go south another half mile to Brewer Road. Which Google offers but only as an alternative.

Nothing in Google’s data seems to indicate they are aware it’s a ford, not a normal road.

Tagging fords in OpenStreetMap

I can’t fix Google. But I can edit OpenStreetMap! Here’s the area in question; the ford is where Sharmiden Way intersects Brewer Road. When I started on this there was no indication the road was unusual at all. So I went and added a notation of the ford. True to open schema form, OSM has several ways to tag fords.

The simple way is to add a single node on the way and tag it ford=yes. I made that edit a couple of weeks ago. The result in the OSM default web map is a tiny blue icon indicating the ford. Not great but at least I can verify the data is on the map.

I made a new edit today, the second fancier way. Which is to create a whole separate way for the ford and tag the whole way with ford=yes. Actually the iD editor wanted to put ford=ford in there but I overrode it because from what I can see ford=yes is more common.

I left both node and way ford annotations in place. Now OpenStreetMap knows about the ford. Will software use that to avoid danger?

OSM routing through fords

Neither of the routing algorithms openstreetmap.org’s website seem to avoid fords. Both Valhalla and OSRM on happily send cars plunging through the swift-flowing creek.

The Android app OsmAnd does have an option (off by default) to avoid fords in routes. And it successfully generates the safer route.

OsmAnd is powerful but it’s really not a user-friendly app. Finding the option to turn off routing through fords it’s like four menu items deep. The map download process is slow and awkward. And the Google Play version of the app wants you to pay for updated maps, otherwise the data is weeks old (which makes testing awkward). The trick for that is to get the F-Droid version which has most of the Pro options unlocked at no cost. Even then you still have to find the extra “Updates” tab to get fresh data, it’s not in the ordinary downloads.

Now I’m curious if any maps avoid this ford. Google Maps can’t, it doesn’t even know the ford is there. OSM based apps now know but only if they’re using fresh data.

I tried Scout Maps, the only OSM app I could find for AAOS, but it still routes me through the ford. They say they use OSM data but there’s no way for me to see how fresh the data is. The app has a way to tell it to avoid unpaved roads but no explicit way to avoid fords.

I got a nice personal message on Mastodon about GraphHopper, a routing service. The default route uses the ford but at least shows a warning about it. And you can customize its algorithm to avoid the ford.

OSM data in QGIS for simple print maps

I’ve been wanting to make some print maps in QGIS using OSM data for roads. There’s a bunch of ways to do this from simple to complex, but I think I found a way that works for me.

  • Start with an OSM extract in .osm.pbf format. These are produced daily for countries and regions and are manageable size.
  • Import it as a layer into QGIS, which has native support for .osm.pbf format. However it will be slow because it is not indexed.
  • Convert to GeoPackage in QGIS, with the defaults. All the property names, etc will be carried over and you’ll get a spatial index.
  • Use the new GeoPackage layer in your maps, you can delete the old OSM PBF layer entirely.

The main drawback is you’re dealing with OSM schema. Ie, drawing roads involves deciphering all the possible tag values for “highway”. It’d be nice to use some processed dataset converted to a simpler schema but I don’t know of an easy way to get a free one.

If you don’t care about licensing, MapTiler has some very nice OSM Planet tiles you can easily import in new versions of QGIS using their MapTiler QGIS Plugin. You can import these as raster maps or vectors. The vectors come with some schema translation and styling so you start with an OSM-looking map right there in QGIS and then modify it as you wish. The downside is I’m not sure you can use this data for, say, a print project without a licensing agreement from MapTiler. Also I didn’t see any easy way to control the level of detail so if you want to override their idea of feature selection at a zoom level you may be out of luck.

Working on a regional map for Papua New Guinea

A friend of mine is an anthropologist expert on Papua New Guinea, particularly Enga Province. There are precious few good maps of PNG (famously) so he’s asked me if I could help prepare a schematic map of the region he can use in a publication. If it goes well maybe we can submit the map to Wikipedia or something too.

For inspiration I pulled a bunch of sample maps from Bing / Google / Openstreetmap, also from the Rumsey archive and various online sources. I particularly liked this map (from this paper) and the SIL map. Openstreetmap’s default map style isn’t bad, either, and I’m encouraged by how much data OSM has. (I don’t need detailed roads, just a single image at large scale.)

It’s interesting how some of the custom maps emphasize roads, others emphasize rivers. Really terrain is a pretty key element of understanding the area too, it’s quite rugged, but most of the maps I see are constrained by print restrictions to not including terrain.

I’m also starting to read up on Wikipedia’s guidance for maps. WikiProject Maps is a good place to start. I really like their exemplar of The Big Island of Hawai’i; the combination of coloured elevation contours and subtle hill shading is great as a base for the map symbols. They also have an SVG template for icons and such. A lot of these principles only work in color though, and I think for print I have to go greyscale.

As for implementing this, my plan is to start with Natural Earth and OSM data and rough something up in QGIS. And then start working in earnest with a tool to extract the data I need and export it to SVG format. Mapnik maybe? Then use Inkscape to further style and deliver the SVG, also allow non-map experts to add text annotations. Or maybe I can lean on QGIS more than that and not write custom code to emit the SVG I need. Looking forward to learning more.

Sochi ski area maps

This Wired piece on Sochi maps notes that OpenStreetMap has way more map detail for the Olympic ski area than Google maps. It’s not entirely a surprise; Google’s coverage in Russia isn’t great, they’re not really into mapping ski lifts and trails, etc. Still, it’s a big world event, you’d think Google would have put some more effort into getting good data. Anyway, I did a map comparison from more sources than the Wired article. Nothing comes near OSM, but the Yandex maps aren’t bad. I did my best to make maps at the same scale centered on 43.6639, 40.3058.

Images in the gallery on this post. Some of why OSM looks so impressive is they just map a whole lot more kinds of features than other maps. That’s a mixed blessing. From worst to best, Bing and Apple have noticeably worse river and road data and are missing the railroad entirely; must be older data. Google’s maps won’t get you lost, Yandex has more local info still, and then the OSM maps have a generous amount of extra info.

Update: the OSM data in Sochi is years old, contributed by many mappers. Not just an Olympics one-off.

Address schema for OSM

It’s lovely that OpenStreetMap has such a.. diverse schema. But it makes it hard to figure out how to encode stuff sometimes. I’m looking at importing a bunch of address data from other sources. What’s the right format?

The source data is diverse, but a common thing seems to be a Point mapped to a street name. Ie, the SF address database I downloaded says POINT(-122.408292 37.747785) 660 PRECITA AVE. Cool! There’s a lot of other data and ambiguity about exactly what that POINT encodes (street front? centroid of parcel? building?). But that’s a good place to start.

The OSM schema for addresses is reasonably well defined. Here are the most important tags, based on the Wiki pages for key:addr and Karlsruhe Schema

  • Parsed address: addr:housenumber, addr:street
  • Unparsed address: addr:full
  • Larger scale data: addr:city, addr:state, addr:country, addr:postcode

There’s additional complications for buildings with multiple addresses, and regions that don’t use city/state addressing (ie, addr:subdistrict), and interpolation, etc. Gonna punt on that and focus to what’s relevant for major US cities.

Another significant question is whether you tag the address data onto a building, or do you create a separate standalone address node. The latter approach seems necessary in the US where we don’t have building footprints for so many places. Although MapBox’s analysis is that the majority of addresses are on buildings.

Here’s a list of top address keys culled from TagInfo. I’ll note the majority of these are tags on nodes, not ways.

  • 26M: addr:housenumber
  • 23M: addr:street
  • 18M: addr:city
  • 14M: addr:postcode
  • 13M: addr:country

There’s a second group of keys that have hundreds of thousands of entries, but many fewer than those top 5 above

  • 1967k: addr:conscriptionnumber. (German addresses?)
  • 1605k: addr:interpolation
  • 842k: addr:state
  • 608k: addr:place
  • 500k-600k: addr:street:name, addr:street:type, addr:street:prefix
  • 463k: addr:streetnumber
  • 3896: addr:full
  • 280k-370k: addr:region, addr:district, addr:suburb

Here’s a bunch of maps of address data that people have made that are relevant. Some of these may not be for public consumption.

I’d like to double back and see what they do in Denmark. That country has very good geocoding data and an ongoing process to sync up with the official government data.

OpenStreetMap iD editor

The new Javascript OSM editor iD is working on live data now. So I made an edit, adding a pond I know is there by tracing it on Bing. Works pretty well, it’s an impressive JS app. Interactivity is not great, need 30fps+ responsive user feedback to really feel right. But it’s an early alpha, I’m sure they’ll get there.

The CSS looks home rolled other than a stock reset. Here’s the third party JS libraries they use:

<script src=’js/lib/lodash.js’></script>
<script src=’js/lib/d3.v3.js’></script>
<script src=’js/lib/sha.js’></script>
<script src=’js/lib/ohauth.js’></script>
<script src=’js/lib/jxon.js’></script>
<script src=’js/lib/d3.typeahead.js’></script>
<script src=’js/lib/d3.geo.tile.js’></script>
<script src=’js/lib/d3.size.js’></script>
<script src=’js/lib/d3.trigger.js’></script>
<script src=’js/lib/d3.keybinding.js’></script>
<script src=’js/lib/d3.tail.js’></script>
<script src=’js/lib/d3-compat.js’></script>
<script src=’js/lib/queue.js’></script>
<script src=’js/lib/bootstrap-tooltip.js’></script>
<script src=’js/lib/rtree.js’></script>

 

Notice what’s missing? A typical slippy map library like Leaflet or OpenLayers. He’s using D3 instead. I hadn’t realized how far along d3.geo.tile has come. Works pretty well on iOS too!

In addition to D3 there’s Lo-Dash (an Underscore alternative), SHA and OAuth (for login), JXON (for XML parsing?), Queue (for async), Bootstrap tooltips, and the RTree data structure for spatial lookups.

San Francisco centerlines

More on Skunk Alley; I was talking to Eric F and he was saying it was a shame that this path wasn’t already in OSM. San Francisco publishes a shapefile of street centerlines; apparently when that was imported via TIGER into OSM they filtered out stuff that wasn’t quite a street, like unimproved rights-of-way. And indeed my second, southern segment of Skunk Alley is in that shapefile, as “UNNAMED 025” with CNN 19211000.

So that begs the question; what’s in the SF shapefile that’s not in OSM? Answering that question correctly requires a bit more geometric fiddling in PostGIS than I know how to do yet, but I did get a quick and dirty picture by using QGIS by drawing the OSM data in black on top of the SFData shapefile in purple. Anything purple peeking through is in the difference (roughly)

Lots of little snips and bits in the SF shapefile that aren’t in the OSM. Interesting! I should figure out how to use PostGIS to give me the actual difference.

While preparing this map I had to fix it so that Church street showed up. I used to draw everything with “railway is null”, but somehow that leaves out Church St. Maybe because it has a Muni track running down it? But with railways turned on you get things like underground subways (BART), the old abandoned track snaking through the Mission, etc. Haven’t found a reliable way to filter all that out yet; need to revisit HighRoad’s canned queries for that.

Walkways in OSM (San Francisco)

I added a walkway to OSM today, Skunk Alley, a funky little path between two houses with a hand painted sign. It’s on land that’s not part of a house lot and goes through a convenient location, so I think it makes sense to have it marked in the map as an actual walkway.

Skunk Alley is tagged “highway=track, surface=dirt”. I’d never seen the surface tag before, it’s not a column in the SQL version of the OSM Metro extracts I’m using. But highway=’track’ is a useful clue. Here’s all the various kinds of highways that look to mean “a way you walk on but can’t drive”.

select highway, count(*) as n
from planet_osm_line where
"highway" IN ('pedestrian', 'track', 'path', 'footway', 'bridleway')
group by highway
order by n desc;

"footway";5252
"path";1063
"track";959
"pedestrian";116
"bridleway";2

I gather from stuff I read that highway=path is not loved in the OSM community.

Here’s a map of most of SF with those 5 types of highway coloured. Purple is “footway” and seems to apply both to walking tracks in parks and the occasional street-type walkway (like along San Jose Avenue, bottom middle). Light blue is “path” and has useful walkways. Brown is “track” and dark blue is everything “pedestrian” and “bridleway”. The distinction between them all seems entirely arbitrary. Fort Funston is all “tracks”, the zoo and Golden Gate Park is all “footways”, and the greenspace west of Stanyan & 17th gets “paths”.

Uploading OSM changes with JOSM

I moved a road. OpenStreetMap had one path for an obscure little road in Nevada City, CA called Woodwardia Place. I was curious about the exact path so I drove down it twice with a GPS logger, then used JOSM to upload a change. It’s cool how fast the upload took effect; the raster tiles for the map were generated anew within 30 seconds of my upload. JOSM is a bit confusing, and I never could figure out how to upload the GPX track for OSM’s records.

Here’s the edit; old road is in grey, new road is in yellow moved slightly north.

Image

Then I split the road. There’s a segment that’s a bridge, so I made a change that split the road into two ways and then tagged the short bridge segment with bridge=yes.

Finally I went to a different part of the map and removed a road segment. I’d driven blind down that road expecting it to go through, but the map was wrong. Never again! Removing a road segment is a bit tricky; I had to select the node on the western (non-existent) T intersection, “unglue it”, delete the incorrect line segments, then “merge nodes” to reglue the now-T intersection that does exist on the map.

OSM “interesting” columns

To better understand the OSM schema, I did a bunch of queries to find out which columns in which tables actually contained meaningful data. Kind of like the query about highway types I did, but for every single column. Then I went through by hand and copied out the “interesting” columns, ones that seemed to have a lot of data.

Here’s a big list by table, then column, then  the distribution of the values in that column. SF Metro only. One thing that’s clear; even in SF the data’s not complete enough to be an unbiased sample. For instance you can’t tell from OSM how many Jewish synagogues there are vs. how many Christian churches, the data’s just not complete enough.

Table planet_osm_line has 62256 rows

aeroway
99% 62093 None
 0% 143 taxiway
 0% 16 runway
 0% 3 apron

bridge
96% 60376 None
 3% 1872 yes

foot
96% 60024 None
 3% 2060 yes
 0% 117 permissive

highway
46% 29165 residential
14% 8897 service
10% 6307 None
 8% 5252 footway
 3% 1870 motorway_link
 2% 1841 tertiary
 2% 1765 secondary
 1% 1150 motorway
 1% 1113 unclassified
 1% 1063 path

man_made
98% 61560 None
 0% 618 pier
 0% 62 pipeline
 0% 12 breakwater

oneway
85% 52927 None
14% 9163 yes
 0% 74 no

railway
97% 60397 None
 1% 787 rail
 0% 322 tram
 0% 314 subway
 0% 166 spur
 0% 79 platform
 0% 68 disused
 0% 58 abandoned
 0% 42 light_rail
 0% 19 monorail

route
98% 61516 None
 0% 420 bicycle
 0% 122 road
 0% 73 subway
 0% 39 tram
 0% 29 scenic
 0% 23 bus
 0% 18 ferry
 0% 8 hiking
 0% 4 railway

service
91% 56958 None
 5% 3588 parking_aisle
 1% 956 driveway
 0% 321 spur
 0% 191 alley
 0% 121 siding

tunnel
99% 62024 None
 0% 227 yes

waterway
97% 60497 None
 2% 1317 stream
 0% 345 canal
 0% 74 drain
 0% 12 river
 0% 7 dam
Table planet_osm_polygon has 39872 rows

aeroway
99% 39841 None
 0% 17 apron
 0% 9 terminal
 0% 3 aerodrome
 0% 1 serodrome
 0% 1 boundary

amenity
92% 36797 None
 5% 2098 parking
 1% 416 school
 0% 81 restaurant
 0% 71 place_of_worship
 0% 51 fast_food
 0% 30 library
 0% 27 hospital
 0% 25 bank
 0% 19 toilets

building
60% 24237 yes
19% 7585 None
12% 5165 residential
 5% 2196 house
 0% 228 school
 0% 106 tank
 0% 55 apartments
 0% 54 retail
 0% 35 garages
 0% 34 terrace

leisure
94% 37581 None
 2% 875 pitch
 2% 847 park
 0% 177 playground
 0% 113 common
 0% 71 swimming_pool
 0% 47 golf_course
 0% 47 garden
 0% 31 sports_centre
 0% 24 track
Table planet_osm_point has 30916 rows

aeroway
99% 30763 None
 0% 107 gate
 0% 36 helipad
 0% 8 aerodrome
 0% 1 seaplane_base
 0% 1 checkin

amenity
73% 22602 None
 3% 1225 restaurant
 3% 997 place_of_worship
 3% 945 school
 2% 687 fire_hydrant
 1% 500 post_box
 1% 421 cafe
 0% 266 fast_food
 0% 263 bench
 0% 256 parking

highway
68% 21209 None
13% 4047 turning_circle
 5% 1850 traffic_signals
 4% 1534 crossing
 3% 979 bus_stop
 2% 903 stop
 0% 189 motorway_junction
 0% 184 mini_roundabout

leisure
97% 30131 None
 1% 524 park
 0% 151 playground
 0% 27 sports_centre
 0% 13 garden
 0% 10 slipway
 0% 9 designated smoking area
 0% 8 common
 0% 8 swimming_pool
 0% 8 picnic_table

man_made
99% 30620 None
 0% 100 water_tower
 0% 85 tower
 0% 30 crane
 0% 22 pier
 0% 12 monitoring_station
 0% 10 water_tank
 0% 6 mine
 0% 5 survey_point
 0% 4 lighthouse

natural
99% 30718 None
 0% 86 peak
 0% 44 bay
 0% 28 beach
 0% 18 tree
 0% 8 wood
 0% 7 spring
 0% 4 wetland
 0% 2 cave_entrance
 0% 1 cliff

power
93% 28782 None
 6% 2038 tower
 0% 90 pole
 0% 3 sub_station
 0% 2 station
 0% 1 generator

railway
97% 30282 None
 0% 260 level_crossing
 0% 168 tram_stop
 0% 63 subway_entrance
 0% 60 station
 0% 54 switch
 0% 21 crossing
 0% 4 turntable
 0% 3 buffer_stop
 0% 1 stop

religion
96% 29948 None
 3% 937 christian
 0% 14 jewish
 0% 12 buddhist
 0% 3 muslim
 0% 1 unitarian
 0% 1 scientologist

OSM unclassified lines, etc

I had a little todo item today, “Edit OpenStreetMap”. Thought it’d be fun to try out the editor. After 10 minutes I declare failure with Potlatch; the Flash app on the main server is so terribly slow as to be unusable. I need to read the Beginner’s Guide and other editing options.

After a bit of patience, Potlatch loaded usefully. I ended up editing the map to put a name on the tiny little Duncan-Castro park. I hope I did this right, the UI for adding a name to a park is not clear. I ended up using the Advanced view to add a name=Duncan-Castro field to the list for the way.

My big plan was to edit one of the 6000+ entries in the SF Metro extract that have no “highway” tagged on them. Turns out that’s not necessary; they tend to be other features, like creeks or county boundaries or stuff. D’oh.

I did find one entry for an uncategorized “Center Street” in SF, osm_id 8489931. But there’s so many other overlapping “Center Streets” in the database I think the fact this one is untagged is not a problem.

select
  name,
  ST_Length(ST_Transform(way, 2163))/1609 as miles
from planet_osm_line
where
  highway is null
order by miles desc;

"Golden Gate National Recreation Area";50.114480677903
"";50.1127120036684
"San Francisco";50.1127120036684
"San Mateo County";49.8960294825062
"";49.6164354346274
"Alameda County";49.5445744035326
"";49.3526266530211
"San Francisco County";49.3158064558191
"";49.2591797769354
"";49.2302041734416
"";49.2049183432214
"";49.1809376585467
"";49.0948344172935

Playing with OSM data, in TileMill

I revisted my earlier OSM experiment only using TileMill instead of QuantumGIS to make the map. TileMill has much nicer output, particularly if you want to ship a set of slippy map tiles or frame out specific high quality images / prints. It’s also more of a textual programming kind of paradigm, which I like better. OTOH TileMill also has very specific limits on what it’s capable of doing; it’s not a generic GIS toolset.

It was pretty easy; the hardest part was remembering the weird way to filter a table with select in TileMill; their PostGIS support is a bit idiosyncratic. Also it guessed wrong on the SRS for my tracks; they’re in WGS84 but it was trying to draw them as if they were in Google Mercator, way out of scale. That seems like a bug.

Anyway, I remade my map of my walks around SF, here’s an image and some code.

        "table": "(select * from planet_osm_polygon\n where leisure = 'park'\n  and geometrytype(\"way\") in ('POLYGON', 'MULTIPOLYGON')\n) as parks",
        "table": "(select * from planet_osm_line\n where \"railway\" is null\n) as road",

@road: #444444;
@border: #222222;
@park: rgb(196, 243, 170);
@water: #b8dee6;
@bg: #ffffff;
@track: rgb(237,101,22);

Map { background-color: @water; }

#sanfrancisco {
  polygon-opacity:1;
  polygon-fill:@bg;
  line-width: 2;
  line-color: @border;
}

#tracks {
  line-color: @track;
  line-width: 3.0;
}
#road {
  line-color: @road;
  [highway='motorway'] { line-width: 3.0; }
  [highway='motorway_link'] { line-width: 2.0; }
  [highway='footway'] { line-width: 0.7; line-color: lighten(@road, 20%); }
}
#parks {
  line-color: @border;
  line-width: 1.0;
  polygon-opacity: 1;
  polygon-fill: @park;
}

OpenStreetMap schema griping

OpenStreetMap is all kinds of awesome, but boy the data schema is a mess. planet_osm_roads doesn’t really contain all the roads, you want planet_osm_line. (Yes, one name is singular, one is plural). planet_osm_line sure contains a lot of lines, what are they all? The “highway” column tells you. here’s the most popular types of “highway” in the San Francisco metro extract.

select
  count(*) as cnt, highway
from planet_osm_line
group by highway
order by cnt desc;

  cnt  |        highway        
-------+-----------------------
 29165 | residential
  8897 | service
  6307 | 
  5252 | footway
  1870 | motorway_link
  1841 | tertiary
  1765 | secondary
  1150 | motorway
  1113 | unclassified
  1063 | path
   959 | track
   890 | primary
   712 | steps
   594 | cycleway
   191 | trunk
   150 | primary_link
   116 | pedestrian
    65 | trunk_link
    44 | construction
    39 | road
    35 | secondary_link
    24 | tertiary_link
     3 | footway_unconstructed
     2 | raceway
     2 | proposed
     2 | bridleway
     1 | service; residential
     1 | platform
     1 | crossing
     1 | living_street
     1 | abandoned
(31 rows)

It’s not terrible; things that are correctly classified really are. But “all roads” requires identifying several classes, there’s some ambiguity, and some stuff clearly doesn’t belong there. Still the data exists and is free, so I shouldn’t complain too much!

(Migurski’s High Road is a set of SQL views that present a cleaner schema of roads. But just roads, nothing else.)

Playing with OSM data

I’m playing with OpenStreetMap data in PostGIS, drawing maps in QGIS. No serious cartography, mind you, just trying to get a feel for the data. I’m starting with Mike Migurski’s metro extracts, the .osm.bz2 file for San Francisco

Import that into PostGIS, which gives this schema which describes these map features.

osm2pgsql -d walks --style /usr/share/osm2pgsql/default.style san-francisco.osm.bz2

For the SF metro, there’s 8000 roads, 40,000 polygons, 31,000 points, and 62,000 lines. You can import all these tables directly from pgsql into QGIS and render them for a basic view. The lines contain the street grid; roads contains just the larger highways, etc.

QGIS makes it easy to explore the tables. When you add a new PostGIS layer and choose a table, you can then choose specific fields and sample their values. Exploring around you can find that “leisure=park” is an interesting subset of polygons, for instance.

Roads are terribly complicated, so to simplify I tried using Migurski’s High Road. It creates custom views with names like “planet_osm_line_z14” where just roads relevant at that zoom level are present. Also some fancy stuff to make drawing casings vs. road surfaces easier. z15plus is the big set of all roads (170,000); _big is 24000 roads and _small is the other 144,000 lines (footpaths and such). Unfortunately QGIS can’t use the High Road views; details in this issue I filed.

I was able to use the High Road code as a guide for categorizing road by size, though. The “highway” field is the key one. It’s a messy schema, there’s about 7 synonyms for “street”.

Here’s a map of the walks I’ve taken in my neighborhood, with streets and parks.

 

Map tile licenses

I’m trying to launch a map project that uses another site’s map tiles in Polymaps. Here’s links to licensing details for various tile options, along with my very cursory understanding based on my non-expert quick read of their licenses.

Google Maps API: various limits, the most important being you are required to use their Javascript library. Or so I’m told, I didn’t read the license to find the specific language.

Microsoft Bing Maps: you can use their web services with your own code, although the way the metadata service works means you may end up having to display some Microsoft branding, links etc. Education and non-profits seem to have pretty generous usage terms. Commercial use can also proceed without a license agreement, but limited to “500,000 transactions” per year. Beyond that you email them for pricing.

OpenStreetMap: It’s Creative Commons, Attribution ShareAlike. No requirements on access code or amount of traffic beyond their tile usage policy. What “ShareAlike” means for a map that uses OSM tiles as a layer is complex: see common license interpretations. The key language I noted was

If you overlay OSM data with your own data created from other sources (for example you going out there with a GPS receiver) and the layers are kept separate and independent, and the OSM layer is unchanged, then you may have created a collective work. ... If you have created a collective work, then only the OSM component of the work must be subject to the OSM licence.

CloudMade. Their map tiles are derived from OSM so are similarly CC-A-SA. They may have further restrictions in their ToS.