Skip to content

Instantly share code, notes, and snippets.

@ajjitn
Last active October 11, 2021 19:12
Show Gist options
  • Save ajjitn/d299ad9f1c920b0f58aa7b973ea6997f to your computer and use it in GitHub Desktop.
Save ajjitn/d299ad9f1c920b0f58aa7b973ea6997f to your computer and use it in GitHub Desktop.
Convert shapefile to CSV
library(sf)
library(tidyverse)
# Read in shapefile
geo_data <- st_read(
dsn = "/path/to/shapefile.shp"
)
# Write out as CSV with X,Y columns for lon/lat respectively
st_write(obj = geo_data,
dsn = "/path/to/output.csv",
layer_options = "GEOMETRY=AS_XY")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment