Posts tagged as:

map

One way, the wrong way

December 23, 2009 in General

Every single street in Boston is one-way, the wrong way. At least, that’s what I’ve believed since I lived there – no matter where you want to go, the roads that appear to form the most direct route will inevitably carry traffic only in the opposite direction. And somehow that remains true when you try to drive back!

Until today, this was just a thought I kept to myself, except to commiserate with other Boston drivers. But now, Andy Woodruff at Cartogrammar (last seen on TGR mapping the colors of Harvard Square) has exposed this bizarre phenomenon to the world. Andy has mapped out a selection of Boston routes which look short and simple as the crow flies but end up being circuitous nightmares thanks to the city’s bizarre traffic patterns.

I immediately recognized the first (above) as the loop of Cambridge Common in Harvard Square – anyone familiar with the rest?

(Via Cartogrammar)

{ 1 comment }

The NYT has published an infographic showing the top recipe searches on Allrecipes.com. Searches are broken out by state, allowing some interesting comparisons. (Local dialects and preferences are an interest of mine, and when combined with maps I can’t resist… see also various words for soda.)

Here’s the chart for “apple pie”, the 5th most popular search. Purple states had above-average search volume; orange states were below:

apple pieIt’s not a particularly even distribution – and sent me looking for a Thanksgiving dish that was more uniformly enjoyed by all Americans. Unsurprisingly, that turned out to be “turkey,” the 14th most popular search. It’s graphic was a blend of muted purples and oranges, dispersed unevenly among the nation’s geography:

turkeyFrom there, I went searching for hyperlocal dishes or specialties. This would be much easier with the raw data, as a simple statistical test for dispersion and geographic correlation would toss up the winners – but it’s a testament to the NYT’s excellent graphics team that their visual maps serve the purpose just as well.

First up, sweet potatoes. The #1 search in the country was “sweet potato casserole,” with most of the searches concentrated in the southeast:

sweet potato casserole

Clocking in at #15 was “sweet potato pie,” another another – even more strongly – southeast favorite:

sweet potato pie

Interestingly, though, sweet potatoes themselves formed a pretty uniform search pattern across the states – and, after turkey, get my vote for “most American dish”:

sweet potato

The dataset reveals two interesting facts about sweet potatoes. First, some people don’t spell too good:

sweet potato casserole 2

Second, there’s a vocabulary difference, as many people out west prefer to call their sweet potatoes “yams” (I can’t back that up empirically, as they might want actual yams, but there is enough of a difference in dialect that many “yams” sold in the United States are required to state that they are also sweet potatoes on their packaging):

yams

Moving on from those delicious root vegetables to another family, corn, reveals further geographic breakdowns. Here’s Midwestern favorite #18, corn casserole:

corn casserole# 27: corn pudding, popular in the mid-Atlantic… and Alaska:

corn puddingand #31 cornbread dressing in the south:

cornbread dressing

Meanwhile, new England likes its butternut squash:

butternut squash

By this point, you’re better off clicking through the actual graphic than staring at my reprints… I hope that all of TGR’s American readers had a happy Thanksgiving, regardless of what was on the table.

{ 0 comments }

This morning, I was excited to see two of my interests collide as Nathan from FlowingData posted a tutorial for creating a choropleth: a map that uses color to convey values (I didn’t know that’s what they’re called either). He used county-level unemployment statistics to generate the following image:

However, the process appears quite intense, involving some python scripts and mucking around inside an SVG file. I half-heartedly wondered if there wasn’t a simpler way to create the image. And just then, along came David from Revolutions to throw down the gauntlet: could anyone come up with a way to replicate Nathan’s map in R?

David’s post pointed me toward R’s maps package, and off I went to start downloading the tools…

It took some time to coerce the BLS data into a compatible form; R don’t understand the FIPS county identifiers, so I had to jump through some hoops to get the strings to match (BLS uses state abbreviations; R wants full names. BLS puts in the words “county”, “parish” or “borough”, R doesn’t expect those to be passed. The BLS has a “Miami-Dade” county in Florida; R recognizes only “Dade”. Etc.) Ultimately, I used the following code to format the strings:

With the data in the correct format, I aligned a color vector with R’s list of counties and plotted the result:

It came out like this:

maps package result

Not too bad, I think. It’s a little rough around the edges and a couple of counties are missing – I assume they are the ones with odd naming conventions (you’ll notice I manually adjusted Miami-Dade in my code). Also, I’m not sure how to bring Hawaii and Alaska into the picture. Moreover, the image doesn’t look too good in R itself. For example, I had given up on getting the county borders to show up as faint lines (I could only get them to be completely opaque) – imagine my surprise when I exported the chart and could see the borders just fine!

In any case, I wasn’t satisfied with this result. I’ve been experimenting with ggplot2 and remembered it had some mapping functions, so off I went to recreate the image with yet another library. Ggplot2 is an excellent general-purpose graphics library; the maps package feels positively last-gen after playing with ggplot2. It’s much more extensible and has many more parameters to experiment with – hard to believe it’s not the standard graphics package that ships with R (which itself is another last-gen experience).

Anyway, I kept the data formatted as above – which may have added an extra line or two to the ggplot2 code, but makes it simpler to jump back and forth – and used the following script to draw a new version of the map:

And the resulting image:


ggplot2 package result

Again, a couple drawbacks: Alaska and Hawaii are nowhere to be seen and the borders are slightly aliased. The aliasing does make a difference, especially when compared to the maps output, but the ease with which I put together the latter graph and the frustration I experienced with the maps package, in my mind, more than erase that perceived shortcoming.

On the whole, I’d still take Nathan’s map over these as a finished product. However, I don’t think R can be beat for ease of use and all-in-one packageability – if I wanted, I could run regressions on the data, overlay my chart with more colors or new metrics, explode out certain counties or states… the possibilities are endless. With just a couple lines of code, I could overlay states the voted for Obama in blue, or highlight counties starting with the letter “C”. The static SVG method doesn’t allow any of that flexibility. Also, I’m completely confident that if I had any experience with these mapping packages – rather than using them for the first time tonight – I could mimic Nathan’s image perfectly.

The ggplot2 package, in particular, is fantastically powerful. I really wish I had discovered it sooner. As a matter of fact, Josh Reich runs a monthly R meetup for R users in the New York area and the next topic happens to be ggplot2 – it’ll be my first time attending, so I can’t really say what to expect, but I’m definitely looking forward to it.


{ 3 comments }

How many roads…

October 29, 2009 in Data

Ben Fry has created a stunning image consisting of the 26 million roads in the United States (click to zoom):

Nothing other than asphalt (gravel, dirt…) has been drawn here, but geographic and political features emerge nonetheless. In a very real sense, the geography is a latent feature of the roads dataset, as it creates boundary conditions for the observable effect (that being the roads themselves). In other words, we see mountains, rivers, oceans, and the Canadian border because they are defined by contiguous regions without any streets.

Please see Ben’s project page for more information.

{ 0 comments }

From Cartogrammar, an absolutely brilliant application of the Flickr API produces this map of the colors of Harvard Square:

The map was created by taking geocoded photos from Flickr and calculating the average hue of the photograph, then plotting that color on the map and interpolating between all the resulting points.  Astoundingly, this image shows the colors (on average) that people in Harvard Square were looking at! Lots of red along the streets come from the abundance of brick buildings, but spots of green shine through just where you’d expect them to – though Harvard Yard is a bit muted (probably because its ringed by so many bricks). My guess is that the blue in the upper right corner comes from sky captured in pictures of Annenberg’s roof.

To take this image to the next level, one would need geographic information on not just where the person stood, but of each object in his or her image. That’s a tall order for a single photo, but with enough images you could solve for the locations of each object in space. A blurred point cloud from Microsoft’s Photosynth would do the trick, or see for example this recreation of Dubrovnik, created purely from tourist’s geolocated photos:

YouTube Preview Image

{ 0 comments }

Unemployment map

April 20, 2009 in Economics

Slate has an interactive map which illustrates job losses by county throughout the US over the last two years. It’s very sobering to watch the red circles (representing losses) explode in late 2008.

{ 0 comments }

Anyone who has visited the South has probably heard a conversation like this:

Waitress: What would you like to drink?

Southerner: I’ll have a coke.

Waitress: What kind of coke?

Southerner: I’ll have a Coke.

And after this bizarre back and forth, the waitress goes off and comes back with (surprise!) a Coke.  Like this:

But this is also a coke:

And so is this:

Yeah, Southerners are weird; obviously only one of those is a Coke. But this twilight zone of soft drinks doesn’t end there – if you were at a diner in the Midwest they’d be offering you “pop” as if you were stuck in Pleasantville around 1950.

And what do you say in a bar – I’ll have a Jack and pop?  If you don’t know the local custom you might end up with a very different drink than you ordered.  Or a very awkward conversation.  Or both.  (And speaking of, I wonder if Southerners visiting the Northeast are terrified of ordering vodka sodas?)

This has driven me crazy for some time, but finally someone has done the research and crunched the numbers and categorically demonstrated all the crazy things people say when they mean to say “soda” (click to zoom):

See Strange Maps for the full details (I really like this site, if you hadn’t noticed).

{ 0 comments }