arcgisbinding (version 1.0.1.229)

arc.write: Write dataset, raster, feature, table or layer

Description

Export a data.frame object to an ArcGIS dataset. If the data frame includes a spatial attribute, this function writes a feature dataset. If no spatial attribute is found, a table is instead written. Export a arc.raster, raster::RasterLayer or raster::RasterBrick object to an ArcGIS raster dataset.

Arguments

path

full output path

data

input source. Accepts data.frame, spatial data.frame, SpatialPointsDataFrame, SpatialLinesDataFrame, and SpatialPolygonsDataFrame, arc.raster, raster::RasterLayer, raster::RasterBrick objects.

Optional parameters

  • coords list containing geometry. Accepts Spatial objects. Put field names if data is data.frame and consists coordinates.

  • shape_info required argument if data has no spatial attribute

  • overwrite overwrite existing dataset. default = FALSE.

Details

Supports a variety of output formats. Below are pairs of example paths and the resulting data types:

  • C:/place.gdb/fc: File Geodatabase Feature Class

  • C:/place.gdb/fdataset/fc: File Geodatabase Feature Dataset

  • in_memory\logreg: In-memory workspace (must be run in ArcGIS Session)

  • C:/place.shp: Esri Shapefile

  • C:/place.dbf: Table

  • C:/place.gdb/raster: File Geodatabase Raster when data parameter is arc.raster or Raster* object

  • C:/image.img: ERDAS Imaging

  • C:/image.tif: Geo TIFF

References

See Also

arc.dataset-class, arc.open, arc.raster

Examples

Run this code
# 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