简体   繁体   中英

How to plot XY points?

How do I plot points like those in 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")))

This seems to work but I wondered what is the correct way to pass a list of POINT :

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

在此处输入图片说明

I would prefer a solution in sf because then I need to calculate distances between points.

Using sf package:

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

dt <- sf::st_as_sfc(dt)

plot(sf::st_geometry(dt))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM