######################################################################################### ################################ Grand Cayman map ####################################### ######################################################################################### # objective: GC map # Author: Jack Johnson (jackvjohnson@hotmail.com) # Date created: April 2023 # Last edited: # clear workspace rm(list=ls()) ######################################################################################### #################################### Set up ############################################# library(tidyverse) library(fishualize) library(patchwork) library(sf) library(ggmap) library(ggsn) library(ggspatial) library(rnaturalearth) library(rnaturalearthdata) ######################################################################################### ################################ working directories #################################### data_wd <- "C:/Users/jackv/OneDrive - Central Caribbean Marine Institute, Inc/Projects/Lead by Luca/Banks project/Data files" output_wd <- "C:/Users/CCMI/Desktop/gc_coral_data/output" shapefile_wd <- "C:/Users/jackv/OneDrive - Central Caribbean Marine Institute, Inc/Shapefiles/Cayman Islands" ######################################################################################### ################################## map of sites ######################################### setwd(shapefile_wd) grand_coord <- c(-81.478113, 19.20, -81.031176, 19.438963) site <- c("Lighthouse Point", "La Mesa", "Roundabout", "Ghost Mountain") lat <- c(19.374341, 19.32168, 19.38443, 19.403375) lon <- c(-81.432961, -81.39308, -81.31839, -81.372718) co_ord_df <- data.frame(site, lat, lon) gc_map <- st_read("cym_admbnda_adm0_2020.shp") gc_map gc_map <- st_transform(gc_map, crs = 4326) p_map <- ggplot() + geom_sf(data=gc_map, fill = "white") + coord_sf(xlim=c(-81.478113,-81.031176), ylim=c(19.20,19.438963), expand = T) + geom_point(data = co_ord_df, aes(x = lon, y = lat), size = 3) + geom_text(aes(x=lon, y=lat, label=site), data=co_ord_df, hjust=+.5, vjust = -1, size = 8) + annotation_scale() + annotation_north_arrow(location = "tr", which_north = "true", pad_x = unit(34, "cm"), pad_y = unit(19.5, "cm") , height = unit(2, "cm"), width = unit(2, "cm") , style = north_arrow_fancy_orienteering) + theme_classic() + xlab("") + ylab("") + theme(axis.title.x = element_text(size = 22, color = "black"), axis.title.y = element_text(size = 22, color = "black"), text=element_text(size=16)) + theme(axis.text.y = element_text(size=18, color="black"), axis.text.x = element_text(size=18, color="black", angle = 0, vjust = .0)) + theme(legend.position = "none") + theme(panel.background = element_rect(fill = "#5ECFFA")) + theme(panel.border= element_rect(colour = "black", linewidth =1, fill =NA)) p_map # trim a world map to show the wider Caribbean region ocean <- ne_download(type = "ocean", category = "physical", scale = "medium") ocean <- st_as_sf(ocean) p_map2 <- ggplot() + geom_sf(data = ocean, fill = "#5ECFFA") + coord_sf(xlim=c(-92.478113,-62.031176), ylim=c(8.8,27), expand = T) + annotation_scale() + #annotation_north_arrow(location = "tr", which_north = "true", # height = unit(1, "cm"), width = unit(1, "cm") , # style = north_arrow_fancy_orienteering) + theme_classic() + xlab("") + ylab("") + theme(panel.background = element_rect(fill = "white")) + geom_rect(aes(xmin = -82.25, xmax = -80.2, ymin = 18.25, ymax = 20.25), color = "black", fill = NA, linewidth = 1) + annotate("text", x=-78, y=15, label = "Caribbean Sea", size = 8) + theme(axis.title.x = element_text(size = 22, color = "black"), axis.title.y = element_text(size = 22, color = "black"), text=element_text(size=16)) + theme(axis.text.y = element_text(size=18, color="black"), axis.text.x = element_text(size=18, color="black", angle = 0, vjust = .0)) + theme(plot.background = element_rect(colour = "black", linewidth =2)) + theme( plot.background = element_blank(), panel.grid.major = element_blank(), panel.grid.minor = element_blank(), panel.border = element_rect(colour = "black", linewidth =1, fill =NA), axis.text.x=element_blank(), axis.ticks.x=element_blank(), axis.text.y=element_blank(), axis.ticks.y=element_blank() ) #theme( # panel.background = element_rect(fill='transparent'), #transparent panel bg # plot.background = element_rect(fill='transparent')) p_map2 ######################################################################################### ########################## combine plots using patchwork ################################ png(file=file.path(output_wd,'inset_map.png'),height=4000,width=6000,res=350) p_map + inset_element(p_map2, 0.6,-0.05,1.025,0.4, align_to = "panel", on_top = T) dev.off() tiff(file=file.path(output_wd,'inset_map.tif'),height=4000,width=6000,res=350) p_map + inset_element(p_map2, 0.6,-0.05,1.025,0.4, align_to = "panel", on_top = T) dev.off() #png(file=file.path(output_wd, "Maps_and_stacked_bars_FIGURE.png"), height = 5000, width = 9000, res=350) #(p_map + p_map2 + plot_layout(ncol=2, widths = c(2, 1))) / (p_benthic_stacked + p_coral_stacked + p_fishtrophic_stacked) + #plot_layout(heights=c(2,1)) + plot_annotation(tag_levels = 'A') & # theme(plot.tag = element_text(size = 50)) #dev.off() #tiff(file=file.path(output_wd, "Maps_and_stacked_bars_FIGURE.tif"), height = 5000, width = 9000, res=350) #(p_map + p_map2 + plot_layout(ncol=2, widths = c(2, 1))) / (p_benthic_stacked + p_coral_stacked + p_fishtrophic_stacked) + #plot_layout(heights=c(2,1)) + plot_annotation(tag_levels = 'A') & # theme(plot.tag = element_text(size = 50)) #dev.off()