
aRcGeo
aRcGeo.RmdInstalling aRcGeo
You can install the development version of aRcGeo from
GitHub with:
# install.packages("devtools")
devtools::install_github("HarunCelikOtto/aRcGeo")Once installed, load the library with:
library(aRcGeo)
#> The functions in this library require the user to have `arcgisbinding` loaded.
#> Please load `library(arcgisbinding)` before running any aRcGeo functions.The first time the library is loaded, you should receive a message
asking you to have the package arcgisbinding loaded
already. This is because the functions verifying ArcGIS licenses in
aRcGeo use the arcgisbinding package.
Initializing an ArcGIS Connection
The main purpose of the aRcGeo package is to provide a
streamlined process for initializing a connection to ArcGIS and
importing the arcpy python module at the same time. This is
achieved using the aRcGeo::init_arcpy() function.
init_arcpy() takes one of two string arguments.
conda_env = "conda environment name"python_env_path = "string path to python.exe"
Since all installations of arcpy in ArcGIS Pro use a
conda environment, it is easiest to supply the conda environment name as
the conda_env argument.
You can check the name of your conda environment using
reticulate::conda_list().
# List your conda environments with Reticulate
# install.packages("reticulate")
reticulate::conda_list() |>
as.list() |>
magrittr::extract2(1)[1] "base"
[2] "Python_Image_Processing"
[3] "arcgispro-py3-DeepLearning"
[4] "r-miniconda"
[5] "r-reticulate" Calling init_arcpy()
After confirming the name of the conda environment where
arcpy exists, we can call init_arcpy() to
initialize an ArcGIS connection:
aRcGeo::init_arcpy(conda_env = "arcgispro-py3-DeepLearning")Output:
-- Initializing Connection ---------------------------------------------------------------------
> Initializing Connection to ArcGIS.
-- Checking Conda Environment ---------------------------------------------------------------------
i All Local Conda Environments:
[1] "base"
[2] "Python_Image_Processing"
[3] "arcgispro-py3-DeepLearning"
[4] "r-miniconda"
[5] "r-reticulate"
v Using conda environment: arcgispro-py3-DeepLearning
v An `arcpy` module successfully imported.
i ArcGIS Product Details:
$license
[1] "Advanced"
$version
[1] "13.1.0.41833"
$path
[1] "C:\\Program Files\\ArcGIS\\Pro\\"
$dll
[1] "rarcproxy_pro"
$app
[1] "ArcGIS Pro"
$pkg_ver
[1] "1.0.1.300"Examples of arcpy Functionality
If the function call completed without an error, then the user should
now see arcpy as a module in their R Environment. This
means that all of the functionality of arcpy can now be
used in an R session.
Here is a basic call to the ListEnvironments() function
in arcypy.
arcpy$ListEnvironments()Output:
[1] "autoCommit" "XYResolution"
[3] "processingServerUser" "gpuId"
[5] "XYDomain" "processingServerPassword"
[7] "scratchWorkspace" "recycleProcessingWorkers"
[9] "cartographicPartitions" "terrainMemoryUsage"
[11] "MTolerance" "compression"
[13] "coincidentPoints" "baUseDetailedAggregation"
[15] "timeZone" "randomGenerator"
[17] "outputCoordinateSystem" "rasterStatistics"
[19] "transferGDBAttributeProperties" "ZDomain"
[21] "cellSizeProjectionMethod" "maintainCurveSegments"
[23] "transferDomains" "S100FeatureCatalogueFile"
[25] "maintainAttachments" "resamplingMethod"
[27] "snapRaster" "cartographicCoordinateSystem"
[29] "baNetworkSource" "configKeyword"
[31] "matchMultidimensionalVariable" "outputZFlag"
[33] "qualifiedFieldNames" "tileSize"
[35] "annotationTextStringFieldLength" "parallelProcessingFactor"
[37] "pyramid" "referenceScale"
[39] "processingServer" "extent"
[41] "unionDimension" "XYTolerance"
[43] "daylightSaving" "tinSaveVersion"
[45] "nodata" "MDomain"
[47] "cellSize" "outputZValue"
[49] "outputMFlag" "cellAlignment"
[51] "geographicTransformations" "ZResolution"
[53] "mask" "processorType"
[55] "maintainSpatialIndex" "preserveGlobalIds"
[57] "workspace" "retryOnFailures"
[59] "MResolution" "baDataSource"
[61] "ZTolerance" "scratchGDB"
[63] "scratchFolder" "packageWorkspace"
[65] "scriptWorkspace" "addOutputsToMap"
[67] "buildStatsAndRATForTempRaster" "autoCancelling"
[69] "isCancelled" "overwriteOutput"