2

I am trying to follow the tutorial found on http://www.r-bloggers.com/mapping-the-worlds-biggest-airlines/. I am able to plot it following the tutorial, but I would also like to convert to Robinson projection. I have noticed there might be an error with the ne_10m_populated_places.shp after doing the readOGR command. Could someone please help me to figure out what I must do with spatial shapes?

library(ggplot2)
library(maps)
library(rgeos)
library(maptools)
gpclibPermit()
library(rgdal)

worldmapin<- readShapePoly("ne_10m_admin_0_countries.shp")
worldmap_ogr <- readOGR(".", "ne_10m_admin_0_countries")
worldRobinson <- spTransform(worldmap_ogr, CRS("+proj=robin +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs"))

urbanareasin<- readShapePoly("ne_10m_urban_areas.shp")
urbanareas_ogr <- readOGR(".", "ne_10m_urban_areas")
urbanareasRobinson <- spTransform(urbanareas_ogr, CRS("+proj=robin +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs"))
simp<- gSimplify(urbanareasRobinson, 10, topologyPreserve=T)
urbanareas<-fortify(simp)

placesin<- readShapeSpatial("ne_10m_populated_places")
placesin_ogr <- readOGR(".", "ne_10m_populated_places")
placesinRobinson <- spTransform(placesin_ogr, CRS("+proj=robin +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs"))

base<- ggplot(worldmapin)
wrld<-c(geom_polygon(aes(long,lat,group=group), size = 0.1, colour= "#090D2A", fill="#FFFFFF", alpha=1, data=worldmap))urb<- c(geom_polygon(aes(long,lat,group=group), size = 0.1, colour= "#FCFFF1", fill="#FCFFF1", alpha=1, data=urbanareas))
places<-geom_text(data=placesinRobinson, aes(LONGITUDE, LATITUDE, label = NAME), size=1)

base+wrld+urb+places
4

0 回答 0