diff --git a/knit_it.sh b/knit_it.sh index 94c9cb5..c765724 100644 --- a/knit_it.sh +++ b/knit_it.sh @@ -1,2 +1 @@ Rscript -e 'library(rmarkdown); rmarkdown::render("./mapping_draft.Rmd", "html_document")' -Rscript -e 'library(rmarkdown); rmarkdown::render("./mapping_draft.Rmd", "pdf_document")' diff --git a/mapping_draft.Rmd b/mapping_draft.Rmd index 0d197ef..7cef8e3 100644 --- a/mapping_draft.Rmd +++ b/mapping_draft.Rmd @@ -8,7 +8,7 @@ affiliation: University of Birmingham institute: University of Birmingham e-mail: "[j.kidwell@bham.ac.uk](mailto:j.kidwell@bham.ac.uk)" date: "`r Sys.Date()`" -bibliography: ~/Dropbox/bibtex/everything.bib +bibliography: biblio.bib linkcolor: black geometry: margin=1in # fontfamily: mathpazo @@ -324,6 +324,7 @@ admin_lev1_fortified <- join(admin_lev1_fortified,admin_lev1@data, by="id") # TODO: fix issues with cut_interval / cut_number below. Current error: "'breaks' are not unique calls" # See here: https://stackoverflow.com/questions/16184947/cut-error-breaks-are-not-unique # Reference here: https://ggplot2.tidyverse.org/reference/cut_interval.html +# Reference re: size and scale for plots: http://sape.inf.usi.ch/quick-reference/ggplot2/size ggplot() + geom_polygon(aes(x = long, y = lat, group = group, @@ -331,7 +332,7 @@ ggplot() + data = admin_lev1_fortified, colour = 'black', alpha = .7, - size = .3) + + size = .005) + viridis::scale_fill_viridis(discrete = TRUE) + labs(x = NULL, y = NULL, fill = "Groups", title = "Figure 1", @@ -340,13 +341,14 @@ ggplot() + "Data: UK Data Service (OGL) & Jeremy H. Kidwell", "You may redistribute this graphic under the terms of the CC-by-SA 4.0 license.", sep = "\n")) + + guides(colour = guide_legend(reverse=T)) + theme_void() + - theme(text = element_text(family = "Arial Narrow", size = 8), + theme(text = element_text(family = "Arial Narrow", size = 9), plot.title = element_text(size = 12, face = "bold"), plot.margin = unit(c(0, 0.25, 0.0, 0.25), "in"), panel.border = element_rect(fill = NA, colour = "#cccccc"), - legend.text = element_text(size = 8), - legend.position = c(0.9, 0.25)) + legend.text = element_text(size = 9), + legend.position = c(0.25, 0.85)) # TODO: shift to use of grobs: https://cran.r-project.org/web/packages/egg/vignettes/Ecosystem.html # ggsave("figure1.pdf") @@ -361,7 +363,7 @@ ggplot() + data = admin_lev1_fortified, colour = 'black', alpha = .7, - size = .3) + + size = .1) + viridis::scale_fill_viridis(discrete = TRUE) + labs(x = NULL, y = NULL, fill = "Groups", title = "Figure 2", @@ -433,7 +435,19 @@ admin_gathered <- gather(data.frame(admin_lev1), key="group_type", value="number # TODO: make custom legend labels, remove X axis label # Ambitious TODO: can we link Admin area titles to locations on adjacent map with lines -ggplot(admin_gathered, aes(fill=group_type, y=number, x=name)) + geom_bar(position="dodge", stat="identity") + coord_flip() + labs(title = "Figure 4", subtitle="Comparison of Groups by Admin Region", fill = "Groups") +ggplot(admin_gathered, + aes(fill=group_type, y=number, x=name)) + + geom_bar(position="dodge", stat="identity") + + coord_flip() + + labs( + title = "Figure 4", + subtitle ="Comparison of Groups by Admin Region", + fill = "Groups") + + theme( + legend.position="bottom", + legend.title = element_blank(), + axis.text.x = element_blank()) + + scale_color_manual(labels = c("DTAS", "ECS", "Permaculture", "Transition")) ``` @@ -529,7 +543,7 @@ A wide variety of historians and sociologists of religion have noted the regiona So why provide this kind of data (i.e. at the level of individual churches) when more granular data (i.e. at the level of individuals persons) is available in the form of the census and related parallel publications such as the 2008 Scottish Environmental Attitudes survey? We believe that mapping places of worship provides a useful intermediate level of analysis and may complement our more atomised understanding of EA which has been assessed at the level of individual persons to date. Because representation within some administrative areas of Scotland, can lead to a small number of data points, we have kept analysis to a National level and have not provided more specific administrative-area level calculations. ```{r create_ecs_denomination_table} -knitr::kable(ecs@data[["denomination"]], caption = 'ECS by denomination') +knitr::kable(summary(ecs@data[["denomination"]]), caption = 'ECS by denomination') # TODO: Add dataframe with overall church numbers for the UK from "ScottishChurches" dataset by JK ``` @@ -540,7 +554,7 @@ While Roman Catholic churches make up just over 10% of the church buildings in S # Eco-Congregations, Urban, Rural and Remote -```{r ur8fold} +```{r ur8fold, message=FALSE, warning=FALSE} # read in relevant polygons for UR8fold scale if (file.exists("data/SG_UrbanRural_2016.shp") == FALSE) { download.file("http://sedsh127.sedsh.gov.uk/Atom_data/ScotGov/ZippedShapefiles/SG_UrbanRural_2016.zip", @@ -590,7 +604,15 @@ Of all the groups surveyed in this study, Eco-Congregation Scotland is the most urbanrural_gathered <- gather(data.frame(urbanrural), key="group_type", value="number", ecs_count, transition_count, dtas_count, permaculture_count) # TODO: switch to stacked percentage plot, see here: https://www.r-graph-gallery.com/48-grouped-barplot-with-ggplot2/ -ggplot(urbanrural_gathered, aes(fill=group_type, y=number, x=UR8FOLD)) + geom_bar(position="dodge", stat="identity") + coord_flip() + labs(title = "Figure 8", subtitle="Comparison of Groups by UrbanRural category", fill = "Groups") + +ggplot(urbanrural_gathered, + aes(fill=group_type, y=number, x=UR8FOLD)) + + geom_bar(position="dodge", stat="identity") + + coord_flip() + + labs( + title = "Figure 8", + subtitle="Comparison of Groups by UrbanRural category", + fill = "Groups") ``` ```{r create_urbanrural_ecs_chart_choropleth, fig.width=4, fig.cap="Figure 9"} @@ -639,7 +661,7 @@ ggplot() + ```{r simd data, message=FALSE, warning=FALSE} # read in relevant polygons, Scottish Index of Multiple deprivation -if (file.exists("data/c_dz_11.shp") == FALSE) { +if (file.exists("data/simd2016_withgeog/c_dz_11.shp") == FALSE) { download.file("http://simd.scot/2016/data/simd2016_withgeog.zip", destfile = "data/simd2016_withgeog.zip") unzip("data/simd2016_withgeog.zip", exdir = "data", junkpaths = TRUE) @@ -696,15 +718,33 @@ allgroups_gathered <- gather(allgroups_simd, key = "simd_category", value = "ran # Run plots # Faceted stacked bar plot -# See here: http://theduke.at/blog/science/beginners-guide-to-creating-grouped-and-stacked-bar-charts-in-r-with-ggplot2/ -# Reference here: https://ggplot2.tidyverse.org/reference/geom_bar.html -ggplot(data=allgroups_gathered, aes(x=simd_category, y=rank)) + - geom_bar(stat="identity") + - facet_grid(~group_type) +# Sort by SIMD ranks for bar stacking below +allgroups_gathered <- allgroups_gathered[order(allgroups_gathered$simd_category, allgroups_gathered$rank),] -# TODO modify fill = quantiles via cut_interval() or mutate ntile() -# cut_interval(x, n = NULL, length = NULL, ...) +# Set manual x-axis labels +axisLabels.x <- c("Crime", "Education", "Employment","Geographic Access","Health","Housing","Income","Overall Rank") + +# Plot +# TODO - tidy facet labels: http://www.cookbook-r.com/Graphs/Facets_(ggplot2)/ +# TODO - add pointX, consider filtering out some of the simd_categories +ggplot(data=allgroups_gathered, + aes(x=simd_category, y=rank, + fill=cut_interval(allgroups_gathered$rank, n = 5))) + + geom_bar(stat="identity", position="fill") + + facet_grid(~group_type) + + theme(legend.position="none", axis.text.x = element_text(size=6, angle=90, hjust = 0.95, vjust = 0.2)) + + scale_x_discrete(labels=axisLabels.x) + + labs(x = NULL, + y = "SIMD Rank (in bins by quantile)", + fill = "Groups", + title = "Figure 10", + subtitle="Distribution of Groups across IMD Domains by Rank", + caption = paste("Jeremy H. Kidwell :: jeremykidwell.info", + "Data: UK Data Service (OGL) & Jeremy H. Kidwell", + "You may redistribute this graphic under the terms of the CC-by-SA 4.0 license.", + sep = "\n")) + # write.csv(simd_percents_only, "derivedData/simd_percents_only.csv", row.names=FALSE) ``` @@ -737,6 +777,12 @@ We can find divergence between transition communities and eco-congregation when # Proximity to "Wilderness" +Chasing down a curiosity, I decided to try and calculate whether proximity to "wilderness" or "scenic nature" or just trees might have some impact on generating more mobilised communities. I realised that there would be several problems with this kind of calculation up front, first being that "nature" is a deeply problematic construct, reviled by geographers and philosophers alike. With this in mind, I identified several different ways of reckoning wilderness, starting with the highly anachronistic "Scenic Land" designation from the 1970s. Then I pursued the more carefully calculated "core wild areas" generated by SNH just a few years ago. However, even the core wile areas concept has been criticised heavily, so I also expanded out my search to include all sites of special scientific interest and then went even wider to include the Scottish Forestry Service's "Native Woodland" and finally, the most generic possible measurement, any land identified as forested at the last Forest Inventory. + +Proximity to these areas was the next concern, because many of these designations deliberately exclude human habitat, so it was necessary to measure the number of sites within proximity. There is a question which lies here regarding aesthetics, namely, what sort of proximity might generate an affective connection? From my own experience, I decided upon the distance represented by a short walk, i.e. a half-kilometre. However, with the more generic measurements, such as SSSI and forestation, this wouldn't do, as there are so many of these sites that a buffer of 500 meters encapsulates almost all of inhabited Scotland. So for these sites I also calculated a count within 50 metres. + +So what did I discover? The results were inconclusive. First, it is important to note that on the whole, Eco-Congregations tend to be more urban than place of worship taken generally at a rate of nearly 3:1 (5.4% of Eco-Congregations lie in areas currently designated as "Very Remote Rural Areas" whereas nearly 15% of places of worship lie in these areas), so what I was testing for was whether this gap was smaller when specifying these various forms of "wild" remoteness. For our narrowest measurements, there were so few sites captured as to render measurement unreliable. There are, for obvious reasons, 0 sites located within any of SNG's core wild areas. Similarly, there are very few of our activist communities located within SSSI's (only 5 places of worship out of over 4k, 2 transition towns, (or 2%) and 7 community development trusts (3%)). However, expanding this out makes things a bit more interesting, within 50 metres of SSSI's in Scotland lie 3 Eco-Congregations (or just under 1%), which compares favourably with the 61 places of worship (or just 1.5%) far exceeding our ratio (1:1.5 vs. 1:3). This is the same with our more anachronistic measure of "scenic areas," there are 7 eco-congregations within these areas, and 175 places of worship, making for a ratio of nearly 1:2 (2.1% vs. 4.3%). Taking our final measure, of forested areas, this is hard to calculate, as only one Eco-Congregation lies within either native or generally forested land + # Appendix A ```{r pander_admin_table} @@ -753,8 +799,8 @@ write.csv(dtas, "derivedData/dtas.csv", row.names=FALSE) write.csv(simd, "derivedData/simd.csv", row.names=FALSE) ## Output mmd tables using pander -panderOptions("digits", 2) -pander(as_data_frame(admin_lev1[,c(3,5,7,11,13)])) +# panderOptions("digits", 2) +# pander(as_data_frame(admin_lev1[,c(3,5,7,11,13)])) ``` # Appendix B @@ -770,6 +816,7 @@ pander(as_data_frame(admin_lev1[,c(3,5,7,11,13)])) # urbanrural.shortened<-data.frame(urbanrural.shortened) # panderOptions("digits", 2) # pander(urbanrural.shortened) +``` # Citations diff --git a/mapping_draft.html b/mapping_draft.html index c833a7b..1753680 100644 --- a/mapping_draft.html +++ b/mapping_draft.html @@ -9,205 +9,21 @@ - + +