Skip to content

Commit

Permalink
Merge branch 'middle-ridge' into 'master'
Browse files Browse the repository at this point in the history
Middle ridge

See merge request WEEL_grp/study-area-figures!9
  • Loading branch information
robitalec committed May 22, 2020
2 parents 544ccc1 + e4255e4 commit c8158bc
Show file tree
Hide file tree
Showing 19 changed files with 396 additions and 55 deletions.
4 changes: 2 additions & 2 deletions R/00-palette.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
### Palette - Study area figure ====
# === Palette - Study area figures ----------------------------------------
# Alec Robitaille

# Water
Expand All @@ -24,7 +24,7 @@ forestcol <- '#A4BC9C'
gridcol <- '#323232'


# Road hiearchy
# Road hierarchy
levels <- c('motorway', 'trunk', 'primary', 'secondary', 'tertiary',
'unclassified', 'residential', 'motorway_link', 'trunk_link',
'primary_link', 'secondary_link', 'tertiary_link',
Expand Down
9 changes: 6 additions & 3 deletions R/01-fogo-island-prep.R
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
### Fogo island prep ====
# === Fogo Island Prep ----------------------------------------------------
# Alec L. Robitaille


### Packages ----
# Packages ----------------------------------------------------------------
libs <- c('sf',
'osmdata')
lapply(libs, require, character.only = TRUE)

### Download OSM data ----


# Download OSM data -------------------------------------------------------
# Set up bounding box - order: xmin, ymin, xmax, ymax
bb <- c(xmin = -54.3533,
ymin = 49.5194,
Expand Down Expand Up @@ -65,6 +67,7 @@ cutisles <- st_difference(islands, waterpols)




### Reproject ----
# Projections
utm <- st_crs('+proj=utm +zone=21 ellps=WGS84')
Expand Down
15 changes: 9 additions & 6 deletions R/02-fogo-island-figure.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
### Fogo Study Area Figure ====
# === Fogo Island Prep ----------------------------------------------------
# Alec L. Robitaille


### Packages ----
# Packages ----------------------------------------------------------------
libs <- c(
'data.table',
'ggplot2',
Expand All @@ -11,15 +11,16 @@ libs <- c(
lapply(libs, require, character.only = TRUE)


### Data ----
# Data --------------------------------------------------------------------
fogo <- st_read('output/fogo-island-polygons.gpkg')
roads <- st_read('output/fogo-roads.gpkg')


# CRS
utm <- st_crs('+proj=utm +zone=21 ellps=WGS84')


### Theme ----
# Theme -------------------------------------------------------------------
# Colors
source('R/00-palette.R')

Expand All @@ -36,7 +37,8 @@ themeMap <- theme(panel.border = element_rect(size = 1, fill = NA),
axis.text = element_text(size = 11, color = 'black'),
axis.title = element_blank())

### Plot ----

# Plot --------------------------------------------------------------------
# Base fogo
(gfogo <- ggplot() +
geom_sf(fill = islandcol, size = 0.3, color = coastcol, data = fogo) +
Expand All @@ -46,7 +48,8 @@ themeMap <- theme(panel.border = element_rect(size = 1, fill = NA),
themeMap)


### Output ----

# Output ------------------------------------------------------------------
ggsave(
'graphics/02-fogo-island.png',
gfogo,
Expand Down
15 changes: 10 additions & 5 deletions R/03-newfoundland-prep.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
### Newfoundland prep ====
# === Newfoundland Prep ---------------------------------------------------
# Alec L. Robitaille


### Packages ----

# Packages ----------------------------------------------------------------
libs <- c('sf', 'osmdata')
lapply(libs, require, character.only = TRUE)

### Download OSM data ----


# Download OSM data -------------------------------------------------------
# Download osm coastlines in bbox
# NOTE: This steps takes a few moments
zz <- opq(getbb('Newfoundland')) %>%
Expand All @@ -23,13 +26,15 @@ castpolys <- st_cast(st_polygonize(st_union(lns)))
nl <- st_as_sf(castpolys)


### Reproject islands ----

# Reproject islands -------------------------------------------------------
# Projections
utm <- st_crs('+proj=utm +zone=21 ellps=WGS84')

# Project to UTM
utmNL <- st_transform(nl, utm)


### Output ----

# Output ------------------------------------------------------------------
st_write(utmNL, 'output/newfoundland-polygons.gpkg')
15 changes: 9 additions & 6 deletions R/04-newfoundland-figure.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
### Newfoundland Study Area Figure ====
# === Newfoundland - Figure -----------------------------------------------
# Alec L. Robitaille


### Packages ----

# Packages ----------------------------------------------------------------
libs <- c(
'data.table',
'ggplot2',
Expand All @@ -11,14 +12,14 @@ libs <- c(
lapply(libs, require, character.only = TRUE)


### Data ----
# Data --------------------------------------------------------------------
nl <- st_read('output/newfoundland-polygons.gpkg')

# CRS
utm <- st_crs('+proj=utm +zone=21 ellps=WGS84')


### Theme ----
# Theme -------------------------------------------------------------------
# Colors
source('R/00-palette.R')

Expand All @@ -29,15 +30,17 @@ themeMap <- theme(panel.border = element_rect(size = 1, fill = NA),
axis.text = element_text(size = 11, color = 'black'),
axis.title = element_blank())

### Plot ----

# Plot --------------------------------------------------------------------
# NOTE: this figure only has the main island's coastline (eg missing Fogo)
# Base NL
(gnl <- ggplot(nl) +
geom_sf(fill = islandcol, color = coastcol, size = 0.3) +
themeMap)


### Output ----

# Output ------------------------------------------------------------------
ggsave(
'graphics/04-newfoundland.png',
gnl,
Expand Down
20 changes: 13 additions & 7 deletions R/05-fogo-inset-newfoundland-figure.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
### Fogo Inset in NL Study Area Figure ====
# === Fogo Inset in NL Study Area Figure ----------------------------------
# Alec L. Robitaille


### Packages ----

# Packages ----------------------------------------------------------------
libs <- c(
'data.table',
'ggplot2',
Expand All @@ -12,7 +13,8 @@ libs <- c(
lapply(libs, require, character.only = TRUE)


### Data ----

# Data --------------------------------------------------------------------
fogo <- st_read('output/fogo-island-polygons.gpkg')
roads <- st_read('output/fogo-roads.gpkg')

Expand All @@ -38,10 +40,11 @@ utmBB <- data.table(dtbb[, project(cbind(x, y), utm$proj4string)])



### Theme ----
# Theme -------------------------------------------------------------------
# Colors
source('R/00-palette.R')


roadcols <- data.table(highway = c("primary", "secondary", "residential",
"service", "unclassified", "footway"))
roadcols[, cols := gray.colors(.N, start = 0.1, end = 0.4)]
Expand All @@ -55,7 +58,8 @@ themeMap <- theme(panel.border = element_rect(size = 1, fill = NA),
axis.text = element_text(size = 11, color = 'black'),
axis.title = element_blank())

### Plot ----

# Plot --------------------------------------------------------------------
# Base Fogo
gfogo <- ggplot(fogo) +
geom_sf(fill = islandcol, size = 0.3, color = coastcol) +
Expand Down Expand Up @@ -99,7 +103,8 @@ gnl <- ggplot(nl) +
)


### Output ----

# Output -----------------------------------------------------------------
ggsave(
'graphics/05-fogo-inset-nl.png',
g,
Expand All @@ -110,7 +115,8 @@ ggsave(



### Alternative options ----

# Alternative options -----------------------------------------------------
# Fogo with NL coastline visible
# (gnl <- ggplot(nl) +
# geom_sf(fill = islandcol) +
Expand Down
18 changes: 12 additions & 6 deletions R/06-terra-nova-prep.R
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
### Terra Nova prep ====
# === Terra Nova - Prep ---------------------------------------------------
# Alec L. Robitaille, Isabella Richmond


### Packages ----

# Packages ----------------------------------------------------------------
libs <- c('curl', 'zip', 'sf', 'osmdata')
lapply(libs, require, character.only = TRUE)


### Download Terra Nova data ----

# Download TN data --------------------------------------------------------
## 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')
Expand Down Expand Up @@ -49,8 +51,9 @@ waterways <- opq(bb) %>%
streamsPol <- st_cast(st_polygonize(st_union(waterways$osm_lines)))
streamsLns <- waterways$osm_lines

### Reproject ----
# Projection


# Reprojection ------------------------------------------------------------
utm <- st_crs('+proj=utm +zone=21 ellps=WGS84')

# Project to UTM
Expand All @@ -60,7 +63,10 @@ utmWater <- st_transform(waterpols, utm)
utmStreamsLns <- st_transform(streamsLns, utm)
utmStreamsPol <- st_transform(streamsPol, utm)

### Output ----



# 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')
Expand Down
15 changes: 9 additions & 6 deletions R/07-terra-nova-figure.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
### Terra Nova Study Area Figure ====
# === Terra Nova - Figure -------------------------------------------------
# Alec L. Robitaille, Isabella Richmond


### Packages ----
# Packages ----------------------------------------------------------------
libs <- c(
'data.table',
'ggplot2',
Expand All @@ -11,7 +11,8 @@ libs <- c(
lapply(libs, require, character.only = TRUE)


### Data ----

# Data --------------------------------------------------------------------
tn <- st_read('output/terra-nova-polygons.gpkg')
roads <- st_read('output/terra-nova-roads.gpkg')

Expand All @@ -29,7 +30,8 @@ selroads <- c('trunk', 'primary')
highway <- roads[roads$highway %in% selroads,]


### Theme ----

# Theme -------------------------------------------------------------------
# Colors
source('R/00-palette.R')

Expand All @@ -49,7 +51,8 @@ themeMap <- theme(panel.border = element_rect(size = 1, fill = NA),
bb <- st_bbox(tn) - rep(c(1e3, -1e3), each = 2)


### Plot ----

# Plot --------------------------------------------------------------------
# Crop NL
nlcrop <- st_crop(nl, bb + rep(c(-5e4, 5e4), each = 2))

Expand All @@ -69,7 +72,7 @@ nlcrop <- st_crop(nl, bb + rep(c(-5e4, 5e4), each = 2))
themeMap)


### Output ----
# Output ------------------------------------------------------------------
ggsave(
'graphics/07-terra-nova.png',
gtn,
Expand Down
16 changes: 10 additions & 6 deletions R/08-terra-nova-buns-figure.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
### Terra Nova Buns Grid Study Area Figure ====
# === Terra Nova Buns Grid - Figure ---------------------------------------
# Alec L. Robitaille, Isabella Richmond


### Packages ----
# Packages ----------------------------------------------------------------
libs <- c(
'data.table',
'ggplot2',
Expand All @@ -12,7 +12,8 @@ libs <- c(
lapply(libs, require, character.only = TRUE)


### Data ----

# Data --------------------------------------------------------------------
grids <- data.table(
SiteName = c("Bloomfield",
"Dunphy's Pond", "TNNP North", "Unicorn"),
Expand Down Expand Up @@ -51,7 +52,8 @@ selroads <- c('trunk', 'primary')
highway <- roads[roads$highway %in% selroads,]


### Theme ----

# Theme -------------------------------------------------------------------
# Colors
source('R/00-palette.R')

Expand All @@ -72,7 +74,8 @@ bb <- st_bbox(tn) + rep(c(-5e3, 5e3), each = 2)
bbadjust <- bb #+ c(-1e3, 0, 0, 0)


### Plot ----

# Plot --------------------------------------------------------------------
# Crop NL
nlcrop <- st_crop(nl, bbadjust + rep(c(-5e4, 5e4), each = 2))

Expand Down Expand Up @@ -134,7 +137,8 @@ annotateBB <- st_bbox(st_transform(annotateSf, utm))



### Output ----

# Output ------------------------------------------------------------------
ggsave(
'graphics/08-terra-nova-buns.png',
g,
Expand Down
Loading

0 comments on commit c8158bc

Please sign in to comment.