arc.write | R Documentation |
Export a data
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. If data
is raster-like object,
this function writes a raster dataset. See ‘Details’ section for more information.
arc.write(path, data, ..., overwrite = FALSE)
path |
full output path |
data |
Accepts input source objects (see ‘Details’ for the types of objects allowed). |
... |
Additional arguments:
|
overwrite |
overwrite existing dataset. default |
Export to a new table dataset when data
type is:
named list
of vectors (see Example #4)
data.frame
Export to a new feature dataset when data
type is:
arc.data
result of arc.select
named list
of vectors, parameters coords
and shape_info
are required (see Example #5)
data.frame
, parameters coords
and shape_info
are required (see Example #2)
SpatialPointsDataFrame
in package sp
SpatialLinesDataFrame
in package sp
SpatialPolygonsDataFrame
in package sp
sf
, sfc
in package sf
Export to a new raster dataset when data
type is:
arc.raster
result of arc.raster
SpatialPixels
, SpatialPixelsDataFrame
in package sp (see Example #6)
SpatialGrid
in package sp
RasterLayer
in package raster (see Example #7)
RasterBrick
in package raster
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
To write Date column type corresponding data
column must have
POSIXct
type (see Example #4).
arc.open
,
arc.select
,
arc.raster
## Example #1. write 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")
## Example #2. 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")))
## Example #3. write only geometry
arc.write(file.path(fgdb_path, "meuse\\riv"), coords=riv)
## Example #4. write a table
t <- Sys.time() # now
arc.write(file.path(fgdb_path, "tlb"), data=list(
'f_double'=c(23,45),
'f_string'=c('hello', 'bob'),
'f_datetime'=as.POSIXct(c(t, t - 3600)) # now and an hour ago
))
## Example #5. 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'))
## Example #6. 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)
## Example #7. 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.