Skip to main content
1 of 2
Simbamangu
  • 14.9k
  • 7
  • 60
  • 93

You need to make a spatial points object and then reproject that:

library(sp)
library(maptools)
data(wrld_simpl)
wrld_simpl.trans <- spTransform(wrld_simpl, CRS = ("+proj=moll +lon_0=0 +x_0=0 +y_0=0"))
plot(wrld_simpl.trans, col = 'lightgray'))
latitudes <- c(-30, 0, 20, 50)
longitudes <- c(-20, 10, 50, 80)

Make an SPDF:

pts <- data.frame(latitudes, longitudes)
coordinates(pts) <- ~longitudes+latitudes
proj4string(pts) <- CRS(paste("+init=epsg:4326"))

Project and plot it:

pts.trans <- spTransform(pts, CRS = ("+proj=moll +lon_0=0 +x_0=0 +y_0=0"))
points(pts.trans, cex = 1.5, col = 'red', pch = 19)

enter image description here

# Compare to unprojected
plot(wrld_simpl, col = 'lightgray')
points(pts, cex = 1.5, col = 'red', pch = 19)

enter image description here

Simbamangu
  • 14.9k
  • 7
  • 60
  • 93