R_scripts/hake_map.R

############################################################################
### notes on making a basic map of the west coast of the U.S. and Canada
############################################################################

# load packages
require(maps)
require(mapdata)
library(ggplot2)
library(ggforce)

# latitude and longitude of the boundaries between the U.S. and Canadian EEZs
# adapted from some GIS file dowloaded from some U.S. government website

# longitude
US.CAN.lon <- c(-123.0907,-123.3222,-123.0085,-123.0085,-123.2679,-123.2189,-123.1599,
                -123.1151,-123.2484,-123.5412,-123.6791,-124.0121,-124.7272,-124.7272,
                -124.7517,-124.7761,-124.7883,-124.8133,-124.8382,-124.8405,-124.8656,
                -124.8906,-124.9156,-124.9158,-124.9408,-124.9657,-124.9886,-125.0030,
                -125.0151,-125.0151,-125.0261,-125.0493,-125.0724,-125.0955,-125.0978,
                -125.1196,-125.1414,-125.1416,-125.1547,-125.1750,-125.1954,-125.2157,
                -125.2360,-125.2563,-125.2766,-125.2969,-125.3172,-125.3375,-125.3441,
                -125.3441,-125.3577,-125.3780,-125.3814,-125.4046,-125.4278,-125.4510,
                -125.4742,-125.4974,-125.5008,-125.5235,-125.5463,-125.5690,-125.5917,
                -125.6144,-125.6371,-125.6598,-125.6825,-125.7051,-125.7278,-125.7505,
                -125.7731,-125.7958,-125.8184,-125.8411,-125.8637,-125.8863,-125.8980,
                -125.9186,-125.9392,-125.9597,-125.9803,-126.0008,-126.0213,-126.0419,
                -126.0624,-126.0829,-126.1034,-126.1239,-126.1444,-126.1649,-126.1853,
                -126.2058,-126.2262,-126.2467,-126.2671,-126.2876,-126.3080,-126.3284,
                -126.3488,-126.3692,-126.3896,-126.4100,-126.4304,-126.4508,-126.4711,
                -126.4915,-126.5118,-126.5322,-126.5525,-126.5728,-126.5932,-126.6135,
                -126.6338,-126.6541,-126.6744,-126.6839,-126.7052,-126.7265,-126.7477,
                -126.7690,-126.7903,-126.8115,-126.8328,-126.8540,-126.8752,-126.8965,
                -126.9177,-126.9389,-126.9601,-126.9813,-127.0025,-127.0237,-127.0448,
                -127.0660,-127.0872,-127.1083,-127.1295,-127.1506,-127.1718,-127.1929,
                -127.2009,-127.2207,-127.2405,-127.2603,-127.2801,-127.2999,-127.3197,
                -127.3395,-127.3593,-127.3791,-127.3988,-127.4186,-127.4383,-127.4581,
                -127.4778,-127.4975,-127.5173,-127.5370,-127.5567,-127.5764,-127.5961,
                -127.6157,-127.6354,-127.6551,-127.6747,-127.6912,-127.7102,-127.7292,
                -127.7481,-127.7671,-127.7861,-127.8051,-127.8240,-127.8430,-127.8619,
                -127.8808,-127.8998,-127.9187,-127.9376,-127.9565,-127.9754,-127.9943,
                -128.0132,-128.0321,-128.0509,-128.0698,-128.0886,-128.1075,-128.1263,
                -128.1452,-128.1640,-128.1828,-128.2016,-128.2204,-128.2392,-128.2580,
                -128.2768,-128.2955,-128.3143,-128.3330,-128.3518,-128.3705,-128.3893,
                -128.4080,-128.4267,-128.4454,-128.4641,-128.4828,-128.5015,-128.5202,
                -128.5389,-128.5575,-128.5762,-128.5948,-128.6135,-128.6321,-128.6507,
                -128.6694,-128.6880,-128.7066,-128.7252,-128.7438,-128.7624,-128.7809,
                -128.7995,-128.8181,-128.8366,-128.8552,-128.8670,-128.8846,-128.9022,
                -128.9197,-128.9373,-128.9548,-128.9723,-128.9899,-129.0074,-129.0249,
                -129.0424,-129.0599,-129.0774,-129.0949,-129.1124,-129.1287)
# latitude
US.CAN.lat <- c(49.00206,49.00207,48.83122,48.76710,48.69399,48.54871,48.45351,48.42283,
                48.28402,48.22455,48.24000,48.29667,48.49345,48.49345,48.49721,48.50096,
                48.50284,48.50430,48.50576,48.50590,48.50516,48.50442,48.50368,48.50367,
                48.50206,48.50044,48.49895,48.49534,48.49200,48.49200,48.48891,48.48248,
                48.47604,48.46960,48.46895,48.46080,48.45265,48.45256,48.44617,48.43647,
                48.42675,48.41704,48.40732,48.39760,48.38787,48.37814,48.36841,48.35867,
                48.35550,48.35550,48.34893,48.33918,48.33756,48.33142,48.32527,48.31912,
                48.31296,48.30680,48.30590,48.29900,48.29211,48.28521,48.27830,48.27139,
                48.26448,48.25756,48.25063,48.24370,48.23677,48.22983,48.22289,48.21595,
                48.20900,48.20204,48.19508,48.18812,48.18451,48.17512,48.16572,48.15632,
                48.14692,48.13752,48.12811,48.11870,48.10928,48.09986,48.09044,48.08101,
                48.07158,48.06214,48.05270,48.04326,48.03382,48.02437,48.01491,48.00546,
                47.99600,47.98653,47.97706,47.96759,47.95812,47.94864,47.93916,47.92967,
                47.92018,47.91069,47.90119,47.89169,47.88219,47.87268,47.86317,47.85365,
                47.84414,47.83461,47.82509,47.82062,47.81214,47.80366,47.79517,47.78668,
                47.77819,47.76969,47.76119,47.75269,47.74418,47.73567,47.72715,47.71863,
                47.71010,47.70158,47.69304,47.68451,47.67597,47.66742,47.65887,47.65032,
                47.64177,47.63321,47.62464,47.61607,47.61284,47.60296,47.59307,47.58319,
                47.57330,47.56340,47.55351,47.54360,47.53370,47.52379,47.51388,47.50397,
                47.49405,47.48413,47.47420,47.46428,47.45434,47.44441,47.43447,47.42453,
                47.41458,47.40464,47.39468,47.38473,47.37477,47.36645,47.35592,47.34540,
                47.33487,47.32433,47.31379,47.30325,47.29271,47.28216,47.27161,47.26106,
                47.25050,47.23994,47.22938,47.21882,47.20825,47.19767,47.18710,47.17652,
                47.16594,47.15535,47.14477,47.13418,47.12358,47.11299,47.10239,47.09178,
                47.08118,47.07057,47.05995,47.04934,47.03872,47.02810,47.01747,47.00684,
                46.99621,46.98558,46.97494,46.96430,46.95366,46.94301,46.93236,46.92171,
                46.91105,46.90039,46.88973,46.87907,46.86840,46.85773,46.84705,46.83638,
                46.82570,46.81501,46.80433,46.79364,46.78295,46.77225,46.76155,46.75085,
                46.74014,46.72944,46.71873,46.70801,46.70117,46.68971,46.67824,46.66677,
                46.65530,46.64383,46.63236,46.62088,46.60940,46.59791,46.58642,46.57494,
                46.56344,46.55195,46.54045,46.52966)

# create map



# plot with GGplot and add movement
cplot <- c(
  "USA","Canada",'Mexico'
)
# Retrievethe map data
cplot <- map_data("world", region = cplot)

df.border <- data.frame(x = US.CAN.lon, y = US.CAN.lat)

cplot <- cplot[-which(cplot$long> -100),]
cplot <- cplot[-which(cplot$long< -135),]

cplot <- cplot[-which(cplot$lat> 70),]
cplot <- cplot[-which(cplot$lat< 20),]

pmap <- ggplot(cplot, aes(x = long, y = lat)) +
  geom_polygon(aes( group = group), fill = 'gray', color = 'black')+
  coord_cartesian(xlim = c(-134,-115), ylim = c(30,52))+
  theme_classic()+
  geom_line(data = df.border, aes(x=x,y= y), linetype = 2, col ='black', size = 1.5)+
  scale_x_continuous('Longitude')+
  scale_y_continuous('Latitude')+
  geom_curve(aes(x= -129, y = 34, xend = -130,yend = 48), col = 'black',
               arrow = arrow(length = unit(0.03, "npc"), ends = 'both'), curvature = -0.15)+
  geom_curve(aes(x= -128, y = 48, xend = -126,yend = 34), col = 'black',
             arrow = arrow(length = unit(0.03, "npc")), curvature = -0.15)+
  annotate(geom="text", x=-120, y=51, label="CAN", color="black")+
  annotate(geom="text", x=-120, y=47, label="USA", color="black")+
  geom_ellipse(aes(x0 = -127, y0 = 32, a = 5, b = 2, angle = 0), fill = alpha('gray', alpha = 0.1), linetype = 0)+
  geom_ellipse(aes(x0 = -129, y0 = 49, a = 1.5, b = 0.7, angle = 0), fill = alpha('gray', alpha = 0.1), linetype = 0)+
#  annotate(geom='text', x = -127, y = 32, label = 'spawning', color ='black')+
  annotate(geom='text', x = -133, y = 40, label = 'Quarterly\nmovement', color ='black', angle = 90)+
  annotate(geom='text', x = -127.5, y = 40, label = 'end of year\nreturn', color ='black', angle = 90)+
  annotate(geom='text', x = -127, y = 32, label = 'spawning', color ='black')

#
pmap


png(filename = 'results/Climate/hakedistribution.png', width = 8, height = 16, units = 'cm', res = 400)
pmap
dev.off()


pdf(file = 'results/Climate/Publication/Figure1.pdf', width = 8/2.54, height = 16/2.54)
pmap
dev.off()
nissandjac/PacifichakeMSE documentation built on March 28, 2022, 12:26 p.m.