st_buffer 函数与几何图形 sfc_POINT。

huangapple go评论84阅读模式
英文:

st_buffer with geometry sfc_POINT

问题

我正在处理地理空间数据,对于分析的一部分,我需要使用从Excel获取的地区坐标点,并使用st_as_sf将这些数据转换为sf对象。当我尝试在这些点周围设置缓冲区时,我可以使用st_buffer(data_as_sf, 2000)来设置2公里的缓冲区。这在我有几何对象为sfc_MULTIPOLYGON的形状文件中运行良好。但现在我的几何对象是sfc_POINT。在这种情况下,我需要如何设置缓冲区?使用常规的st_buffer方法会起作用吗,还是我需要将其转换为sfc_MULTIPOLYGON

英文:

I'm working with geospatial data and for one part of the analysis I need to use coordinate points of regions that I get from an excel and turn that data into sf object using st_as_sf. When I tried to set a buffer around the points I use st_buffer(data_as_sf, 2000) for a 2km buffer. This was working well with shapefiles where I had the geometry object as sfc_MULTIPOLYGON. But now my geometry object is sfc_POINT. How do I need to set the buffer in this case? Would it work well using regular st_buffer method or do I need to convert it into sfc_MULTIPOLYGON?

答案1

得分: 1

为什么不简单地测试一下?

library(sf)

my_point <- st_sfc(st_point(c(0, 0)))

my_buffer <- st_buffer(my_point, 2000)

class(my_point)
#> [1] "sfc_POINT" "sfc"
class(my_buffer)
#> [1] "sfc_POLYGON" "sfc"

plot(my_buffer, axes = TRUE)
plot(my_point, add = TRUE)

我们可以看到st_buffer正确地创建了一个2,000米的sfc_POLYGON围绕我们的sfc_POINT

创建于2023年02月23日,使用reprex v2.0.2

英文:

Why not simply test it out?

library(sf)

my_point &lt;- st_sfc(st_point(c(0, 0)))

my_buffer &lt;- st_buffer(my_point, 2000)

class(my_point)
#&gt; [1] &quot;sfc_POINT&quot; &quot;sfc&quot;
class(my_buffer)
#&gt; [1] &quot;sfc_POLYGON&quot; &quot;sfc&quot;

plot(my_buffer, axes = TRUE)
plot(my_point, add = TRUE)

st_buffer 函数与几何图形 sfc_POINT。

We can see that st_buffer has correctly created a 2,000m sfc_POLYGON around our sfc_POINT

<sup>Created on 2023-02-23 with reprex v2.0.2</sup>

huangapple
  • 本文由 发表于 2023年2月24日 01:13:23
  • 转载请务必保留本文链接:https://go.coder-hub.com/75548150.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定