#Maryam Nouri-Aiin #MAP CODES rm(list=ls(all=TRUE)) library(ggplot2) library(ggmap) library(maps) library(mapdata) library(stringr) library(dplyr) library(viridis) library(sf) library(tmap) library(tmaptools) library(ggrepel) library(RColorBrewer) require(maps) require(viridis) library(tidyverse) theme_set( theme_void() ) usa <- map_data("usa") w2hr <- map_data("world2Hires") states <- map_data("state") counties <- map_data("county") vt_df <- subset(states, region == "vermont") vt_county <- subset(counties, region == "vermont") vt_subregion <- vt_county$subregion dots <- data.frame(ID = c("HF", "CRN", "MTF", "HG","CW", "AU"), x = c(-73.20430, -72.50000, -72.50000, -73.16200, -73.18568, -72.99638), y = c(44.43087, 43.99000, 44.23000, 44.54188, 44.47596, 44.34676)) dots$group <- 1:6 dots$ID vt_base <- ggplot(data = vt_county, mapping = aes(x = long, y = lat, group = group),labels = TRUE) + geom_path(size=1) + coord_fixed(1.3) + geom_polygon(color = "black", fill = "gray") + theme_bw() #vt_base + theme_nothing() #theme_void() VTMAP <- vt_base + geom_polygon(data = vt_county, fill = NA, color = "black") + geom_polygon(color = "black", fill = "light grey") # get the state border back on top VTMAP1 <- VTMAP + geom_point(data = dots, mapping = aes(x = x, y = y), color = "red", alpha=10, size = 4) VTMAP2 <- VTMAP1 + geom_label_repel( aes(x = x, y = y, label = ID), data=dots, family = 'Times', size = 5, box.padding = 0.2, point.padding = 0.3, segment.color = 'black') + xlab("Longitude") + ylab("Latitude") + + theme_bw() all_states <- map_data("state") vt <- filter(all_states, region =="vermont") USMAP <- ggplot(all_states, aes(x=long, y=lat, group = group)) + geom_polygon(fill="light grey", colour = "black") + geom_polygon(data = vt, aes(x=long, y=lat, group = group),fill="red")+ xlab("Longitude") + ylab("Latitude")+ theme_void() png(file="VTMAP.png", res=600, width=3000, height=4800, pointsize=10) VTMAP2 dev.off() png(file="USMAP.png", res=600, width=6000, height=4300, pointsize=10) USMAP dev.off()