Skip to content

Instantly share code, notes, and snippets.

@mattbk
Created September 5, 2019 17:13
Show Gist options
  • Save mattbk/4cda0eaddd0c8c8b154e51244896812c to your computer and use it in GitHub Desktop.
Save mattbk/4cda0eaddd0c8c8b154e51244896812c to your computer and use it in GitHub Desktop.
Convert sf point set geometry from XY to XYZ using an existing column
add_z <- function(x, z_name){
st_geometry(x) <- st_sfc(st_multipoint(cbind(st_coordinates(x),
x[[z_name]]))) %>%
st_cast("POINT")
return(x)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment