我想用wgs84坐标在line-shapefile周围创建一个缓冲区.
我准备了一个包含单个线段和Datum的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
Run Code Online (Sandbox Code Playgroud)
显然命令的坐标有问题.我尝试了一些方法,但没有找到解决方案.
我找到的关于点周围缓冲区的另一个例子如下,但我不确定如何在我的情况下使用它:http: //r-sig-geo.2731867.n2.nabble.com/compute-buffer-from -点-shape文件到有-shape文件,td4574666.html
有任何想法吗?
最好的问候,Stefan
//更新:
减少到相关部分,这里是代码:
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 …Run Code Online (Sandbox Code Playgroud)