I am trying to plot the area of Ossetes in Georgia. This works fine, the following code:
setwd("/my/path/")
library(sp)
library(maps)
library(maptools)
library(ggplot2)
library(rgdal)
greg <- readOGR("../GlobalData/GREG/", "GREG",
verbose = TRUE, stringsAsFactors = FALSE)
borders <- readOGR("/path/to/cshapes/", "cshapes",
verbose = TRUE, stringsAsFactors = FALSE)
georgia <- borders[borders$COWCODE == 372,]
ossetes <- greg[greg$G1ID == 849,]
georgia.df <- fortify(georgia)
ossetes.df <- fortify(ossetes)
tblisi <- georgia@data # access data from the shapefile from here
tblisi["group"] <- 91.1
p <- ggplot(georgia.df, aes(x = long, y = lat, group = group)) +
geom_polygon(aes(x=long,y=lat,group=group), fill="white", colour="grey") +
# Add capital city
geom_point(data=tblisi,aes(CAPLONG,CAPLAT),colour="black",size=4) +
geom_text(data=tblisi, aes(CAPLONG, CAPLAT, label=CAPNAME),hjust=1, vjust=-0.6) +
# Add Ossetes
geom_path(data = ossetes.df, aes(x=long,y=lat,group=group), fill="white", colour="grey") +
# Styling
labs(x=" ", y=" ") +
theme_bw() +
theme(panel.grid.minor=element_blank(), panel.grid.major=element_blank()) +
theme(axis.ticks = element_blank(), axis.text.x = element_blank(), axis.text.y = element_blank()) +
theme(panel.border = element_blank())
p
returns the following graph:
What I would like to do is show only the area of Ossetes in Georgia. But I have currently no idea how to supress the area that is outside of the country borders (the part straight up from Tblisi, parted by the countryborder).
Any ideas on how I could do this?