【问题标题】:Changing the Projection of Shapefile更改 Shapefile 的投影
【发布时间】:2017-02-20 03:23:30
【问题描述】:

我正在尝试将 Germany-Shapefile 的投影从 NA 更改或指定为 +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0,但不知何故无法正常工作。

可重现的示例: shapefile等文件可以下载here:

我尝试的是以下内容:

library(maptools)
library(sp)
library(rgeos)
library(rgdal)
projection.x <- CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0")
mapG <- readShapePoly("vg2500_lan.shp", verbose=TRUE, proj4string=projection.x)
summary(mapG)
mapG <- spTransform(mapG, CRS("+proj=longlat +ellps=WGS84 +datum=WGS84"))

所以,问题是我无法在地图上绘制我的观察结果。见下文

使用 ggmap 包中的 geocode 函数检测到这些 ponits。 任何想法如何更改 shapefile 的投影或谷歌坐标的投影将不胜感激!

【问题讨论】:

    标签: r projection shapefile sp


    【解决方案1】:

    我发现了我的错误。解决方案是:

    mapG <- readOGR("vg2500_lan.shp", layer="vg2500_lan")
    summary(mapG)
    germG <- spTransform(mapG, CRS("+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"))
    plot(germG, axes=T)
    

    以及所需的输出:

    【讨论】:

    • 您的数据链接不再起作用。你能提供一个带有 dput 的样本吗?
    猜你喜欢
    • 2014-10-07
    • 2017-02-17
    • 1970-01-01
    • 2019-02-24
    • 1970-01-01
    • 1970-01-01
    • 2016-11-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多