我想使用 Terra::buffer 在一系列点周围创建 x 米的缓冲区,并保留原始矢量对象(例如点)属性。
或者,一旦我的缓冲区没有属性,我如何合并这些数据集。就像传统 GIS 中按位置合并一样。
创建一些具有属性的示例点数据
library(terra)
f <- system.file("ex/lux.shp", package="terra")
v <- vect(f)
set.seed(1)
p <- spatSample(v, 5)
p
# class : SpatVector
# geometry : points
# dimensions : 5, 6 (geometries, attributes)
# extent : 5.962628, 6.351843, 49.59884, 49.86376 (xmin, xmax, ymin, ymax)
# coord. ref. : lon/lat WGS 84 (EPSG:4326)
# names : ID_1 NAME_1 ID_2 NAME_2 AREA POP
# type : <num> <chr> <num> <chr> <num> <int>
# values : 1 Diekirch 3 Redange 259 18664
# 3 Luxembourg 11 Mersch 233 32112
# 2 Grevenmacher 6 Echternach 188 18899
1000米缓冲区
b <- buffer(p, 1000)
b
# class : SpatVector
# geometry : polygons
# dimensions : 5, 6 (geometries, attributes)
# extent : 5.94872, 6.365734, 49.58985, 49.87275 (xmin, xmax, ymin, ymax)
# coord. ref. : lon/lat WGS 84 (EPSG:4326)
# names : ID_1 NAME_1 ID_2 NAME_2 AREA POP
# type : <num> <chr> <num> <chr> <num> <int>
# values : 1 Diekirch 3 Redange 259 18664
# 3 Luxembourg 11 Mersch 233 32112
# 2 Grevenmacher 6 Echternach 188 18899