######################################### #Run Arc Python commands from R! #OR use R to launch Python Scripts. ######################################### #http://zevross.com/blog/2019/11/12/using-reticulate-with-arcpy-on-a-windows-machine/ #https://developers.arcgis.com/python/guide/appending-features/ #https://blog.rstudio.com/2018/03/26/reticulate-r-interface-to-python/ ######################################### # Install reticulate package #install.packages("reticulate") ######################################### # Load reticulate package library(reticulate) #32 bit ArcMap python... #use_python('C:\\Python27\\ArcGIS10.7\\python.exe', required = T) ######################################### #I am on 64 bit ArcPro python. #C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3 use_python('C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\python.exe', required = T) py_available(TRUE) os <- import("os") setwd("C:/data") ############### ############### # To expose functions for publishing feature classes and interacting with portal and AGOL. #arcgis <- import("arcgis") ############### # To expose arcpy functions. arcpy <- import("arcpy") ############### #Works! yahooo! arcpy$Buffer_analysis("C:/data/north.shp", "C:/data/buffer.shp", "500 METERS") #not sure if these are needed. py_run_string(arcpy.env.workspace = "C:/data/") outLocation = "C:/data" #Works! Run a Python file fromR py_run_file("C:/data/append.py") #Execute python command in R. Works Too!!!! arcpy$Append_management(c("north.shp", "south.shp"), "out.shp", "NO_TEST") ################# #there are other ways to do this. #py_run_string(arcpy$Append_management(c("north.shp", "south.shp"), "out.shp", "NO_TEST") )