ggplot2 中的经度和纬度显示不正确
Longitude and latitude do not show correctly in ggplot2
我现在正尝试在 ggplot2
中绘制加拿大地图,但我发现经度和纬度在地图上显示不正确。有什么解决办法吗?非常感谢。
arcgis shapfile 下载自https://www.arcgis.com/home/item.html?id=dcbcdf86939548af81efbd2d732336db
library(ggplot2)
library(rgdal)
countries<-readOGR("Canada.shp", layer="Canada")
ggplot()+geom_polygon(data=countries,aes(x=long,y=lat,group=group),fill='white',color = "black")
地图上的经度应该是110W、100W、90W。地图中的纬度应该是 50N、60N、70N。不过暂时不是这样。
坐标不是经纬度:
> summary(countries)
Object of class SpatialPolygonsDataFrame
Coordinates:
min max
x -2314694.5 3093025
y 321591.9 4811137
Is projected: TRUE
proj4string :
[+proj=aea +lat_1=50 +lat_2=70 +lat_0=40 +lon_0=-96 +x_0=0 +y_0=0
+datum=NAD83 +units=m +no_defs +ellps=GRS80 +towgs84=0,0,0]
它们是"aea",这是具有给定参数的阿尔伯斯等面积。
要转换为经纬度,请使用 spTransform
和投影 "epsg:4326" 转换为 WGS84 经纬度,如 GPS 系统中所用。
> ca = spTransform(countries, "+init=epsg:4326")
> summary(ca)
Object of class SpatialPolygonsDataFrame
Coordinates:
min max
x -141.00301 -52.62028
y 41.91332 83.10832
我现在正尝试在 ggplot2
中绘制加拿大地图,但我发现经度和纬度在地图上显示不正确。有什么解决办法吗?非常感谢。
arcgis shapfile 下载自https://www.arcgis.com/home/item.html?id=dcbcdf86939548af81efbd2d732336db
library(ggplot2)
library(rgdal)
countries<-readOGR("Canada.shp", layer="Canada")
ggplot()+geom_polygon(data=countries,aes(x=long,y=lat,group=group),fill='white',color = "black")
地图上的经度应该是110W、100W、90W。地图中的纬度应该是 50N、60N、70N。不过暂时不是这样。
坐标不是经纬度:
> summary(countries)
Object of class SpatialPolygonsDataFrame
Coordinates:
min max
x -2314694.5 3093025
y 321591.9 4811137
Is projected: TRUE
proj4string :
[+proj=aea +lat_1=50 +lat_2=70 +lat_0=40 +lon_0=-96 +x_0=0 +y_0=0
+datum=NAD83 +units=m +no_defs +ellps=GRS80 +towgs84=0,0,0]
它们是"aea",这是具有给定参数的阿尔伯斯等面积。
要转换为经纬度,请使用 spTransform
和投影 "epsg:4326" 转换为 WGS84 经纬度,如 GPS 系统中所用。
> ca = spTransform(countries, "+init=epsg:4326")
> summary(ca)
Object of class SpatialPolygonsDataFrame
Coordinates:
min max
x -141.00301 -52.62028
y 41.91332 83.10832