您也可以留在基础图形/ggplot 中并使用更好的 shapefile。有many NYC shapefiles(这只是少数)。我抓住了自治市的边界:
library(sp)
library(rgdal)
library(rgeos)
library(ggplot2)
library(ggthemes)
url <- "http://www.nyc.gov/html/dcp/download/bytes/nybb_15b.zip"
fil <- basename(url)
if (!file.exists(fil)) download.file(url, fil)
fils <- unzip(fil)
nyc <- readOGR(fils[1], ogrListLayers(fils[1])[1], stringsAsFactors=FALSE)
# base
plot(nyc, lwd=0.5, asp=1)
# ggplot2
# simplifying the polygons speeds up ggplot2 a bit
nyc_map <- fortify(gSimplify(nyc, 0.05))
gg <- ggplot()
gg <- gg + geom_map(data=nyc_map, map=nyc_map,
aes(x=long, y=lat, map_id=id),
color="black", fill="white", size=0.25)
gg <- gg + coord_equal()
gg <- gg + theme_map()
gg
该特定 shapefile 是预先投影的,因此您只需要确保绘图的纵横比为 1:1。
其他 shapefile 提供不同级别的详细信息。