Skip to content

Commit

Permalink
Merge branch 'terra-nova' into 'master'
Browse files Browse the repository at this point in the history
Terra nova

See merge request WEEL_grp/study-area-figures!1
  • Loading branch information
Isabella Richmond committed Apr 15, 2020
2 parents 4146f42 + e6f8489 commit 2b1809e
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 0 deletions.
44 changes: 44 additions & 0 deletions R/06-terra-nova-prep.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
### Terra Nova prep ====
# Alec L. Robitaille, Isabella Richmond


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


### Download Terra Nova 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')

unzip('input/national-parks.zip', exdir = 'input/national-parks')

parks <- st_read('input/national-parks')

tn <- parks[parks$parkname_e == 'Terra Nova National Park of Canada', ]


## Roads
# Need latlon
bb <- st_bbox(st_transform(st_buffer(tn, 1e4), 4326))
routes <- opq(bb) %>%
add_osm_feature(key = 'highway') %>%
osmdata_sf()

# Grab roads
roads <- routes$osm_lines



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

# Project to UTM
utmTN <- st_transform(tn, utm)
utmRoads <- st_transform(roads, utm)

### Output ----
st_write(utmTN, 'output/terra-nova-polygons.gpkg')
st_write(utmRoads, 'output/terra-nova-roads.gpkg')
70 changes: 70 additions & 0 deletions R/07-terra-nova-figure.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
### Terra Nova Study Area Figure ====
# Alec L. Robitaille, Isabella Richmond


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


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

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

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

# Only main highway
highway <- roads[roads$highway == 'trunk',]


### Theme ----
# Colors
watercol <- '#c3e2ec'
islandcol <- '#d0c2a9'
coastcol <- '#82796a'
roadcol <- '#666666'
gridcol <- '#323232'
roadcol <- '#191919'

parkcol <- '#7F9B62'
parkboundcol <- '#4c5d3a'


# 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.2),
axis.text = element_text(size = 11, color = 'black'),
axis.title = element_blank())

# x/y limits
bb <- st_bbox(tn) - rep(c(1e3, -1e3), each = 2)


### Plot ----
# Base terra-nova
(gtn <- ggplot() +
geom_sf(fill = islandcol, size = 0.3, color = coastcol, data = nl) +
geom_sf(fill = parkcol, size = 0.3, color = parkboundcol, data = tn) +
geom_sf(color = roadcol, data = highway) +
coord_sf(xlim = c(bb['xmin'], bb['xmax']),
ylim = c(bb['ymin'], bb['ymax'])) +
guides(color = FALSE) +
themeMap)


### Output ----
ggsave(
'graphics/07-terra-nova.png',
gtn,
width = 10,
height = 10,
dpi = 320
)
Binary file added graphics/07-terra-nova.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed output/fogo-water.Rds
Binary file not shown.
Binary file modified output/terra-nova-polygons.gpkg
Binary file not shown.
Binary file added output/terra-nova-roads.gpkg
Binary file not shown.

0 comments on commit 2b1809e

Please sign in to comment.