The bottom line is that your shapefile seems to be corrupt.
The points shapefile has two main sections, a coords
section that has the coordinates of the points, and a data section that has "attribute" data (information about the points, like region and country in your case). Your shapefile has Lon and Lat in the data section as well, but they don't match:
library(rgdal)
setwd("<directory with shapefile...>")
map <- readOGR(dsn=".", layer="test")
range(map@data$Lat)
# [1] -54.48708 70.66344
range(map@coords[,2])
# [1] -5.448708e+01 2.766634e+145
Reprojection involves transforming the information in the coords
section, which is why it failed.
Here is a workaround, but hacking the SpatialPointsDataFrame is not a good idea:
map@coords <- as.matrix(map@data[c("Lon","Lat")])
map@bbox <- rbind(range(map@coords[,1]),range(map@coords[,2]))
wgs.84 <- "+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"
proj4string(map) <- CRS(wgs.84)
library(ggplot2)
gg <- data.frame(map@coords)
ggplot(gg) +
geom_point(aes(x=Lon,y=Lat), size=1, alpha=0.5, colour="blue") +
coord_fixed()
mercator <- "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs"
map.mercator <- spTransform(map,CRS=CRS(mercator))
gg <- data.frame(map.mercator@coords)
ggplot(gg) +
geom_point(aes(x=Lon,y=Lat), size=1, alpha=0.5, colour="green") +
coord_fixed()
I'd recommend you re-create the shapefile and try again.