An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20140217/157fea71/attachment.pl>
Rendering a map of all zip codes (ZCTAs)
2 messages · arilamstein at gmail.com, Roger Bivand
On Tue, 18 Feb 2014, arilamstein at gmail.com wrote:
I recenty posted<https://groups.google.com/forum/#!topic/ggplot2/5ZTGjl_Guvo)>this question on the ggplot2 mailing list and did not hear back, so I thought that reposting to sig-geo might be better. I have recently released an R package called choroplethr<http://tech.truliablog.com/2014/01/15/the-choroplethr-package-for-r/>that attempts to facilitate the creation of choropleth maps in R at the state, county and ZIP code level of detail. It uses the state and county maps that come with the ggplot2 package (or is the it the maps package?). For zip maps it just renders a scatterplot against the state boundaries.
Your "blog" points to github - the package is on CRAN, point to that; install.github() tries to install from source, and most users need binary installs; it is also not >= GPL-2. Note that the boundary data in the maps package do not have clear pedigrees, and the zipcode package only ships points (so why would you be surprised if only points are displayed?) - they are also without clear authority.
I would like to render zip code choropleths using the ZIP Code Tabulated Area (ZCTA) shapefile that the census distributes here<http://www.census.gov/cgi-bin/geo/shapefiles2013/main>. Hadley has a nice tutorial on how to work with shapefiles in ggplot2 here<https://github.com/hadley/ggplot2/wiki/plotting-polygon-shapefiles>. However, those directions do not work for me, and I think that it might be due to the size of the shapefile (501 MB zipped). As I mentioned on the ggplot2 mailing list, the call to "fortify" will run all night and still not finish.
You can choose to use ggplot2 and fortify, but you go from fish to fish soup without the possibility of getting the fish back (in reasonable time, fish paste best option). However, converting all the coordinates to data.frame format is time-consuming, and creates very many copies of attrribute data.
Can anyone give me pointers on how to work with this file effectively in R? Ideally I would be able to distribute this map as part of my package as well, but clearly the current size of the shapefile makes that prohibitive.
Firstly, do study thematic cartography. You'll find that many of the 30K geometries are invisible on most available screen resolutions, so that visualising more than a small subset isn't very sensible anyway (single pixels belonging to different class intervals from their neighbours are very hard to pick out, even with transparent borders). So choosing the subset of your imported SpatialPolygonsDataFrame object you need and only fortifying that subset will make things more tractable. You should drop the idea of shipping the US Census shapefile of ZCTA, CRAN and its mirrors do not need to duplicate files that are available online elsewhere; if the boundaries were on a WFS (Web Feature Server), it might be possible to download just the subset needed. Roger
Thanks. Ari [[alternative HTML version deleted]]
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Roger Bivand Department of Economics, Norwegian School of Economics, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: Roger.Bivand at nhh.no