-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'terra-nova' into 'master'
Terra nova See merge request WEEL_grp/study-area-figures!1
- Loading branch information
Showing
6 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.