I want to show points on the map. Those points are represented as coordinates (long/lat) and are stored in a data frame as numerics. I'm wondering if I really need to transform numeric coordinates (lon/lat) to sf object of POINT type. I don't know what benefits of such convertion are. In this example I use numeric coordinates from 2 columns and show them on the map:
data(quakes)
leaflet(data = quakes[1:20,]) %>% addTiles() %>%
addMarkers(~long, ~lat)
Here data frame (quakes) is not spatial, lon/lat are numeric. However, I can do exactly the same converting numeric coordinates to sf POINTs, then show them on a map:
coords <- quakes %>%
sf::st_as_sf(coords = c("long","lat"), crs = 4326) %>%
sf::st_geometry()
leaflet(data = coords[1:20,]) %>% addTiles() %>%
addMarkers()
Question is: in case of showing points (markers) on the map - should we convert to spatial objects first or just use numeric columns? What's the point of using POINTs at all if I can do exactly the same using numeric lon/lat? Performance issues?
tm_dots
intmap
rather than the coordinates usingleaflet
. – william3031