改变形状文件的投影 [英] Changing the Projection of Shapefile

查看:55
本文介绍了改变形状文件的投影的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将德国形状文件的投影从 NA 更改或分配到 +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0,但不知何故它不能正常工作.

可重现的示例:Shapefile 和其他文件可以在使用 ggmap 包中的 geocode 函数检测 ponits.任何想法如何更改 shapefile 的投影或谷歌坐标的投影将不胜感激!

解决方案

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

mapG <- readOGR("vg2500_lan.shp", layer="vg2500_lan")摘要(地图G)gerg <- spTransform(mapG, CRS("+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"))情节(germG,轴= T)

以及所需的输出:

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!

解决方案

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:

这篇关于改变形状文件的投影的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆