Changing the Projection of Shapefile

前提是你 提交于 2019-12-12 08:34:02

问题


I am trying to change or assign the projection of a Germany-Shapefile from NA to +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0, but somehow it doesn't work well.

Reproducible Example: Shapefile and other files can be downloaded here:

What I tried is the following:

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"))

So, the problem is I cannot plot my observations on the map. See below

The ponits were detected using geocode function from ggmap package. Any idea how to change the projection of the shapefile or the projection of the google coordinates would be highly appreciated!


回答1:


I found my mistake. The solution would be:

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)

And the desired output:



来源:https://stackoverflow.com/questions/39979726/changing-the-projection-of-shapefile

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!