From 0f22b6a2235fcb17886f939006b36d179f65068d Mon Sep 17 00:00:00 2001
From: Jason Brown
Date: Wed, 26 Aug 2015 13:14:33 -0400
Subject: [PATCH 1/3] Present population density choropleths instead of
count-based choropleth.
---
IntroToMapping.Rmd | 34 +++++++++++++++++++++++++---------
1 file changed, 25 insertions(+), 9 deletions(-)
diff --git a/IntroToMapping.Rmd b/IntroToMapping.Rmd
index e43dd71..e8a43ab 100644
--- a/IntroToMapping.Rmd
+++ b/IntroToMapping.Rmd
@@ -79,19 +79,35 @@ data("df_zip_demographics")
kable(head(df_zip_demographics))
```
-## Population: Washington
-
-```{r}
-dfzipmedrent=df_zip_demographics[,c(1,8)]
-colnames(dfzipmedrent)=c("region","value")
-zip_choropleth(dfzipmedrent,state_zoom="washington")+coord_map() #adds mercator projection
+## Population Density Choropleths
+Use population density (population per area) rather than raw count for a sound spatial analysis. A good explanation of the trouble with choropleth maps of raw count data is available in Monmonier, Mark, _Mapping It Out: Expository Cartography for the Humanities and Social Sciences_ (1993: University of Chicago Press, Chicago). Pages 159-167.
+
+```{r pop density intro}
+library(dplyr)
+data(zip.map) #Pull ZCTA area from `choroplethrZip` package data sets to compute density
+zarea <- zip.map %>% group_by(region) %>%
+ summarize(zland = first(ALAND10), zwater = first(AWATER10))
+df_pop_zip <- df_pop_zip %>% merge(zarea, all.x = TRUE)
+df_pop_zip$popdensity <- with(df_pop_zip, count / (zland + zwater) * 1000 ^ 2)
+kable(head(df_pop_zip))
```
-## Population: Spokane County (FIPS 53063)
-```{r}
+## Population Density: Washington
+
+Use an equal area projection since the measure is normalized by area.
+
+```{r wash state pop density}
+df_pop_zip$value <- df_pop_zip$popdensity
+zip_choropleth(df_pop_zip, state_zoom = 'washington', legend = 'Count per km^2') +
+ coord_map(projection = 'albers', lat0 = 41, lat1 = 47) # equal area projection for pacific NW http://spatialreference.org/ref/sr-org/nad83-us-pacific-northwest-albers/html/
+```
+
+## Population Density: Spokane County (FIPS 53063)
-zip_choropleth(dfzipmedrent, county_zoom=53063) + coord_map()
+```{r county zcta pop density}
+zip_choropleth(df_pop_zip, county_zoom = 53063, legend = 'Count per km^2') +
+ coord_map(projection = 'albers', lat0 = 41, lat1 = 47)
```
## Interactive map using leaflet, tigris and acs
From 129cbe5d4ba73dbc8766b572099016a2c00e4ff8 Mon Sep 17 00:00:00 2001
From: Jason Brown
Date: Wed, 26 Aug 2015 13:22:04 -0400
Subject: [PATCH 2/3] Population density choropleths instead of count
choropleths.
---
IntroToMapping.Rmd | 34 +++++++++++++++++++++++++---------
1 file changed, 25 insertions(+), 9 deletions(-)
diff --git a/IntroToMapping.Rmd b/IntroToMapping.Rmd
index e43dd71..e8a43ab 100644
--- a/IntroToMapping.Rmd
+++ b/IntroToMapping.Rmd
@@ -79,19 +79,35 @@ data("df_zip_demographics")
kable(head(df_zip_demographics))
```
-## Population: Washington
-
-```{r}
-dfzipmedrent=df_zip_demographics[,c(1,8)]
-colnames(dfzipmedrent)=c("region","value")
-zip_choropleth(dfzipmedrent,state_zoom="washington")+coord_map() #adds mercator projection
+## Population Density Choropleths
+Use population density (population per area) rather than raw count for a sound spatial analysis. A good explanation of the trouble with choropleth maps of raw count data is available in Monmonier, Mark, _Mapping It Out: Expository Cartography for the Humanities and Social Sciences_ (1993: University of Chicago Press, Chicago). Pages 159-167.
+
+```{r pop density intro}
+library(dplyr)
+data(zip.map) #Pull ZCTA area from `choroplethrZip` package data sets to compute density
+zarea <- zip.map %>% group_by(region) %>%
+ summarize(zland = first(ALAND10), zwater = first(AWATER10))
+df_pop_zip <- df_pop_zip %>% merge(zarea, all.x = TRUE)
+df_pop_zip$popdensity <- with(df_pop_zip, count / (zland + zwater) * 1000 ^ 2)
+kable(head(df_pop_zip))
```
-## Population: Spokane County (FIPS 53063)
-```{r}
+## Population Density: Washington
+
+Use an equal area projection since the measure is normalized by area.
+
+```{r wash state pop density}
+df_pop_zip$value <- df_pop_zip$popdensity
+zip_choropleth(df_pop_zip, state_zoom = 'washington', legend = 'Count per km^2') +
+ coord_map(projection = 'albers', lat0 = 41, lat1 = 47) # equal area projection for pacific NW http://spatialreference.org/ref/sr-org/nad83-us-pacific-northwest-albers/html/
+```
+
+## Population Density: Spokane County (FIPS 53063)
-zip_choropleth(dfzipmedrent, county_zoom=53063) + coord_map()
+```{r county zcta pop density}
+zip_choropleth(df_pop_zip, county_zoom = 53063, legend = 'Count per km^2') +
+ coord_map(projection = 'albers', lat0 = 41, lat1 = 47)
```
## Interactive map using leaflet, tigris and acs
From a1ba7692d95b5a0caef0f710bf4da32b9291b299 Mon Sep 17 00:00:00 2001
From: Jason Brown
Date: Wed, 2 Sep 2015 09:49:44 -0400
Subject: [PATCH 3/3] Add .html for pop density edits.
---
.gitignore | 1 +
IntroToMapping.html | 140 +++++++++++++++++++++++++++++++++-----------
2 files changed, 108 insertions(+), 33 deletions(-)
diff --git a/.gitignore b/.gitignore
index 96374c4..a992975 100644
--- a/.gitignore
+++ b/.gitignore
@@ -41,3 +41,4 @@ $RECYCLE.BIN/
Network Trash Folder
Temporary Items
.apdisk
+.Rproj.user
diff --git a/IntroToMapping.html b/IntroToMapping.html
index dc373bd..62825ca 100644
--- a/IntroToMapping.html
+++ b/IntroToMapping.html
@@ -86,7 +86,7 @@
-
+
@@ -411,24 +411,98 @@
-
Use population density (population per area) rather than raw count for a sound spatial analysis. A good explanation of the trouble with choropleth maps of raw count data is available in Monmonier, Mark, Mapping It Out: Expository Cartography for the Humanities and Social Sciences (1993: University of Chicago Press, Chicago). Pages 159-167.
-
+
library(dplyr)
+data(zip.map) #Pull ZCTA area from `choroplethrZip` package data sets to compute density
+zarea <- zip.map %>% group_by(region) %>%
+ summarize(zland = first(ALAND10), zwater = first(AWATER10))
+df_pop_zip <- df_pop_zip %>% merge(zarea, all.x = TRUE)
+df_pop_zip$popdensity <- with(df_pop_zip, count / (zland + zwater) * 1000 ^ 2)
+kable(head(df_pop_zip))
-
Population: Spokane County (FIPS 53063)
+
+
+
region
+
zland
+
zwater
+
value
+
count
+
popdensity
+
+
+
01001
+
29635482
+
2229764
+
545.421805
+
17380
+
545.421805
+
+
+
01002
+
142559990
+
4276576
+
195.577987
+
28718
+
195.577987
+
+
+
01003
+
1842385
+
12788
+
6083.529676
+
11286
+
6083.529676
+
+
+
01005
+
114586901
+
667043
+
44.423642
+
5120
+
44.423642
+
+
+
01007
+
136346000
+
6943850
+
101.842524
+
14593
+
101.842524
+
+
+
01008
+
139331464
+
5086093
+
8.032264
+
1160
+
8.032264
+
+
+
+
Population Density: Washington
+
+
Use an equal area projection since the measure is normalized by area.