Map Projections for R Shapefiles: United States
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Someone contacted me recently about the map projections used in my blscrapeR package. After a bit of web searching, I couldn’t find a really good list of map projections for the continental U.S. that could be used in R. This list is as much for my own reference as anyone else, but hope you find it useful.
Here’s my list of map projections that are appropriate to map the continental U.S. in R. DISCLAIMER: I have omitted many, if you like another, comment and I’ll add to the list. The full code is below in Gist form. There are many other projections listed here, I just displayed the ones I find most useful.
The Native Map Projection
U-g-l-y, you ain’t got no alibi!
# Default projection of the map can be found by running the following on the SpatialPolyGonsDataFrame. raster::crs(county) # Then apply the result to the CRS() functions. us.map <- spTransform(state, CRS("+proj=longlat +datum=NAD83 +no_defs +ellps=GRS80 +towgs84=0,0,0"))
Mercator Projection
# Mercator projection. us.map <- spTransform(state, CRS("+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +no_defs"))
Lambert Azimuthal Equal Area Projection
# Lambert Azimuthal Equal Area us.mpa <- spTransform(state, CRS("+proj=laea +lat_0=52 +lon_0=10 +x_0=4321000 +y_0=3210000 +ellps=GRS80 +units=m +no_defs"))
# Lambert Conformal Conic us.mpa <- spTransform(state, CRS("+proj=lcc +lat_1=33 +lat_2=45 +lat_0=39 +lon_0=-96 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs"))
Albers Equal Area Projection
# Albers Equal Area us.mpa <- spTransform(state, CRS("+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-96 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs"))
Albers Equal Area Conic Projection
# Albers Equal Area Conic us.mpa <- spTransform(state, CRS("+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=37.5 +lon_0=-96 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs"))
Full Code
Here's the full script I used, including all of the projection arguments, shapefile and mapping data.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.