# NOT RUN {
## write as a shapefile
fc <- arc.open(system.file("extdata", "ca_ozone_pts.shp", package="arcgisbinding"))
d <- arc.select(fc, 'ozone')
d[1,] <- 0.6
arc.write(tempfile("ca_new", fileext=".shp"), d)
## create and write to a new file geodatabase
fgdb_path <- file.path(tempdir(), "data.gdb")
data(meuse, package="sp")
## create feature dataset 'meuse'
arc.write(file.path(fgdb_path, "meuse\\pts"), data=meuse, coords=c("x", "y", "elev"), shape_info=list(type='Point',hasZ=TRUE,WKID=28992))
data(meuse.riv, package="sp")
riv <- sp::SpatialPolygons(list(sp::Polygons(list(sp::Polygon(meuse.riv)),"meuse.riv")))
## write only geometry
arc.write(file.path(fgdb_path, "meuse\\riv"), coords=riv)
## write as table
arc.write(file.path(fgdb_path, "tlb"), data=list('f1'=c(23,45), 'f2'=c('hello', 'bob')))
## from scratch as feature class
arc.write(file.path(fgdb_path, "fc_pts"), data=list('data'=rnorm(100)),
coords=list(x=runif(100,min=0,max=10),y=runif(100,min=0,max=10)),
shape_info=list(type='Point'))
## write Raster
# make SpatialPixelsDataFrame
data(meuse.grid, package="sp")
sp::coordinates(meuse.grid) = c("x", "y")
sp::gridded(meuse.grid) <- TRUE
meuse.grid@proj4string=sp::CRS(arc.fromWktToP4(28992))
arc.write(file.path(fgdb_path, "meuse_grid"), meuse.grid)
## write using a RasterLayer object
r <- raster::raster(ncol=10, nrow=10)
raster::values(r) <- runif(raster::ncell(r))
arc.write(file.path(fgdb_path, "raster"), r)
# }
Run the code above in your browser using DataLab