[R-sig-Geo] Error when saving an sf (data) object to file as a shapefile

Lom Navanyo |omn@v@@|@ @end|ng |rom gm@||@com
Sat Jun 20 10:43:44 CEST 2020


Hello,

I have had to merge a shapefile that I read into R as an sf object with a
.csv data containing  some variables. Now I want to save the merged data to
a file (a folder on my pc). I am however getting following error:

Error in CPL_write_ogr(obj, dsn, layer, driver,
as.character(dataset_options),  :
  Write error

Below is a snippet of code used:
library(sf)
library(dplyr)
library(ggplot2)
library(stringr)
library(rgdal)
library(sp)

parcel1 <- st_read("parcels_all.shp")
balance5 <- read.csv("Balanced_5.csv")

mergedparcel <- merge(parcel1, balance5, by=c('PARCEL_ID','CAL_YEAR'),
all.x = FALSE, all.y=TRUE)

st_write(mergedparcel,"mergedparcel.shp")

I also used the shapefile function thus:

shapefile(mergedparcel , "D:/Documents/mergedparcel.shp")
 This also gives me:
Error in shapefile(mergedparcel, "D:/Documents/
Documents/mergedparcel.shp") :
  could not find function "shapefile"

Am I doing this right?
Any suggestion to resolve this issue would be appreciated.

-----------------
Lom

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list