An interactive map/guide to wineries in Napa:
It was produced in R using ggmap. A description of how it was made is here:
Or scraped from the post:
R has had a maps package available since the very early days. It’s great for simple geographic maps, but the political boundaries can be out of date. For more detailed maps, you can also download shape files and use the sp package to draw borders directly.
But for accurate and attractive maps of countries, roads and satellite imagery, nothing beats online sources like OpenStreetMap and Google Maps. At theuseR!2012 conference last month, David Kahle introduced his ggmap package, which makes it trivial to import such maps into R. You can then use maps as a background layer in a data visualization with ggplot2. (David gives detailed information in his useR slides.)
I wanted to try out the ggmap package, so I thought it would be fun to try and solve a problem that’s been bugging me for a while: it’s hard to find a good map of wineries you can visit in Napa Valley. (Yes, first-world problems, I know.) While there are more than 400 wineries in the Valley (plus hundreds more garage-based and custom crush producers), you can’t visit all of them for a public tasting. The Napa Valley Wine project manages a database of all the wineries and notes which can be visited, but doesn’t provide a map. I decided to use ggmap to create one.
First, I imported the Wine Project database as a data frame in R, and filtered out any wineries with an missing address (or where only a P.O. Box was provided). Then, I selected all of the wineries that offered tastings (either as walk-ins, or by appointment) — there were 345, in all. Then I used ggmap’s geocode function to convert the addresses into latitude/longitude coordinates:
addresses <- with(visit.wine, paste(Address, City, "CA", sep=", ") ) locs <- geocode(addresses)
Finally, I chose a map center of the city of Saint Helena, CA (the launch-point for my bike rides in the Valley) and grabbed the map from Google using ggmap’sqmap function. Then, I superimposed a scatterplot of the winery locations using the standard ggplot2 geom_point function:
map.center <- geocode("Saint Helena, CA") SHmap <- qmap(c(lon=map.center$lon, lat=map.center$lat), source="google", zoom=12) SHmap + geom_point( aes(x=lon, y=lat, colour=App), data=visit.wine) + scale_colour_manual(values=c("dark blue","orange"))+ labs(colour="Appointment Required")