diff --git a/R/00-palette.R b/R/00-palette.R
index 909c70b..24682a3 100644
--- a/R/00-palette.R
+++ b/R/00-palette.R
@@ -1,12 +1,20 @@
### Palette - Study area figure ====
# Alec Robitaille
+# Water
watercol <- '#c3e2ec'
+streamcol <- '#7e9da7'
+streampolcol <- '#9cb4bc'
+coastcol <- '#b59f78'
+
+# Land
islandcol <- '#d0c2a9'
-coastcol <- '#82796a'
+
+# Anthro
roadcol <- '#666666'
-gridcol <- '#323232'
-parkcol <- '#9fb5a0'
-parkboundcol <- '#4c5d3a'
+parkcol <- '#b4bc9c'
+parkboundcol <- '#90967c'
+# Map etc
+gridcol <- '#323232'
diff --git a/R/06-terra-nova-prep.R b/R/06-terra-nova-prep.R
index 5de2852..b23af61 100644
--- a/R/06-terra-nova-prep.R
+++ b/R/06-terra-nova-prep.R
@@ -11,7 +11,7 @@ lapply(libs, require, character.only = TRUE)
## Polygon from Open Canada
# https://open.canada.ca/data/en/dataset/e1f0c975-f40c-4313-9be2-beb951e35f4e
curl_download('http://ftp.maps.canada.ca/pub/pc_pc/National-parks_Parc-national/national_parks_boundaries/national_parks_boundaries.shp.zip', 'input/national-parks.zip')
-
+dir.create('input')
unzip('input/national-parks.zip', exdir = 'input/national-parks')
parks <- st_read('input/national-parks')
@@ -21,7 +21,7 @@ tn <- parks[parks$parkname_e == 'Terra Nova National Park of Canada', ]
## Roads
# Need latlon
-bb <- st_bbox(st_transform(st_buffer(tn, 1e4), 4326))
+bb <- st_bbox(st_transform(st_buffer(tn, 5e4), 4326))
routes <- opq(bb) %>%
add_osm_feature(key = 'highway') %>%
osmdata_sf()
@@ -41,6 +41,14 @@ mpols <- water$osm_multipolygons
waterpols <- st_union(st_combine(mpols))
+# Streams
+waterways <- opq(bb) %>%
+ add_osm_feature(key = 'waterway') %>%
+ osmdata_sf()
+
+streamsPol <- st_cast(st_polygonize(st_union(waterways$osm_lines)))
+streamsLns <- waterways$osm_lines
+
### Reproject ----
# Projection
utm <- st_crs('+proj=utm +zone=21 ellps=WGS84')
@@ -49,8 +57,12 @@ utm <- st_crs('+proj=utm +zone=21 ellps=WGS84')
utmTN <- st_transform(tn, utm)
utmRoads <- st_transform(roads, utm)
utmWater <- st_transform(waterpols, utm)
+utmStreamsLns <- st_transform(streamsLns, utm)
+utmStreamsPol <- st_transform(streamsPol, utm)
### Output ----
st_write(utmTN, 'output/terra-nova-polygons.gpkg')
st_write(utmRoads, 'output/terra-nova-roads.gpkg')
st_write(utmWater, 'output/terra-nova-water.gpkg')
+st_write(utmStreamsLns, 'output/terra-nova-streams-lns.gpkg')
+st_write(utmStreamsPol, 'output/terra-nova-streams-pols.gpkg')
diff --git a/R/07-terra-nova-figure.R b/R/07-terra-nova-figure.R
index 0bbeb6b..e58e55b 100644
--- a/R/07-terra-nova-figure.R
+++ b/R/07-terra-nova-figure.R
@@ -18,6 +18,8 @@ roads <- st_read('output/terra-nova-roads.gpkg')
nl <- st_read('output/newfoundland-polygons.gpkg')
water <- st_read('output/terra-nova-water.gpkg')
+streamLns <- st_read('output/terra-nova-streams-lns.gpkg')
+streamPols <- st_read('output/terra-nova-streams-pols.gpkg')
# CRS
utm <- st_crs('+proj=utm +zone=21 ellps=WGS84')
@@ -56,6 +58,8 @@ nlcrop <- st_crop(nl, bb + rep(c(-5e4, 5e4), each = 2))
geom_sf(fill = islandcol, size = 0.3, color = coastcol, data = nlcrop) +
geom_sf(fill = parkcol, size = 0.3, color = parkboundcol, data = tn) +
geom_sf(fill = watercol, size = 0.2, color = coastcol, data = water) +
+ geom_sf(fill = streampolcol, color = NA, data = streamPols) +
+ geom_sf(color = streamcol, size = 0.4, data = streamLns) +
geom_sf(aes(color = highway), data = highway) +
geom_sf_label(aes(label = 'Terra Nova National Park'), size = 5, fontface = 'bold', data = tn) +
scale_color_manual(values = roadpal) +
diff --git a/R/08-terra-nova-buns-figure.R b/R/08-terra-nova-buns-figure.R
index 8bf5035..9f64463 100644
--- a/R/08-terra-nova-buns-figure.R
+++ b/R/08-terra-nova-buns-figure.R
@@ -40,6 +40,8 @@ roads <- st_read('output/terra-nova-roads.gpkg')
nl <- st_read('output/newfoundland-polygons.gpkg')
water <- st_read('output/terra-nova-water.gpkg')
+streamLns <- st_read('output/terra-nova-streams-lns.gpkg')
+streamPols <- st_read('output/terra-nova-streams-pols.gpkg')
# CRS
utm <- st_crs('+proj=utm +zone=21 ellps=WGS84')
@@ -100,8 +102,10 @@ nlcrop <- st_crop(nl, bbadjust + rep(c(-5e4, 5e4), each = 2))
geom_sf(fill = islandcol, size = 0.3, color = coastcol, data = nlcrop) +
geom_sf(fill = parkcol, size = 0.3, color = parkboundcol, data = tn) +
geom_sf(fill = watercol, size = 0.2, color = coastcol, data = water) +
- geom_sf(aes(color = highway), data = highway) +
scale_color_manual(values = roadpal) +
+ geom_sf(color = streamcol, size = 0.4, data = streamLns) +
+ geom_sf(fill = streampolcol, color = streamcol, alpha = 0.5, color = NA, data = streamPols) +
+ geom_sf(aes(color = highway), data = highway) +
geom_point(aes(x, y), data = grids) +
geom_sf_label(aes(label = 'Terra Nova National Park'), data = tn, fill = '#bbcbbc') +
geom_label_repel(aes(x, y, label = SiteName), size = 4.5, data = grids) +
diff --git a/R/09-bloomfield-figure.R b/R/09-bloomfield-figure.R
new file mode 100644
index 0000000..9718e5a
--- /dev/null
+++ b/R/09-bloomfield-figure.R
@@ -0,0 +1,132 @@
+### Bloomfield Study Area Figure ====
+# Alec L. Robitaille, Juliana Balluffi-Fry
+
+
+### Packages ----
+libs <- c(
+ 'data.table',
+ 'ggplot2',
+ 'sf',
+ 'ggrepel'
+)
+lapply(libs, require, character.only = TRUE)
+
+
+### Data ----
+grids <- data.table(SiteName = 'Bloomfield',
+ x = 723457,
+ y = 5359856)
+
+roads <- st_read('output/terra-nova-roads.gpkg')
+nl <- st_read('output/newfoundland-polygons.gpkg')
+water <- st_read('output/terra-nova-water.gpkg')
+streamLns <- st_read('output/terra-nova-streams-lns.gpkg')
+streamPols <- st_read('output/terra-nova-streams-pols.gpkg')
+
+
+# CRS
+utm <- st_crs(nl)
+
+# Bounding Box
+# In meters
+dist <- 4e4
+zoomout <- rep(c(-dist, dist), each = 2)
+bb <- st_bbox(st_as_sf(grids, coords = c('x', 'y'))) + zoomout
+
+# Only main highway and primary
+selroads <- c('trunk', 'primary', 'secondary')
+roads <- roads[roads$highway %in% selroads,]
+
+
+# Zoomout x2 to ensure no data is clipped within view
+streams <- st_crop(streamLns, bb + (zoomout * 2))
+highway <- st_crop(roads, bb + (zoomout * 2))
+nlcrop <- st_crop(nl, bb + (zoomout * 2))
+
+
+
+
+### Theme ----
+# Colors
+source('R/00-palette.R')
+
+roadcols <- data.table(highway = c('trunk', 'trunk_link', 'primary', 'primary_link',
+ 'secondary', 'secondary_link', 'tertiary',
+ 'tertiary_link',
+ 'service', 'residential', 'construction' ,
+ 'unclassified', 'cycleway', 'footway', 'bridleway',
+ 'path', 'track', 'steps'
+))
+roadcols[, cols := gray.colors(.N, start = 0.1, end = 0.6)]
+roadpal <- roadcols[, setNames(cols, highway)]
+
+
+# Theme
+themeMap <- theme(panel.border = element_rect(size = 1, fill = NA),
+ panel.background = element_rect(fill = watercol),
+ panel.grid = element_line(color = gridcol, size = 0.6),
+ axis.text = element_text(size = 11, color = 'black'),
+ axis.title = element_blank())
+
+### Plot ----
+
+# NL plot
+(gnl <- ggplot() +
+ geom_sf(fill = islandcol, size = 0.1, color = 'black', data = nl) +
+ geom_rect(
+ aes(
+ xmin = bb['xmin'],
+ xmax = bb['xmax'],
+ ymin = bb['ymin'],
+ ymax = bb['ymax']
+ ),
+ fill = NA,
+ size = 1.5,
+ color = 'red'
+ ) +
+ themeMap +
+ theme(axis.text = element_blank(),
+ axis.ticks = element_blank(),
+ plot.margin = grid::unit(c(-1,-1,-1,-1), 'mm')))
+
+
+# Base bloomfield
+(gblm <- ggplot() +
+ geom_sf(fill = islandcol, size = 0.3, color = coastcol, data = nlcrop) +
+ geom_sf(fill = watercol, size = 0.2, color = coastcol, data = water) +
+ geom_sf(fill = streampolcol, color = NA, data = streamPols) +
+ geom_sf(color = streamcol, size = 0.2, data = streamLns) +
+ geom_sf(aes(color = highway), size = 0.5, data = highway) +
+ geom_point(aes(x, y), size = 2, data = grids) +
+ geom_label_repel(aes(x, y, label = SiteName), size = 6.5, data = grids) +
+ scale_color_manual(values = roadpal) +
+ coord_sf(xlim = c(bb['xmin'], bb['xmax']),
+ ylim = c(bb['ymin'], bb['ymax'])) +
+ guides(color = FALSE) +
+ themeMap)
+
+
+
+#add NL map to bloomfield map
+annoBB <- st_sfc(st_point(c(-54.4, 48.1)))
+st_crs(annoBB) <- 4326
+annotateBB <- st_bbox(st_buffer(st_transform(annoBB, utm), 1.3e4))
+
+g <- gblm +
+ annotation_custom(
+ ggplotGrob(gnl),
+ xmin = annotateBB['xmin'],
+ xmax = annotateBB['xmax'],
+ ymin = annotateBB['ymin'],
+ ymax = annotateBB['ymax']
+ )
+
+
+### Output ----
+ggsave(
+ 'graphics/09-bloomfield.png',
+ g,
+ width = 10,
+ height = 10,
+ dpi = 320
+)
diff --git a/README.Rmd b/README.Rmd
index 1669689..8cd788a 100644
--- a/README.Rmd
+++ b/README.Rmd
@@ -70,7 +70,7 @@ Reproducing: run `03-newfoundland-prep.R` and `06-terra-nova-prep.R` to generat
knitr::include_graphics('graphics/07-terra-nova.png')
```
-4. Terra Nova Bunny Grids
+5. Terra Nova Bunny Grids
This uses data from GeoGratis and Open Street Map and six packages: `osmdata`, `curl`, `zip`, `sf`, `data.table` and `ggplot`.
@@ -80,3 +80,15 @@ Reproducing: run `03-newfoundland-prep.R` and `06-terra-nova-prep.R` to generat
```{r}
knitr::include_graphics('graphics/08-terra-nova-buns.png')
```
+
+6. Bloomfield
+
+This uses data from Open Street Map and six packages: `osmdata`, `curl`, `zip`, `sf`, `data.table` and `ggplot`.
+
+
+Reproducing: run `03-newfoundland-prep.R` and `06-terra-nova-prep.R` to generate the NL and TN polygons and `09-bloomfield-figure.R` to combine and generate the figure.
+
+```{r}
+knitr::include_graphics('graphics/09-bloomfield.png')
+```
+
diff --git a/README.md b/README.md
index 13328b2..2331854 100644
--- a/README.md
+++ b/README.md
@@ -1,22 +1,20 @@
-# study-area-figures
+study-area-figures
+==================
-Collecting WEEL study area figures in one place, for sharing\!
+Collecting WEEL study area figures in one place, for sharing!
-## Contributing:
+Contributing:
+-------------
1. Clone the repository
2. Add your script (follow the numbering scheme)
-3. Add the output figure to `graphics/`, with a name and number
- matching the script it originates from.
-4. (Ideally) add the figure to the `README.Rmd` so we can preview them
- all together in one spot.
+3. Add the output figure to `graphics/`, with a name and number matching the script it originates from.
+4. (Ideally) add the figure to the `README.Rmd` so we can preview them all together in one spot.
-**Note: currently the input folder is ignored, if you have small data
-you’d like to share, carefully remove it from the `.gitignore`**
+**Note: currently the input folder is ignored, if you have small data you'd like to share, carefully remove it from the `.gitignore`**
-Also, we output the features to `.gpkg` (GeoPackage) because…
-[shapefiles are hell](http://switchfromshapefile.org).
+Also, we output the features to `.gpkg` (GeoPackage) because... [shapefiles are hell](http://switchfromshapefile.org).
Also\! I made a bash script for rerunning all the figures. If you want
to try it, let me know.
@@ -25,11 +23,9 @@ to try it, let me know.
1. Fogo Island
-This uses data from Open Street Map and four packages: `osmdata`, `sf`,
-`data.table` and `ggplot`.
+This uses data from Open Street Map and four packages: `osmdata`, `sf`, `data.table` and `ggplot`.
-Reproducing: run `01-fogo-island-prep.R` to generate the islands polygon
-and `02-fogo-island-figure.R` to generate the figure.
+Reproducing: run `01-fogo-island-prep.R` to generate the islands polygon and `02-fogo-island-figure.R` to generate the figure.
``` r
knitr::include_graphics('graphics/02-fogo-island.png')
@@ -37,16 +33,13 @@ knitr::include_graphics('graphics/02-fogo-island.png')
-2. Newfoundland
+1. Newfoundland
-This uses data from Open Street Map and four packages: `osmdata`, `sf`,
-`data.table` and `ggplot`.
+This uses data from Open Street Map and four packages: `osmdata`, `sf`, `data.table` and `ggplot`.
-Reproducing: run `03-newfoundland-prep.R` to generate the islands
-polygon and `04-newfoundland-figure.R` to generate the figure.
+Reproducing: run `03-newfoundland-prep.R` to generate the islands polygon and `04-newfoundland-figure.R` to generate the figure.
-Note: this map doesn’t show internal water. Let me know if that’s
-something you’d like to add.
+Note: this map doesn't show internal water. Let me know if that's something you'd like to add.
``` r
knitr::include_graphics('graphics/04-newfoundland.png')
@@ -54,15 +47,11 @@ knitr::include_graphics('graphics/04-newfoundland.png')
-3. Fogo with Newfoundland inset
+1. Fogo with Newfoundland inset
-This uses data from Open Street Map and four packages: `osmdata`, `sf`,
-`data.table` and `ggplot`.
+This uses data from Open Street Map and four packages: `osmdata`, `sf`, `data.table` and `ggplot`.
-Reproducing: run `01-fogo-island-prep.R`, `03-newfoundland-prep.R`, to
-generate the Fogo and NL polygons and
-`04-fogo-inset-newfoundland-figure.R` to combine and generate the
-figure.
+Reproducing: run `01-fogo-island-prep.R`, `03-newfoundland-prep.R`, to generate the Fogo and NL polygons and `04-fogo-inset-newfoundland-figure.R` to combine and generate the figure.
``` r
knitr::include_graphics('graphics/05-fogo-inset-nl.png')
@@ -70,14 +59,11 @@ knitr::include_graphics('graphics/05-fogo-inset-nl.png')
-4. Terra Nova
+1. Terra Nova
-This uses data from GeoGratis and Open Street Map and six packages:
-`osmdata`, `curl`, `zip`, `sf`, `data.table` and `ggplot`.
+This uses data from GeoGratis and Open Street Map and six packages: `osmdata`, `curl`, `zip`, `sf`, `data.table` and `ggplot`.
-Reproducing: run `03-newfoundland-prep.R` and `06-terra-nova-prep.R` to
-generate the NL and TN polygons and `07-terra-nova-figure.R` to combine
-and generate the figure.
+Reproducing: run `03-newfoundland-prep.R` and `06-terra-nova-prep.R` to generate the NL and TN polygons and `07-terra-nova-figure.R` to combine and generate the figure.
``` r
knitr::include_graphics('graphics/07-terra-nova.png')
@@ -85,17 +71,26 @@ knitr::include_graphics('graphics/07-terra-nova.png')
-4. Terra Nova Bunny Grids
+1. Terra Nova Bunny Grids
-This uses data from GeoGratis and Open Street Map and six packages:
-`osmdata`, `curl`, `zip`, `sf`, `data.table` and `ggplot`.
+This uses data from GeoGratis and Open Street Map and six packages: `osmdata`, `curl`, `zip`, `sf`, `data.table` and `ggplot`.
-Reproducing: run `03-newfoundland-prep.R` and `06-terra-nova-prep.R` to
-generate the NL and TN polygons and `08-terra-nova-buns-figure.R` to
-combine and generate the figure.
+Reproducing: run `03-newfoundland-prep.R` and `06-terra-nova-prep.R` to generate the NL and TN polygons and `08-terra-nova-buns-figure.R` to combine and generate the figure.
``` r
knitr::include_graphics('graphics/08-terra-nova-buns.png')
```
+
+1. Bloomfield
+
+This uses data from Open Street Map and six packages: `osmdata`, `curl`, `zip`, `sf`, `data.table` and `ggplot`.
+
+Reproducing: run `03-newfoundland-prep.R` and `06-terra-nova-prep.R` to generate the NL and TN polygons and `09-bloomfield-figure.R` to combine and generate the figure.
+
+``` r
+knitr::include_graphics('graphics/09-bloomfield.png')
+```
+
+
diff --git a/graphics/02-fogo-island.png b/graphics/02-fogo-island.png
index 28663b3..7cd37c0 100644
Binary files a/graphics/02-fogo-island.png and b/graphics/02-fogo-island.png differ
diff --git a/graphics/04-newfoundland.png b/graphics/04-newfoundland.png
index a62e804..3fbc6d1 100644
Binary files a/graphics/04-newfoundland.png and b/graphics/04-newfoundland.png differ
diff --git a/graphics/05-fogo-inset-nl.png b/graphics/05-fogo-inset-nl.png
index c598b92..2cf6443 100644
Binary files a/graphics/05-fogo-inset-nl.png and b/graphics/05-fogo-inset-nl.png differ
diff --git a/graphics/07-terra-nova.png b/graphics/07-terra-nova.png
index aeae1ab..b1c7cc0 100644
Binary files a/graphics/07-terra-nova.png and b/graphics/07-terra-nova.png differ
diff --git a/graphics/08-terra-nova-buns.png b/graphics/08-terra-nova-buns.png
index 2fb772d..b830953 100644
Binary files a/graphics/08-terra-nova-buns.png and b/graphics/08-terra-nova-buns.png differ
diff --git a/graphics/09-bloomfield.png b/graphics/09-bloomfield.png
new file mode 100644
index 0000000..15effcb
Binary files /dev/null and b/graphics/09-bloomfield.png differ
diff --git a/output/terra-nova-polygons.gpkg b/output/terra-nova-polygons.gpkg
index c0d714f..fd481d7 100644
Binary files a/output/terra-nova-polygons.gpkg and b/output/terra-nova-polygons.gpkg differ
diff --git a/output/terra-nova-roads.gpkg b/output/terra-nova-roads.gpkg
index 7f1b4a0..e721cc5 100644
Binary files a/output/terra-nova-roads.gpkg and b/output/terra-nova-roads.gpkg differ
diff --git a/output/terra-nova-streams-lns.gpkg b/output/terra-nova-streams-lns.gpkg
new file mode 100644
index 0000000..5390d5e
Binary files /dev/null and b/output/terra-nova-streams-lns.gpkg differ
diff --git a/output/terra-nova-streams-pols.gpkg b/output/terra-nova-streams-pols.gpkg
new file mode 100644
index 0000000..4466ce7
Binary files /dev/null and b/output/terra-nova-streams-pols.gpkg differ
diff --git a/output/terra-nova-water.gpkg b/output/terra-nova-water.gpkg
index 49177de..c8f9223 100644
Binary files a/output/terra-nova-water.gpkg and b/output/terra-nova-water.gpkg differ