Skip to content
Prev 397187 / 398500 Next

Save spatial data in a csv file

As Hasan suggested, much more information is needed. It would be very helpful to know the class of nyc_ct_geo, and how it was created. It is possibly an sf object from the print output.
library(sf)
nc <- st_read(system.file("gpkg/nc.gpkg", package="sf"))
tf <- tempfile(fileext=".csv")
st_write(nc_geom, tf, driver="CSV", layer_options=c("GEOMETRY=AS_WKT"))
file.show(tf)

With more than 2000 polygon objects in your case, this is hardly a sensible way to write geometries to file, and depends on the person receiving the file having software that can convert WKT back to geometries. For more details on the CSV driver for st_write, please see https://gdal.org/en/stable/drivers/vector/csv.html#vector-csv

Maybe following up on the R-sig-geo list would be helpful if clarification is needed.

Roger

--
Roger Bivand
Emeritus Professor
Norwegian School of Economics
Postboks 3490 Ytre Sandviken, 5045 Bergen, Norway
Roger.Bivand at nhh.no