diff --git a/figures/create_admin_barplot-1.pdf b/figures/create_admin_barplot-1.pdf index 974600b..0d3f695 100644 Binary files a/figures/create_admin_barplot-1.pdf and b/figures/create_admin_barplot-1.pdf differ diff --git a/figures/create_admin_barplot-1.png b/figures/create_admin_barplot-1.png index 74febfb..c4fe680 100644 Binary files a/figures/create_admin_barplot-1.png and b/figures/create_admin_barplot-1.png differ diff --git a/figures/create_choropleth_others-1.pdf b/figures/create_choropleth_others-1.pdf index ae401e4..9afa509 100644 Binary files a/figures/create_choropleth_others-1.pdf and b/figures/create_choropleth_others-1.pdf differ diff --git a/figures/create_choropleth_others-1.png b/figures/create_choropleth_others-1.png index 9b952ea..2ba6c94 100644 Binary files a/figures/create_choropleth_others-1.png and b/figures/create_choropleth_others-1.png differ diff --git a/figures/create_choropleth_others-2.pdf b/figures/create_choropleth_others-2.pdf index ad35615..5353591 100644 Binary files a/figures/create_choropleth_others-2.pdf and b/figures/create_choropleth_others-2.pdf differ diff --git a/figures/create_choropleth_others-2.png b/figures/create_choropleth_others-2.png index 651767b..6eabc04 100644 Binary files a/figures/create_choropleth_others-2.png and b/figures/create_choropleth_others-2.png differ diff --git a/figures/create_choropleth_others-3.pdf b/figures/create_choropleth_others-3.pdf index 4ab7e27..571c016 100644 Binary files a/figures/create_choropleth_others-3.pdf and b/figures/create_choropleth_others-3.pdf differ diff --git a/figures/create_choropleth_others-3.png b/figures/create_choropleth_others-3.png index 408da16..55541c0 100644 Binary files a/figures/create_choropleth_others-3.png and b/figures/create_choropleth_others-3.png differ diff --git a/figures/create_simd_barplot-1.pdf b/figures/create_simd_barplot-1.pdf index dc86b72..49ec99b 100644 Binary files a/figures/create_simd_barplot-1.pdf and b/figures/create_simd_barplot-1.pdf differ diff --git a/figures/create_simd_barplot-1.png b/figures/create_simd_barplot-1.png index e156aa7..194881b 100644 Binary files a/figures/create_simd_barplot-1.png and b/figures/create_simd_barplot-1.png differ diff --git a/figures/create_ur_barplot-1.pdf b/figures/create_ur_barplot-1.pdf index e547239..07b93c4 100644 Binary files a/figures/create_ur_barplot-1.pdf and b/figures/create_ur_barplot-1.pdf differ diff --git a/figures/create_ur_barplot-1.png b/figures/create_ur_barplot-1.png index 0ad0b87..a78321b 100644 Binary files a/figures/create_ur_barplot-1.png and b/figures/create_ur_barplot-1.png differ diff --git a/figures/create_urbanrural_ecs_chart_choropleth-1.pdf b/figures/create_urbanrural_ecs_chart_choropleth-1.pdf index 2970817..5c47104 100644 Binary files a/figures/create_urbanrural_ecs_chart_choropleth-1.pdf and b/figures/create_urbanrural_ecs_chart_choropleth-1.pdf differ diff --git a/figures/create_urbanrural_ecs_chart_choropleth-1.png b/figures/create_urbanrural_ecs_chart_choropleth-1.png index 19178c5..a657628 100644 Binary files a/figures/create_urbanrural_ecs_chart_choropleth-1.png and b/figures/create_urbanrural_ecs_chart_choropleth-1.png differ diff --git a/figures/plot_admin_ecs_admin2_choropleth-1.png b/figures/plot_admin_ecs_admin2_choropleth-1.png index 5f13b35..5200f2f 100644 Binary files a/figures/plot_admin_ecs_admin2_choropleth-1.png and b/figures/plot_admin_ecs_admin2_choropleth-1.png differ diff --git a/figures/plot_admin_ecs_choropleth-1.pdf b/figures/plot_admin_ecs_choropleth-1.pdf index d6fe2a5..bfa05c2 100644 Binary files a/figures/plot_admin_ecs_choropleth-1.pdf and b/figures/plot_admin_ecs_choropleth-1.pdf differ diff --git a/figures/plot_admin_ecs_choropleth-1.png b/figures/plot_admin_ecs_choropleth-1.png index 46510ae..05caf24 100644 Binary files a/figures/plot_admin_ecs_choropleth-1.png and b/figures/plot_admin_ecs_choropleth-1.png differ diff --git a/figures/plot_admin_ecs_normed_choropleth-1.pdf b/figures/plot_admin_ecs_normed_choropleth-1.pdf index 5f5bc80..b3393df 100644 Binary files a/figures/plot_admin_ecs_normed_choropleth-1.pdf and b/figures/plot_admin_ecs_normed_choropleth-1.pdf differ diff --git a/figures/plot_admin_ecs_normed_choropleth-1.png b/figures/plot_admin_ecs_normed_choropleth-1.png index 3787e43..c8414e3 100644 Binary files a/figures/plot_admin_ecs_normed_choropleth-1.png and b/figures/plot_admin_ecs_normed_choropleth-1.png differ diff --git a/figures/plot_admin_ecs_normed_choropleth-2.pdf b/figures/plot_admin_ecs_normed_choropleth-2.pdf index d50cead..dc0c585 100644 Binary files a/figures/plot_admin_ecs_normed_choropleth-2.pdf and b/figures/plot_admin_ecs_normed_choropleth-2.pdf differ diff --git a/figures/plot_admin_ecs_normed_choropleth-2.png b/figures/plot_admin_ecs_normed_choropleth-2.png index 353491b..c3444c1 100644 Binary files a/figures/plot_admin_ecs_normed_choropleth-2.png and b/figures/plot_admin_ecs_normed_choropleth-2.png differ diff --git a/figures/wilderness_plots-1.pdf b/figures/wilderness_plots-1.pdf deleted file mode 100644 index d70727f..0000000 Binary files a/figures/wilderness_plots-1.pdf and /dev/null differ diff --git a/figures/wilderness_plots-1.png b/figures/wilderness_plots-1.png deleted file mode 100644 index b1f355b..0000000 Binary files a/figures/wilderness_plots-1.png and /dev/null differ diff --git a/figures/wilderness_plots-2.pdf b/figures/wilderness_plots-2.pdf deleted file mode 100644 index ed3367c..0000000 Binary files a/figures/wilderness_plots-2.pdf and /dev/null differ diff --git a/figures/wilderness_plots-2.png b/figures/wilderness_plots-2.png deleted file mode 100644 index 082fcd1..0000000 Binary files a/figures/wilderness_plots-2.png and /dev/null differ diff --git a/mapping_draft.Rmd b/mapping_draft.Rmd index 5cce3d8..42f42a4 100644 --- a/mapping_draft.Rmd +++ b/mapping_draft.Rmd @@ -31,6 +31,8 @@ output: fig_caption: true citation_package: natbib latex_engine: xelatex + always_allow_html: yes + --- ```{r setup, include=FALSE} @@ -198,9 +200,8 @@ proj4string(transition_wgs) <- CRS(wgs84) transition <- spTransform(transition_wgs, bng) transition_sf <- st_as_sf(transition, coords = c("X", "Y"), crs=27700) -# read in all_churches data and turn it into a SpatialPointsDataFrame -# TODO: need to remove all data points which are outside BNG area to -# resolve error +# read in all_churches data (data set generated by Jeremy Kidwell to replace PointX data used from Ordnance Survey) +# TODO: need to remove all data points which are outside BNG area to resolve error # also need to make symmetrical with ECS denominations, add Methodist # churches, remove nazarene and salvation army @@ -217,7 +218,6 @@ coordinates(pow_pointX) <- c("feature_easting", "feature_northing") proj4string(pow_pointX) <- proj4string(admin_lev1) pow_pointX_sf <- st_as_sf(pow_pointX, coords = c("X", "Y"), crs=27700) - # read in Scottish Community Dev. trust data and turn it into a SpatialPointsDataFrame dtas <- read.csv("data/community-dev-trusts-2.6.csv") coordinates(dtas) <- c("X", "Y") @@ -229,7 +229,6 @@ permaculture <- read.csv("data/permaculture_scot-0.8.csv") coordinates(permaculture) <- c("X", "Y") proj4string(permaculture) <- proj4string(admin_lev1) permaculture_sf <- st_as_sf(permaculture, coords = c("X", "Y"), crs=27700) - ``` ```{r process_admin_data} @@ -298,10 +297,8 @@ admin_lev1$ecs_count_pownorm <- admin_lev1$ecs_count * admin_lev1$pow_percent # Preserve scale admin_lev1$ecs_count_popnorm_scaled <- admin_lev1$ecs_count_popnorm*(sum(admin_lev1$ecs_count)/sum(admin_lev1$ecs_count_popnorm)) - admin_lev1$ecs_count_pownorm_scaled <- admin_lev1$ecs_count_pownorm*(sum(admin_lev1$ecs_count)/sum(admin_lev1$ecs_count_pownorm)) - # Load population statistics for normalising data by population on admin_lev2 admin_lev2_pop <- read.csv("./data/scotland_and_wales_const_scotland_2011pop.csv") admin_lev2 <- merge(x=admin_lev2, y=admin_lev2_pop, by.x = "code", by.y = "CODE") @@ -326,14 +323,6 @@ Perhaps the first important question to ask of these groups is, where are they? # Note: for more information on EU administrative levels, see here: https://ec.europa.eu/eurostat/web/nuts/national-structures-eu # TODO: Need to clip choropleth polygons to buildings shapefile - -# Prepare admin_lev1 for tidyr and reinsert dropped columns -names(admin_lev1)[names(admin_lev1) == "newcode"] <- "id" -admin_lev1@data$id <- as.integer(rownames(admin_lev1@data)) -admin_lev1@data$id <- admin_lev1@data$id-1 -admin_lev1_fortified <- tidy(admin_lev1) -admin_lev1_fortified <- join(admin_lev1_fortified,admin_lev1@data, by="id") - # Draw initial choropleth map of ECS concentration (using sp, rather than sf data) # Note: some ideas taken from here: https://unconj.ca/blog/choropleth-maps-with-r-and-ggplot2.html # See also here: https://timogrossenbacher.ch/2016/12/beautiful-thematic-maps-with-ggplot2-only/ @@ -342,29 +331,23 @@ admin_lev1_fortified <- join(admin_lev1_fortified,admin_lev1@data, by="id") # 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, - fill = cut_interval(admin_lev1_fortified$ecs_count, 5)), - data = admin_lev1_fortified, - colour = 'black', - alpha = .7, - size = .005) + - scale_fill_brewer(palette = "Oranges") + - labs(x = NULL, y = NULL, fill = "Groups", - title = "Figure 1a", - subtitle="Concentration of ECS groups", - 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")) + - theme_void() + - 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 = 9), - legend.position = c(0.25, 0.85)) -# TODO: consider a shift to use of grobs: https://cran.r-project.org/web/packages/egg/vignettes/Ecosystem.html +# Switching to tmap from ggplot + +tm_shape(admin_lev1) + + tm_fill(col = "ecs_count", palette = "Oranges") + +# tm_shape(ecs_sf) + +# tm_dots("red", size = .05, alpha = .4) + +# tm_scale_bar(position = c("left", "bottom")) + + tm_style("gray", title = "Figure 1a") + + tm_credits("Data: UK Data Service (OGL) + & Jeremy H. Kidwell, + Graphic is CC-by-SA 4.0", + position = c("right", "bottom")) + + tm_layout(title = "Concentration of ECS groups", + frame = FALSE, + title.size = .7, + inner.margins = c(0.1, 0.1, 0.05, 0.05) + ) ``` @@ -372,35 +355,21 @@ ggplot() + ```{r plot_admin_ecs_admin2_choropleth, fig.width=4, fig.show="hold", fig.cap="Figure 3"} -# Prepare admin_lev2 for tidyr and reinsert dropped columns -names(admin_lev2)[names(admin_lev2) == "newcode"] <- "id" -admin_lev2@data$id <- as.integer(rownames(admin_lev2@data)) -admin_lev2@data$id <- admin_lev2@data$id-1 -admin_lev2_fortified <- tidy(admin_lev2) -admin_lev2_fortified <- join(admin_lev2_fortified,admin_lev2@data, by="id") - -ggplot() + - geom_polygon(aes(x = long, y = lat, group = group, - fill = cut_interval(admin_lev2_fortified$ecs_count, 5)), - data = admin_lev2_fortified, - colour = 'black', - alpha = .7, - size = .005) + - scale_fill_brewer(palette = "Oranges") + - labs(x = NULL, y = NULL, fill = "Groups", - title = "Figure 1b", - subtitle="Concentration of ECS groups (LAU)", - 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")) + - theme_void() + - 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 = 9), - legend.position = c(0.25, 0.85)) +tm_shape(admin_lev2) + + tm_fill(col = "ecs_count", palette = "Oranges") + +# tm_shape(ecs_sf) + +# tm_dots("red", size = .05, alpha = .4) + +# tm_scale_bar(position = c("left", "bottom")) + + tm_style("gray", title = "Figure 3") + + tm_credits("Data: UK Data Service (OGL) + & Jeremy H. Kidwell, + Graphic is CC-by-SA 4.0", + position = c("right", "bottom")) + + tm_layout(title = "Concentration of ECS groups", + frame = FALSE, + title.size = .7, + inner.margins = c(0.1, 0.1, 0.05, 0.05) + ) ``` @@ -408,52 +377,34 @@ ggplot() + ```{r plot_admin_ecs_normed_choropleth, fig.width=4, fig.show="hold", fig.cap="Figure 2"} # Plot out first figure with normalised data: -ggplot() + - geom_polygon(aes(x = long, y = lat, group = group, - fill = cut_interval(admin_lev1_fortified$ecs_count_pownorm_scaled, 5)), - data = admin_lev1_fortified, - colour = 'black', - alpha = .7, - size = .005) + - scale_fill_brewer(palette = "Oranges") + - labs(x = NULL, y = NULL, fill = "Groups", - title = "Figure 2", - subtitle="Concentration of ECS groups, data normalised by places of worship", - 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")) + - theme_void() + - theme(text = element_text(family = "Arial Narrow", size = 8), - 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.25, 0.85)) + +tm_shape(admin_lev1) + + tm_fill(col = "ecs_count_pownorm_scaled", palette = "Oranges") + + tm_style("gray", title = "Figure 4") + + tm_credits("Data: UK Data Service (OGL) + & Jeremy H. Kidwell, + Graphic is CC-by-SA 4.0", + position = c("right", "bottom")) + + tm_layout(title = "Concentration of ECS groups, data normalised by places of worship", + frame = FALSE, + title.size = .7, + inner.margins = c(0.1, 0.1, 0.05, 0.05) + ) # Plot out second figure with normalised data: -ggplot() + - geom_polygon(aes(x = long, y = lat, group = group, - fill = cut_interval(admin_lev1_fortified$ecs_count_popnorm_scaled, 5)), - data = admin_lev1_fortified, - colour = 'black', - alpha = .7, - size = .005) + - scale_fill_brewer(palette = "Oranges") + - labs(x = NULL, y = NULL, fill = "Groups", - title = "Figure 3", - subtitle="Concentration of ECS groups, data normalised by population", - 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")) + - theme_void() + - theme(text = element_text(family = "Arial Narrow", size = 8), - 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.25, 0.85)) + +tm_shape(admin_lev1) + + tm_fill(col = "ecs_count_popnorm_scaled", palette = "Oranges") + + tm_style("gray", title = "Figure 5") + + tm_credits("Data: UK Data Service (OGL) + & Jeremy H. Kidwell, + Graphic is CC-by-SA 4.0", + position = c("right", "bottom")) + + tm_layout(title = "Concentration of ECS groups, data normalised by places of worship", + frame = FALSE, + title.size = .7, + inner.margins = c(0.1, 0.1, 0.05, 0.05) + ) # TODO: Force bins to be consistently at count of 5? diff --git a/mapping_draft.html b/mapping_draft.html index d370463..599eb5c 100644 --- a/mapping_draft.html +++ b/mapping_draft.html @@ -11,21 +11,285 @@ - +