R/coords_to_sf.R

Defines functions coords_to_sf

coords_to_sf <- function(coords) {
  if (inherits(coords, "sf")) {
    return(coords)
  }
  if (inherits(coords, "SpatVector")) {
    return(sf::st_as_sf(coords))
  }
  if (is.matrix(coords)) coords <- data.frame(coords)
  if (is.data.frame(coords)) colnames(coords) <- c("x", "y")
  return(sf::st_as_sf(coords, coords = c("x", "y")))
}

Try the wingen package in your browser

Any scripts or data that you put into this service are public.

wingen documentation built on May 29, 2024, 9:59 a.m.