如何绘制XY点?

How to plot XY points?

如何像 dt 中那样绘制点?

dt <- list(structure(c(30.417963152251, -91.1871239471436), 
                   class = c("XY", "POINT", "sfg")), 
                   structure(c(30.4171489671194, -91.1836263465881), 
                   class = c("XY", "POINT", "sfg")), 
                   structure(c(NA_real_, NA_real_), 
                   class = c("XY", "POINT", "sfg")))

这似乎可行,但我想知道传递 POINT 列表的正确方法是什么:

plot(c(dt[[1]], dt[[2]]))

我更喜欢 sf 中的解决方案,因为那样我需要计算点之间的距离。

使用 sf 包:

dt <- lapply(dt, sf::st_point)

dt <- sf::st_as_sfc(dt)

plot(sf::st_geometry(dt))