I am trying to add an ESRI shapefile (.shp) to the ggmap graph of the state of North Carolina, which has the following code:
x <- get_map(location="North Carolina", zoom=6, maptype="terrain")
ggmap(x) + geom_polygon(data=citylim83.df, aes(x=long, y=lat), fill="red", alpha=0.2)
The form file that I downloaded and strengthened in citylim83.df
. Here is the code used to upload the shapefile to ggplot:
epsgs <- make_EPSG() citylim <- readOGR(dsn=".", layer="MunicipalBoundaries_polys")`
MunicipalBoundaries projection units, after performing an EPSG search, are ft-US for the state system. Although this .shp has a NAD83 geographic coordinate system, I also want to project it onto NAD83 to get rid of the state system (the EPSG code for NAD83 (UTM-17N) is 26917):
citylim83 <- spTransform(citylim, CRS("+init=epsg:26917")) summary(citylim83) Object of class SpatialPolygonsDataFrame Is projected: TRUE [+init=epsg:26917 +proj=utm +zone=17 +ellps=GRS80 +datum=NAD83 +units=m citylim83.df <- fortify(citylim83)
This data frame was then used in the ggmap code shown above.
Despite the fact that now it is definitely projected into NAD83, it still will not appear on the basis of ggmap. What is the basic projection of the get_map object that I imported? Is there a command to find this so that I can map my map to the shapefile that I want to display on top of it? Should I "unproject" my citylim object? The FYI shapefile is the city limit for each municipality in North Carolina, if not clear. Any help would be greatly appreciated, as I am very new to the ggplot2 / ggmap community.
source share