【发布时间】:2012-04-01 21:21:24
【问题描述】:
我想在带有 wgs84 坐标的 line-shapefile 周围创建一个缓冲区。
我准备了一个带有单个线段和基准的 shapefile:D_WGS_1984。 之后,我使用“readOGR”命令将 .shp 加载到 R 中。
之后我尝试了 rgeos-package 中的 gBuffer 方法来计算缓冲区:
gBuffer(l2, width=1.0, quadsegs=5, capStyle="ROUND", joinStyle="ROUND", mitreLimit=0.01))
Warning:
In gBuffer(l2, width = 1, quadsegs = 5, capStyle = "ROUND", joinStyle = "ROUND", :
Spatial object is not projected; GEOS expects planar coordinates
显然该命令的坐标有问题。我尝试了一些方法,但没有找到解决方案。
我为点周围的缓冲区找到的另一个示例如下,但我不确定在我的情况下如何使用它: http://r-sig-geo.2731867.n2.nabble.com/compute-buffer-from-point-shapefile-to-have-shapefile-td4574666.html
有什么想法吗?
最好的问候, 斯蒂芬
//更新:
精简到相关部分,代码如下:
require("rgeos")
require("rgdal")
l2=readOGR(dsn="C:/Maps", layer="osm_ms")
proj4string(l2) <- CRS("+proj=longlat")
l2.trans <- spTransform(l2, CRS("+proj=longlat"))
summary(l2.trans)
> Object of class SpatialLinesDataFrame
> Coordinates:
> min max
> x 7.478942 7.772171
> y 51.840318 52.058856
> Is projected: FALSE
> proj4string : [+proj=longlat +ellps=WGS84]
> Data attributes:
plot(l2.trans)
plot(gBuffer(l2.trans, width=1.0, quadsegs=5, capStyle="ROUND", joinStyle="ROUND", mitreLimit=0.01))
大概是这样的:
预计:FALSE 是问题的原因,但我不确定如何使用 spTranform 以及如何找到正确的投影。
【问题讨论】:
-
告诉我们你尝试了什么,对我们不知道你已经做了什么,除了你做了什么。