Package ‘arcgisbinding’
July 11, 2016
Version 1.0.0.121
Date 2016-07-11
Title Bindings for ArcGIS
Author Esri
Maintainer Esri
NeedsCompilation no
Description This package provides classes for loading, converting and exporting Ar-
cGIS datasets and layers in R
Depends R (>= 3.2.0)
Imports methods
Suggests sp
License Apache License 2.0
URL http://esri.com
OS_type windows
Archs i386, x64
.
.
.
.
.
.
.
R topics documented:
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
arc.check_product .
.
arc.data2sp .
.
.
arc.dataset-class .
arc.env .
.
.
arc.fromP4ToWkt .
arc.fromWktToP4 .
arc.open .
.
arc.progress_label .
.
arc.progress_pos
.
.
arc.select
.
arc.shape
.
.
.
.
arc.shape-class
.
arc.shape2sp .
.
.
arc.shapeinfo .
arc.sp2data
.
.
.
arc.write .
.
arcgisbinding .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
.
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
.
.
.
.
.
.
.
.
2
3
3
4
5
6
6
8
9
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Index
16
1
2
arc.check_product
arc.check_product
ArcGIS product and license information
Description
Initialize connection to ArcGIS. Any script running directly from R (i.e. without being called
from a Geoprocessing script) should first call arc.check_product to create a connection with
ArcGIS. Provides installation details on the version of ArcGIS installed that arcgisbinding can
communicate with.
Usage
arc.check_product()
Details
Returned details include:
• Product: ArcGIS Desktop (i.e. ArcMap), or ArcGIS Pro. The name of the product connected
to.
• License level: Basic, Standard, or Advanced are the three licensing levels available. Each
provides progressively more functionality within the software. See the "Desktop Functionality
Matrix" link for details.
• Build number: The build number of the release being used. Useful in debugging and when
creating error reports.
• DLL: The dynamic linked library (DLL) in use allowing ArcGIS to communicate with R.
References
ArcGIS Desktop Functionality Matrix
Note
Additional license levels are available on ArcGIS Desktop: Server, EngineGeoDB, and Engine.
These license levels are currently unsupported by this binding.
Examples
info <- arc.check_product()
info$license # ArcGIS license level
info$version # ArcGIS build number
info$app # product name
info$dll # binding DLL in use
arc.data2sp
3
arc.data2sp
Convert an arc.dataframe object to an sp SpatialDataFrame object
Description
Convert an ArcGIS data.frame to the equivalent sp data frame type. The output types that can be
generated: SpatialPointsDataFrame, SpatialLinesDataFrame, or SpatialPolygonsDataFrame.
Usage
arc.data2sp(x)
Arguments
x
Examples
data.frame result of arc.select
require(sp)
d <- arc.open(system.file("extdata", "ca_ozone_pts.shp",
package="arcgisbinding"))
df <- arc.select(d, ’ozone’)
sp.df <- arc.data2sp(df)
## Not run: spplot(sp.df)
arc.dataset-class
Class "arc.dataset"
Description
arc.dataset S4 class
Details
The dataset_type slot possible values are described in the referenced "dataset properties – data
type" documentation. For feature datasets, extent contains four double values: (xmin, ymin, xmax, ymax).
The fields slot includes the details of the ArcGIS data types of the relevant fields, which include
data types not directly representable in R.
Slots
path file path or layer name
dataset_type dataset type
extent spatial extent of the dataset
fields list of field names
shapeinfo geometry information (see arc.shapeinfo)
References
1. ArcGIS Help: Dataset properties – dataset type
arc.env
4
Examples
ozone.file <- system.file("extdata", "ca_ozone_pts.shp",
package="arcgisbinding")
d <- arc.open(ozone.file)
names(d@fields) # get all field names
d@shapeinfo
d
# print shape info
# print dataset info
arc.env
Get geoprocessing environment settings
Description
Geoprocessing environment settings are additional parameters that affect a tool’s results. Instead,
they are values configured in a separate dialog box, and interrogated and used by the script when
run.
Usage
arc.env()
Details
The geoprocessing environment can control a variety of attributes relating to where data is stored,
the extent and projection of analysis outputs, tolerances of output values, and parallel processing,
among other attributes. the default location for geoprocessing tool inputs and outputs. See the topics
listed under "References" for details on the full range of environment settings that Geoprocessing
scripts can utilize.
References
• ArcGIS Help: What is a geoprocessing environment setting?
• ArcGIS Help: Setting geoprocessing environments
Note
• This function is only available from within an ArcGIS session. Usually, it is used to get local
Geoprocessing tool environment settings within the executing tool.
• This function can only read current geoprocessing settings. Settings, such as the current
workspace, must be configured in the calling Geoprocessing script, not within the body of
the R script.
Examples
## Not run:
tool_exec <- function(in_para, out_params)
{
env = arc.env()
wkspath <- env$workspace
...
return(out_params)
}
arc.fromP4ToWkt
## End(Not run)
5
arc.fromP4ToWkt
Convert PROJ.4 Coordinate Reference System string to Well-known
Text.
Description
The arc.fromP4ToWkt command converts a PROJ.4 coordinate reference system (CRS) string to a
well-known text (WKT) representation. Well-known text is used by ArcGIS and other applications
to robustly describe a coordinate reference system. Converts PROJ.4 stings which include either the
’+proj’ fully specified projection parameter, or the ’+init’ form that takes well-known IDs (WKIDs),
such as EPSG codes, as input.
Usage
arc.fromP4ToWkt(proj4)
Arguments
proj4
Details
PROJ.4 projection string
The produced WKT is equivalent to the ArcPy spatial reference exported string:
arcpy.Describe(layer).SpatialReference.exportToString()
References
1. OGC specification 12-063r5
2. ArcGIS Help: What are map projections?
Note
The ’+init’ method currently only works with ArcGIS Pro.
See Also
arc.fromWktToP4
Examples
arc.fromP4ToWkt("+proj=eqc") # Equirectangular
arc.fromP4ToWkt("+proj=latlong +datum=wgs84") # WGS 1984 geographic
arc.fromP4ToWkt("+init=epsg:2806") # initalize based on EPSG code
6
arc.open
arc.fromWktToP4
Convert a Well-known Text Coordinate Reference System into a
PROJ.4 string.
Description
Convert a well-known text (WKT) coordinate reference system (CRS) string to a PROJ.4 represen-
tation. PROJ.4 strings were created as a convenient way to pass CRS information to the command-
line PROJ.4 utilities, and have an expressive format. Alternatively, can accept a well-known ID
(WKID), a numeric value that ArcGIS uses to specify projections. See the ’Using spatial refer-
ences’ resource for lookup tables which map between WKIDs and given projection names.
Usage
arc.fromWktToP4(wkt)
Arguments
wkt
References
WKT projection string, or a WKID integer
1. ArcGIS REST API: Using spatial references
2. OGC specification 12-063r5
3. ArcGIS Help: What are map projections?
See Also
arc.fromP4ToWkt
Examples
d <- arc.open(system.file("extdata", "ca_ozone_pts.shp",
package="arcgisbinding"))
arc.fromWktToP4(d@shapeinfo$WKT)
arc.fromWktToP4(4326) # use a WKID for WGS 1984, a widely
# used standard for geographic coordinates
arc.open
Open dataset, table, or layer
Description
Open ArcGIS datasets, tables and layers. Returns a new arc.dataset-class object which contains
details on both the spatial information and attribute information (data frame) contained within the
dataset.
7
arc.open
Usage
arc.open(path)
Arguments
path
Value
file path or layer name
An arc.dataset object
Supported Formats
• Feature Class: A collection of geographic features with the same geometry type (i.e. point,
line, polygon) and the same spatial reference, combined with an attribute table. Feature classes
can be stored in a variety of formats, including: files (e.g. Shapefiles), Geodatabases, compo-
nents of feature datasets, and as coverages. All of these types can be accessed using the full
path of the relevant feature class (see note below on how to specify path names).
• Layer: A layer references a feature layer, but also includes additional information necessary
to symbolize and label a dataset appropriately. arc.open supports active layers in the current
ArcGIS session, which can be addressed simply by referencing the layer name as it is dis-
played within the application. Instead of referencing file layers on disk (i.e. .lyr and .lyrx
files), the direct reference to the actual dataset should be used.
• Table: Tables are effectively the same as data frames, containing a collection of records (or
observations) organized in rows, with columns storing different variables (or fields). Feature
classes similarly contain a table, but include the additional information about geometries lack-
ing in a standalone table. When a standalone table is queries for its spatial information, e.g.
arc.shape(table), it will return NULL. Table data types include formats such as text files,
Excel spreadsheets, dBASE tables, and INFO tables.
References
• What is the difference between a shapefile and a layer file?
• ArcGIS Help: What is a layer?
• ArcGIS Help: What are tables and attribute information?
Note
Paths must be properly quoted for the Windows platform. There are two styles of paths that work
within R on Windows:
• Doubled backslashes, such as: C:\\Workspace\\archive.gdb\\feature_class.
• Forward-slashes such as: C:/Workspace/archive.gdb/feature_class.
Network paths can be accessed with a leading \\\\host\share or //host/share path. To access
tables and data within a Feature Dataset, reference the full path to the dataset, which follows the
structure: ///. So
for a table called table1 located in a feature dataset fdataset within a Geodatabase called data.gdb,
the full path might be: C:/Workspace/data.gdb/fdataset/table1
See Also
arc.dataset-class
8
Examples
arc.progress_label
ozone.file <- system.file("extdata", "ca_ozone_pts.shp",
package="arcgisbinding")
d <- arc.open(ozone.file)
cat(’all fields:’, names(d@fields), fill = TRUE) # print all fields
arc.progress_label
Set progressor label for Geoprocessing dialog box
Description
Geoprocessing tools have a progressor, which includes both a progress label and a progress bar.
The default progressor continuously moves back and forth to indicate the script is running. Using
arc.progress_label and arc.progress_pos allows fine control over the script progress. Updat-
ing the progressor isn’t necessary, but is useful in situations where solely outputting messages to
the dialog is insufficient to communicate script progress.
Usage
arc.progress_label(label)
Arguments
label
Details
Progress Label
Using arc.progress_label allows control over the label that is displayed at the top of the running
script. For example, it might be used to display the current step of the analysis taking place.
References
Understanding the progressor in script tools
Note
• Currently only functions in ArcGIS Pro, and has no effect in ArcGIS Desktop.
• This function is only available from within an ArcGIS session, and has no effect when run
from the command line or in background geoprocessing.
See Also
arc.progress_pos, "Progress Messages" example Geoprocessing script
Examples
## Not run:
arc.progress_label("Calculating bootstrap samples...")
## End(Not run)