Description Usage Arguments Details Value Author(s) Examples
View source: R/rpygeo_reticulate.R
This function loads the output of an ArcPy function into the R session. Raster files are loaded as raster objects and vector files as sf objects.
| 1 | 
| data | 
 | 
Currently files and datasets stored in file geodatabases are supported.
Supported file formats:
Tagged Image File Format (.tif)
Erdas Imagine Images (.img)
Esri Arc/Info Binary Grid (.adf)
Esri ASCII Raster (.asc)
Esri Shapefiles (.shp)
Supported datasets:
Feature Class
Raster Dataset
Esri has not released an API for raster datasets in file geodatabases. rpygeo_load converts a raster dataset to a temporary ASCII raster first and then loads it into the R session. Be aware that this can take a long time for large raster datasets.
This function can be used with the %>% operator from the dplyr package. The %>% operator forwards the reticulate object from the ArcPy function to rpygeo_load (s. Example 1). If used without the %>% operator an reticulate object can be specified for the data parameter (s. Example 2). It is also possible to use the filename of the ArcPy function output (s. Example 3). For Arc/Info Binary Grids the data parameter is just the name of the directory, which contains the adf files.
raster or sf object
Marc Becker
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | ## Not run: 
# Load packages
library(RPyGeo)
library(magrittr)
library(RQGIS)
library(spData)
# Get data
data(dem, package = "RQGIS")
data(nz, package = "spData")
# Write data to disk
writeRaster(dem, file.path(tempdir(), "dem.tif"), format = "GTiff")
st_write(nz, file.path(tempdir(), "nz.shp"))
# Load the ArcPy module and build environment
arcpy <- arcpy_build_env(overwrite = TRUE, workspace = tempdir())
# Create a slope raster and load it into the R session (Example 1)
slope <-
  arcpy$Slope_3d(in_raster = "dem.tif", out_raster = "slope.tif") %>%
  rpygeo_load()
# Create a aspect raster and load it into the R session (Example 2)
ras_aspect <- arcpy$sa$Aspect(in_raster = "dem.tif")
rpygeo_load(ras_aspect)
# Convert elevation raster to polygon shapefile and load it into R session (Example 3)
arcpy$RasterToPolygon_conversion("dem.tif", "elev.shp")
rpygeo_load("elev.shp")
## End(Not run)
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.