带gbuffer的R中的缓冲区(地理)空间点 [英] Buffer (geo)spatial points in R with gbuffer
问题描述
我正在尝试以100 km的半径缓冲数据集中的点.我正在使用软件包rgeos
中的函数gBuffer
.这是我到目前为止的内容:
I'm trying to buffer the points in my dataset with a radius of 100km. I'm using the function gBuffer
from the package rgeos
. Here's what I have so far:
head( sampledf )
# postalcode lat lon city province
#1 A0A0A0 47.05564 -53.20198 Gander NL
#4 A0A1C0 47.31741 -52.81218 St. John's NL
coordinates( sampledf ) <- c( "lon", "lat" )
proj4string( sampledf ) <- CRS( "+proj=longlat +datum=WGS84" )
distInMeters <- 1000
pc100km <- gBuffer( sampledf, width=100*distInMeters, byid=TRUE )
我收到以下警告:
在gBuffer(sampledf,width = 100 * distInMeters,byid = TRUE)中: 没有投影空间对象; GEOS期望平面坐标
In gBuffer(sampledf, width = 100 * distInMeters, byid = TRUE) : Spatial object is not projected; GEOS expects planar coordinates
根据我的理解/阅读,我需要更改坐标参考系统(CRS), 特别是数据集从地理"到投影"的投影. 我不确定如何更改此设置.这些都是加拿大的地址,我可能会补充. 因此,NAD83在我看来似乎是一个自然的选择,但我可能是错的.
From what I understand/read, I need to change the Coordinate Reference System (CRS), in particular the projection, of the dataset from 'geographic' to 'projected'. I'm not sure sure how to change this. These are all Canadian addresses, I might add. So NAD83 seems to me a natural projection to choose but I may be wrong.
任何/所有帮助将不胜感激.
Any/all help would be greatly appreciated.
推荐答案
再进行一点挖掘,事实证明,使用投影的"坐标参考系统就像
With a little bit more digging, it turns out that using a 'projected' coordinates reference system is as simple as
# To get Statscan CRS, see here:
# http://spatialreference.org/ref/epsg/3347/
pc <- spTransform( sampledf, CRS( "+init=epsg:3347" ) )
STATSCAN(适用于加拿大地址)使用的
EPSG3347使用兰伯特保形圆锥投影.请注意,NAD83是不合适的:它是地理"而不是计划的" CRS.缓冲点
EPSG3347, used by STATSCAN (adequate for Canadian addresses), uses a lambert conformal conic projection. Note that NAD83 is inappropriate: it is a 'geographic', rather than a 'projected' CRS. To buffer the points
pc100km <- gBuffer( pc, width=100*distm, byid=TRUE )
# Add data, and write to shapefile
pc100km <- SpatialPolygonsDataFrame( pc100km, data=pc100km@data )
writeOGR( pc100km, "pc100km", "pc100km", driver="ESRI Shapefile" )
这篇关于带gbuffer的R中的缓冲区(地理)空间点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!