I've got a map in ggplot (made up of geom_polygon, lines, points and segments). The original was in WGS, with all units in degrees lat/lon. All of the additional data (for lines and points) are also in degrees. I want to retransform the entire thing into an equal-area projection (Mollweide). The first step (transforming the underlying rworldmap polygon) was fairly painless, although there are some odd horizontal lines running through. However, I'm not sure how to tackle the next step. As I said, all the data are in degrees, and I want to specify xlim/ylim, axes labels and (curved) gridlines in degrees. Will I have to convert everything into Mollweide meters, or is it somehow possible to just reshape my final map object in one painless step?
This is what i have so far, to demonstrate these weird horizontal lines.
library(rworldmap)
library(rgdal)
library(ggplot2)
moll_crs<-CRS("+proj=moll +R=10567000 +lon_0=0 +x_0=0 +y_0=0 +units=m +towgs84=0,0,0,0,0,0,0 +no_defs")
ggplot() +
geom_polygon(data = spTransform(getMap(resolution = 'low'), CRSobj = moll_crs),
aes(x = long,
y = lat,
group = group),
fill = 'gray90',
colour = 'gray10',
size = 0.3) +
coord_fixed()
This results in horizontal lines.
EDIT:
Following @hrbmstr 's answer, I'm using his GeoJSON file with coord_map("molleweide")
:
ggplot() +
geom_map(data=world, map=world,
aes(x=long, y=lat, map_id=id),
fill="gray90", color="gray10", size=0.3) +
coord_map("mollweide",
xlim = c(-50, 40))
The xlim
argument is messing things up though, adding in horizontal lines. I thought the coord_***(xlim)
arguments just changed the viewable area, but it seems to be affecting how the map is drawn. Any ideas?