Giter Club home page Giter Club logo

r-bridge's Introduction

R-integration for ArcGIS Pro and Desktop

Requirements

Latest R Core for Windows (http://cran.r-project.org/bin/windows/base/)

Official web page https://r-arcgis.github.io/

Installation

> install.packages("arcgisbinding", repos="https://r.esri.com", type="win.binary")

Basic GP Tool R script

tool_exec <- function (in_params, out_params)
{
  value0 <- in_params[[1]]
  print(value0)
# ...
  out_params$output1 <- TRUE
  return (out_params)
}

tool_exec(in_params, out_params) - required main function

Parameters

  • in_params list of all input parameters
  • output_params list of all output and derived parameters

You can get tool parameter value by index in_params[[1]] or by parameter name output_params$output1

Return Value

  • set or update output GP parameters and return output_params.

Using arcgisbinding in standalone R script

> library(arcgisbinding)
> arc.check_product()
> d <- arc.open("c:/mydb.gdb/points")

Build

> git clone https://devtopia.esri.com/r-integration .

Rebuild Visual Studio solution r-integration/src/msprojects/R-bridge.sln

or

> cd r-integration/build/
> build.bat pro debug

or

Production build with Docker image

Build dependencies

r-bridge's People

Contributors

dpavlushko avatar hhkaos avatar orhuna avatar scw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

r-bridge's Issues

Arc crashes when exporting large datasets to R

I created a custom script tool using the following R script to export data from Arc to R using the 64-bit background processing. Unfortunately, Arc crashes when I use large files (>1.5 or 2 Gb). To remedy this problem, I've had to export the files in chunks. Would be great if I could export things all at once.

R-script

tool_exec <- function(in_params, out_params)
{
    library(data.table)

    print(getwd())
    print(in_params)
    
    fcpath     <- in_params[[1]]      
    outvarname <- in_params[[2]]
    outfile    <- in_params[[3]]

    # fields
    fc <- arc.open(fcpath)
    if (is.null(in_params[[4]])) flds <- names(fc@fields)
    else                         flds <- unlist( in_params[[4]] )

    # output datatype
    outtype <- ifelse( is.null(in_params[[5]]), "dt", in_params[[5]])

    # print stuff
    print(paste("saving", outvarname, "as", outtype, "to", outfile))

    # add where_clause = ""

    # import
    if ( is.null(in_params[[6]]) ) {
        if (outtype != "sp") {
            assign(outvarname, data.table(arc.select(fc, fields=flds)))     
        } else if (outtype == "sp") {
            assign(outvarname, arc.data2sp(arc.select(fc, fields=flds)))
        }
    } else {
        where <- in_params[[6]]
        if (outtype != "sp") {
            assign(outvarname, data.table(arc.select(fc, fields=flds, where_clause=where)))     
        } else if (outtype == "sp") {
            assign(outvarname, arc.data2sp(arc.select(fc, fields=flds, where_clause=where)))
        }           
    }
 
    # save
    save(list=outvarname, file=outfile)
}

Python

The toolbox is called rLinkTbx.tbx. Happy to provide via email if helpful.

import arcpy
import time

arcpy.ImportToolbox(dirProj + "/rLinkTbx.tbx", "mytbx")
strdate = time.strftime("%Y-%m-%d", time.localtime())

arcpy.mytbx.saveToR(
    fcpath = gdb + "/" + fc, 
    objectname = fc, 
    outfile = dirOut + fc + "-" + strdate + ".Rdata", 
    fields = "#")

tool-parameters

tool-help.pdf

Potential bug in arc.env()$workspace READ-ONLY on server deployments

In a Desktop architecture, it seems like arc.env()$workspace can be correctly used as a scratch workspace to write output files. However, when the same R script is published as a GP service and deployed on a Server architecture, arc.env()$workspace becomes READ-ONLY and throws errors (see below) when trying to write to that location:

“Error executing tool. Factor Analysis for Mixed Data Job ID: jac57dc60e745433bb91359a45e0b2bcc : Error in sink : invalid 'description' argument? Failed to execute (FAMD).? Failed to execute (Factor Analysis for Mixed Data)."

message:"Unable to complete operation."

This only happens on a server deployment, as the same script works correctly on Desktop. The function sink() is an R command to write to an output text file.

ERROR 4: Unable to open EPSG support file gcs.csv. Try setting the GDAL_DATA environment variable....

I'm trying to access feature classes from ArcGIS Online and/or from features stored on local file geodatabases. Previously, I could connect to these successfully using R V. 4.0.0 and ArcGIS Pro V. 2.4. I recently upgraded to Pro 2.5.2... but now I get an error, but only with some of my feature classes.

Here's my code that used to work without complaining:

library(arcgisbinding)
arc.check_product()
pilot_locs <- arc.data2sf(arc.select(arc.open("Maps/Basemap/Basemap.gdb/Locations")))

Here's my code + output, including the error that is now occurring:

> library(arcgisbinding)
*** Please call arc.check_product() to define a desktop license.
> arc.check_product()
product: ArcGIS Pro (12.5.0.22081)
license: Advanced
version: 1.0.1.240 
> 
> pilot_locs <- arc.data2sf(arc.select(arc.open("Maps/Basemap/Basemap.gdb/Locations")))

ERROR 4: Unable to open EPSG support file gcs.csv. Try setting the GDAL_DATA environment variable to point to the directory containing EPSG csv files.
ERROR 6: No translation for an empty SRS to PROJ.4 format is known.

> sessionInfo()
R version 4.0.0 (2020-04-24)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362)

Matrix products: default

locale:
[1] LC_COLLATE=English_Canada.1252  LC_CTYPE=English_Canada.1252    LC_MONETARY=English_Canada.1252
[4] LC_NUMERIC=C                    LC_TIME=English_Canada.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] arcgisbinding_1.0.1.240

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.4.6       rstudioapi_0.11    magrittr_1.5       units_0.6-6        tidyselect_1.1.0   R6_2.4.1          
 [7] rlang_0.4.6        dplyr_1.0.0        tools_4.0.0        grid_4.0.0         packrat_0.5.0      KernSmooth_2.23-17
[13] e1071_1.7-3        DBI_1.1.0          ellipsis_0.3.0     class_7.3-17       tibble_3.0.1       lifecycle_0.2.0   
[19] sf_0.9-4           crayon_1.3.4       purrr_0.3.4        vctrs_0.3.0        glue_1.4.0         compiler_4.0.0    
[25] pillar_1.4.4       generics_0.0.2     classInt_0.4-3     pkgconfig_2.0.3   

arc.sp2data() / arc.data2sp() and arc.write() does not correctly convert some spatial references (e.g. EPSG 3857)

Hello all,

I have noticed that when converting an arc.data object to a SpatialPolygonsDataFrame (SPDF) using the arc.data2sp() function the proper spatial reference definition is not always well maintained.

This is then propagated when the SPDF is converted back to an arc.data object or alternatively when it is exported via arc.write() using the SPDF directly.

For example, if I import a geodatabase feature class with EPSG 3857 using arc.open() and check the spatial reference, I get:

"PROJCS["WGS_1984_Web_Mercator_Auxiliary_Sphere",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Mercator_Auxiliary_Sphere"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",0.0],PARAMETER["Standard_Parallel_1",0.0],PARAMETER["Auxiliary_Sphere_Type",0.0],UNIT["Meter",1.0]]"

Upon converting to an SPDF and then back again (or alternatively if I just use arc.write() directly with the SPDF), I will instead get a spatial reference of "Unnamed ellipse Mercator":

"PROJCS["unnamed_ellipse_Mercator_2SP",GEOGCS["GCS_unnamed_ellipse",DATUM["D_unknown",SPHEROID["Unknown",6378137,0]],PRIMEM["Greenwich",0],UNIT["Degree",0.0174532925199433]],PROJECTION["Mercator_2SP"],PARAMETER["standard_parallel_1",0],PARAMETER["central_meridian",0],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["Meter",1]]"

As you cannot convert back to an arc.dataset object and then use arc.select() again to re-project an, it makes it difficult to ensure there is the correct spatial reference data upon exporting back to a geodatabase feature class.

Overall this makes it difficult to properly import, edit, and export geodatabase feature classes. Any advice or solutions would be appreciated!

arc.env() does not grab workspace from GP tool environment settings

I noticed that arc.env()$workspace only grabs workspace from environment settings set up at the ArcGIS Desktop GP menu level, not the GP tool level. Posted on GeoNet as well.

env = arc.env()
wkspath <- env$workspace
#this path does not grab the GP tool environment settings, rather only the GP main menu env settings
print(wkspath)  

Failed to initialize R interpreter with arcgisbinding 1.0.1.241 and Pro 2.6.x script tools

Hi all,

I work for Esri Support Services and I am currently working with a user encountering some issues with the R-ArcGIS bridge post-upgrade. The user upgraded from Pro 2.5.x to 2.6 and also updated the arcgisbinding to the current release, 1.0.1.241. R version is 3.6.3.

Generally Support does not handle R cases, but I wanted to help out the user as much as possible and have reproduced the issue. On Pro 2.6.2 with arcgisbinding 1.0.1.241 and R 3.6.3, attempting to run any R scripts as script tools returns the error message of 'Failed to initialize R interpreter.' Downgrading the library to 1.0.1.239 returns a different error message of 'could not find function 'tool_exec.''

The user reports that their colleagues on Pro 2.4.2 with R versions 3.6.2 and 3.5.0 with arcgisbinding 1.0.1.232 are still able to run R scripts successfully.

Is there anything we are missing with these errors or some configuration we have incorrect?

ArcGIS 10.3.1 --R Sample Tools freezes when using arc.env() call inside tool script

I noticed a strange behavior both in the sample R tools provided and my own custom R tool scripts. When adding the arc.env() function from arcgisbindings to the tool script, execution halts/freezes and does not complete. Is this a bug?

For example, add arc.env() to the semiparam regression tool script to check issue above.

Example:

tool_exec <- function(in_para, out_params)
{
env = arc.env()
wkspath <- env$workspace
...
return(out_params)
}

Quick question regarding sharing a geoprocessing tool that includes arc-r bridge elements

Hi,

I am new to using the Arc-R bridge and have come upon it in my work to build a geoprocessing tool to be shared via a private Portal to my organization. One step in the tool uses an R script which I have successfully turned into an ArcGIS script tool using the bridge functionality, and then incorporated into my ModelBuilder workflow for the geoprocessing tool. The tool runs just fine locally.

Before I share it with the rest of my organization, I want to double check that the R script tool will work in a tool shared via Portal. I might be overthinking this or just flat out wrong about how the bridge works, but my worry is that if another member of my organization were to run the tool within our Portal that the R script would have no R installation to reference, as it seems to do locally on my personal machine. Is this something that will present problems? And, if so, what potential workarounds might I have?

arc.write error with version 1.0.1.231

Previously working code returns an error after updating arcgisbinding package to 1.0.1.231
arc.write("E:\\file.shp", sp_table)
returns

Error in (function (classes, fdef, mtable)  : 
  unable to find an inherited method for function ‘arc.shapeinfo’ for signature ‘"NULL"’

ArcGIS Pro crashes when trying to detect R

Hello,

I'm trying to complete the "Using the R-ArcGIS Bridge" web course through Esri for class. I can't get passed the installing R-ArcGIS Bridge particularly the first part which is this in the training:

"I will navigate to the R-ArcGIS Support options by clicking the Project tab and selecting Options and then view the geoprocessing options."

Every single time I've tried to do this, ArcGIS Pro crashes immediately, and I get this error report:
image

I have R v3.4 and ArcGIS Pro 2.0. I also have RStudio installed. Any help would be appreciated.

Encoding Issue

Hi,

I've got trouble with encoding using arc.write() and the 64bit binding dll of ArcGIS Pro. Here's a minimum example involving shapefiles and attribute data only, but it's the same with FileGDBs:
library(arcgisbinding)
arc.check_product()
options(stringsAsFactors = FALSE)
setwd("D:/GIS/Test")
df.chr <- data.frame("Test" = c("ä", "a", "ß", "s"))
Encoding(df.chr$Test)
arc.write(paste0(getwd(), "/latin1.shp"), df.chr)
df.chr$Test <- enc2utf8(df.chr$Test)
Encoding(df.chr$Test)
arc.write(paste0(getwd(), "/utf8.shp"), df.chr)

This is what I get in both cases:
encoding

I'm using:

  • R version 3.2.3 64bit
  • arcgisbinding v1.0.0.118
  • product: ArcGIS Pro
  • license: Advanced
  • build number: 11.2.0.5023
  • binding dll: rarcproxy_pro

With the 32bit binding dll of ArcGIS Desktop it seems to work though.

Please let me know if you need any additional information.

R 3.5 support

Known current issue: the bridge isn't working with the most recent R 3.5.0 release.

arc.write() won't populate a feature dataset.

Hi all,

I'm not sure if this is an issue, or just me. :)

In the following part of the details section of the arc.write() documentation, it indicates that features can be written to a geodatabase feature dataset, but I can not get this to work.

Supports a variety of output formats. Below are pairs of example paths and the resulting data types:
...
C:/place.gdb/fdataset/fc: File Geodatabase Feature Dataset

When I send a value for a path that is 1 level inside a gdb file (i.e. a feature dataset), my data gets written into the geodatabase (which is awesome), but it is not being written into the desired feature dataset, just within the root of the gdb I'm doing something like:

theGDB = "C:/stuff/mygeodatabase.gdb"
theFD = "fdataset"
thisFeature = "FeatureX"
arc.write(path = paste0(theGDB,"/",theFD,"/",thisFeature), data = spatial_data, coords = list(spatial_data@data$LONG, spatial_data@data$LAT))

I had thought that it had to do with the coordinate system of the feature dataset matching my features, but if I manually drag my created features from the root of the gdb into the feature dataset manually (in ArcCatalog), they go just fine.

The fact that my data is indeed being written gives me confidence that I'm on the right track, but since I want to script the creation of almost 3000 features and use feature datasets to categorize them makes the feature datasets pretty important.

Thanks for any tips or insight.

Support writing text fields which are longer than 255 characters.

As reported by Andrew Gilbert, currently if writing a text field, writing will fail if any of the values exceed 255 characters in length. Here's a quick example, with a String field that'll fit in 1024 characters:

data_type_test.csv

OBJECTID,OBJECTID_1,Shape_Length,StringField,Number,Boolean,LongString
,1,457754.519544604641851,,,TRUE,"This is a very long string, This is a very long string, This is a very long string, This is a very long string, This is a very long string, This is a very long string, This is a very long string, This is a very long string, This is a very long string, This is a very long string, This is a very long string, This is a very long string, This is a very long string, This is a very long string, This is a very long string, This is a very long string, This is a very long string, This is a very long string, This is a very long string, This is a very long string, This is a very long string, This is a very long string, This is a very long string, This is a very long string, This is a very long string, This is a very long string, This is a very long string, This is a very long string, This is a very long string, This is a very long string, This is a very long string, This is a very long string, This is a very long string, This is a very long string, This is a very long string."

Now, try to write this input using arcgisbinding:

library(arcgisbinding)
arc.check_product()

# you'll need to set a location with setwd(), here I use a location with an
# existing `r_test.gdb` file.
# setwd()

d <- arc.open("data_type_test.csv")
dr <- arc.select(d)
arc.write("r_test.gdb/long_string_write", dr)
# fails with:
# Error in .call_proxy("arc_export2dataset", path, data, coords, shape_info) : 
#  The row contains a bad value. [LongString]

I discussed this with @dpavlushko, he said it's because of how we create the output. We basically do this in two steps, initializing an output dataset, and then later writing it. At initialization, we don't know the structure of the data, so it is initialized to the default length for a text field currently.

arc.write looking for multiple gdal dll's

I'm getting the following set of errors when trying to write an sf point data frame to a geodatabase:

ERROR 1: Can't load requested DLL: C:\Program Files\ArcGIS\Pro\bin\gdalplugins\gdal_ECW.dll
126: The specified module could not be found.

ERROR 1: Can't load requested DLL: C:\Program Files\ArcGIS\Pro\bin\gdalplugins\gdal_ECW.dll
126: The specified module could not be found.

ERROR 1: Can't load requested DLL: C:\Program Files\ArcGIS\Pro\bin\gdalplugins\gdal_ECW.dll
126: The specified module could not be found.

ERROR 1: Can't load requested DLL: C:\Program Files\ArcGIS\Pro\bin\gdalplugins\gdal_ECW.dll
126: The specified module could not be found.

ERROR 1: Can't load requested DLL: C:\Program Files\ArcGIS\Pro\bin\gdalplugins\gdal_ECW.dll
126: The specified module could not be found.

ERROR 1: Can't load requested DLL: C:\Program Files\ArcGIS\Pro\bin\gdalplugins\gdal_HDF4.dll
126: The specified module could not be found.

ERROR 1: Can't load requested DLL: C:\Program Files\ArcGIS\Pro\bin\gdalplugins\gdal_HDF4.dll
126: The specified module could not be found.

ERROR 1: Can't load requested DLL: C:\Program Files\ArcGIS\Pro\bin\gdalplugins\gdal_HDF4.dll
126: The specified module could not be found.

ERROR 1: Can't load requested DLL: C:\Program Files\ArcGIS\Pro\bin\gdalplugins\gdal_HDF4.dll
126: The specified module could not be found.

ERROR 1: Can't load requested DLL: C:\Program Files\ArcGIS\Pro\bin\gdalplugins\gdal_HDF4.dll
126: The specified module could not be found.

ERROR 1: Can't load requested DLL: C:\Program Files\ArcGIS\Pro\bin\gdalplugins\gdal_HDF5.dll
126: The specified module could not be found.

ERROR 1: Can't load requested DLL: C:\Program Files\ArcGIS\Pro\bin\gdalplugins\gdal_HDF5.dll
126: The specified module could not be found.

ERROR 1: Can't load requested DLL: C:\Program Files\ArcGIS\Pro\bin\gdalplugins\gdal_HDF5.dll
126: The specified module could not be found.

ERROR 1: Can't load requested DLL: C:\Program Files\ArcGIS\Pro\bin\gdalplugins\gdal_HDF5.dll
126: The specified module could not be found.

ERROR 1: Can't load requested DLL: C:\Program Files\ArcGIS\Pro\bin\gdalplugins\gdal_HDF5.dll
126: The specified module could not be found.

ERROR 1: Can't load requested DLL: C:\Program Files\ArcGIS\Pro\bin\gdalplugins\gdal_JP2KAK.dll
126: The specified module could not be found.

ERROR 1: Can't load requested DLL: C:\Program Files\ArcGIS\Pro\bin\gdalplugins\gdal_JP2KAK.dll
126: The specified module could not be found.

ERROR 1: Can't load requested DLL: C:\Program Files\ArcGIS\Pro\bin\gdalplugins\gdal_JP2KAK.dll
126: The specified module could not be found.

ERROR 1: Can't load requested DLL: C:\Program Files\ArcGIS\Pro\bin\gdalplugins\gdal_JP2KAK.dll
126: The specified module could not be found.

ERROR 1: Can't load requested DLL: C:\Program Files\ArcGIS\Pro\bin\gdalplugins\gdal_JP2KAK.dll
126: The specified module could not be found.

ERROR 1: Can't load requested DLL: C:\Program Files\ArcGIS\Pro\bin\gdalplugins\gdal_JPIPKAK.dll
126: The specified module could not be found.

ERROR 1: Can't load requested DLL: C:\Program Files\ArcGIS\Pro\bin\gdalplugins\gdal_JPIPKAK.dll
126: The specified module could not be found.

ERROR 1: Can't load requested DLL: C:\Program Files\ArcGIS\Pro\bin\gdalplugins\gdal_JPIPKAK.dll
126: The specified module could not be found.

ERROR 1: Can't load requested DLL: C:\Program Files\ArcGIS\Pro\bin\gdalplugins\gdal_JPIPKAK.dll
126: The specified module could not be found.

ERROR 1: Can't load requested DLL: C:\Program Files\ArcGIS\Pro\bin\gdalplugins\gdal_JPIPKAK.dll
126: The specified module could not be found.

ERROR 1: Can't load requested DLL: C:\Program Files\ArcGIS\Pro\bin\gdalplugins\gdal_MG4Lidar.dll
126: The specified module could not be found.

ERROR 1: Can't load requested DLL: C:\Program Files\ArcGIS\Pro\bin\gdalplugins\gdal_MG4Lidar.dll
126: The specified module could not be found.

ERROR 1: Can't load requested DLL: C:\Program Files\ArcGIS\Pro\bin\gdalplugins\gdal_MG4Lidar.dll
126: The specified module could not be found.

ERROR 1: Can't load requested DLL: C:\Program Files\ArcGIS\Pro\bin\gdalplugins\gdal_MG4Lidar.dll
126: The specified module could not be found.

ERROR 1: Can't load requested DLL: C:\Program Files\ArcGIS\Pro\bin\gdalplugins\gdal_MG4Lidar.dll
126: The specified module could not be found.

ERROR 1: Can't load requested DLL: C:\Program Files\ArcGIS\Pro\bin\gdalplugins\gdal_netCDF.dll
126: The specified module could not be found.

ERROR 1: Can't load requested DLL: C:\Program Files\ArcGIS\Pro\bin\gdalplugins\gdal_netCDF.dll
126: The specified module could not be found.

ERROR 1: Can't load requested DLL: C:\Program Files\ArcGIS\Pro\bin\gdalplugins\gdal_netCDF.dll
126: The specified module could not be found.

ERROR 1: Can't load requested DLL: C:\Program Files\ArcGIS\Pro\bin\gdalplugins\gdal_netCDF.dll
126: The specified module could not be found.

ERROR 1: Can't load requested DLL: C:\Program Files\ArcGIS\Pro\bin\gdalplugins\gdal_netCDF.dll
126: The specified module could not be found.

This was working as of 3 months ago and I don't believe I changed anything on my end. Any ideas?

Published GP Process is canceled before it's finished

Steps to reproduce

Publish GP Process with simple R Script.
Just print datetime every 10 seconds.

message("Start")
tool_exec <- function(in_param, out_param)
{

  result = tryCatch({
    
  for (i in 1:1000)
    {      
      date_time<-Sys.time()
      message(i, ": ", date_time)
      while((as.numeric(Sys.time()) - as.numeric(date_time))<10){
      } #dummy while loop
    }


  }, warning = function(w) {
    print(paste("w:  ",w))
  }, error = function(e) {
    print(paste("e:  ",e))
  }, finally = {
    message("finally completed") 
  })

}


Current behaviour (bug)

The script Cancelled before finish.
esriJobMessageTypeAbort: Cancelled script timeoutTest...
esriJobMessageTypeAbort: (timeoutTest) aborted by User.

image

Expected behaviour (correct)

Script should running more than 70 seconds (1 Minute and 10 Seconds)

Testing.

Tested with:

Arcgis server 10.6
CRAN R-3.6.1
R-bridge v1.0.1.239
Published with Arcgis Pro 2.6.0

Also Tested with

Arcgis server 10.6
Microsoft R Open 4.0.2
R-bridge v1.0.1.241
Published with Arcgis Pro 2.6.0

Additional info

As standalone tool inside Arc pro it's working.

arc.open() error in .call_proxy

Hello,

I'm using ArcGIS Desktop 10.5
R 3.4.3 32 bits
arc.open() gives Error in .call_proxy("dataset.open", .Object, path) : cannot open dataset
I have no idea how to fix it. Any help would be appreciated!

Rui

R and RStudio crash when calling arc.check_product()

Hi,

since today both R and RStudio crash when I call arc.check_product() so I cannot access the R-ArcGIS Bridge from R anymore. Any ideas? I work with RStudio 0.99.893 and R3.2.4, I have ArcMap 10.4 and ArcGIS Pro 1.2 installed on Windows 10, and I can access the R-ArcGIS Bridge from ArcGIS for Desktop without any problem.

Thanks, Jan

Will you be building in support for the simple features package?

My agency just got the r-bridge installed and running this week. It will make workflows and the task of documenting them much much better, So thank you for building it.

I'm wondering if you're contemplating building in support for the relatively new simple features package in R. That is, will you be creating arc.sf2sata and arc.data2sf() functions and building in support for sf objects in arc.write()?

Thanks again for your work on this.

arcgisbindings 1.0.1.241 compatibility with R 4.0.2 and ArcGIS 10.7.1

I haven't yet made the transition to ArcPro and recently upgraded R from 3.5 to 4.0.2. The arcgisbindings package was working for me using Desktop 10.7.1 and R 3.5 but stopped working when I upgraded R to v4. I ran the update bindings python script and it appeared to work (shows proper R 4.0.2 folder) but ArcMap keeps throwing "*** Please install ArcGIS R integration package" when I try to run tools that previously worked. I redownloaded the "master.zip" file and reran the update in ArcCatalog but still got the same thing. I also installed the arcgisbinding package in the R console and results from arc.check_product() that reflect 10.7.1 and 1.0.1.241. I can probably get by for a while just using the package in R but I will definitely need to run toolbox tools at some point and prefer not to switch over to ArcPro just yet. How can I get arcgisbindings to work in ArcGIS when the update script says "The installed ArcGIS R package (version 1.0.1.241) is the current version on GitHub"?

R Bridge use with Citrix Receiver hosted ArcGIS Desktop?

Is this possible? Most of my agency accesses Arc remotely, through Citrix. Very few have local installs of either ArcGIS or ArcPro. Is there anyway to use r-bridge with this configuration? Most folks also have ArcGIS online accounts as well. But it is my understanding that you need to run arc.check_product() prior to doing anything else such ase arc.portal_connect().

Setting up the r-bridge with python toolbox

As I understand, running R with the r-bridge is similar to creating a script tool. However, I've come to love the way I can create the GUI for my tools using the python toolbox pyt files. Is there a way to use the r-bridge with the python toolbox approach? I.e. that I define my parameters with arcpy.Parameter() and I run my R-Script in the execute()-Function?

Add ability to detect and delete feature classes

It would be very nice, actually it's really necessary, to have the ability to delete feature classes from a File Geodatabase from R via the r-bridge. It's very tedious to have to do this manually. Also to see if it exists already would be useful alone.

ready for R 4.0?

Tried upgrading to R 4.0 tonight and hit this error when trying to load the bridge library:
Error: package 'arcgisbinding' was built before 4.0.0: please-re-install it

Tried several times without success. Using Arcgis Pro to install the bridge but manual installs from the zip don't seem to work either.

Export of polygons as GDB and SHP yield negative area value

I recently ran into an issue while grabbing some data from a PostGIS database and outputting to FileGDB via arc.write. Several of the exported polygons had a negative area value. As a result, the "Select By Location" tool in ArcMap (10.6.1 in this case) would not select any polygons with a negative area.

Writing these polygons out using sf::st_write, however yielded correct area when brought into ArcMap. Below is a reproducible example:

library(sf)
#> Linking to GEOS 3.6.1, GDAL 2.2.3, PROJ 4.9.3
library(arcgisbinding)
#> *** Please call arc.check_product() to define a desktop license.

arc.check_product()
#> product: ArcGIS Pro ( 12.3.2.15850 )
#> license: Advanced 
#> version: 1.0.1.232

poly_wkt <- "MULTIPOLYGON (((417290.4 3835221, 417291 3835224, 417308.9 3835361, 417309.3 3835364, 417330.8 3835579, 417330.8 3835599, 417326.6 3835619, 417318.5 3835638, 417306.8 3835654, 417235 3835737, 417221.7 3835750, 417206.2 3835760, 417189.1 3835767, 417171 3835771, 417152.6 3835771, 417134.3 3835768, 417117 3835762, 417101 3835752, 417058.9 3835722, 416710.1 3835692, 416702 3835691, 416275.4 3835619, 416255.5 3835614, 416237.2 3835604, 416221.2 3835591, 416208.2 3835575, 416107.8 3835421, 416098.7 3835404, 416093.2 3835384, 416091.6 3835365, 416094 3835345, 416100.1 3835326, 416109.9 3835309, 416122.9 3835294, 416138.6 3835282, 416156.4 3835273, 416175.6 3835268, 416410.6 3835230, 416811.9 3834851, 416876.4 3834603, 416883.2 3834584, 416893.6 3834567, 416907.2 3834553, 416923.3 3834541, 417041.6 3834473, 417058.3 3834466, 417076.2 3834461, 417094.7 3834460, 417113 3834462, 417130.5 3834468, 417328.6 3834552, 417619.8 3834432, 417637 3834426, 417654.9 3834424, 417672.8 3834425, 417862.9 3834454, 417879.6 3834458, 417951.5 3834482, 418093.6 3834387, 418098.1 3834384, 418291.7 3834269, 418309.2 3834261, 418327.8 3834257, 418347.1 3834256, 418366.2 3834258, 418384.4 3834265, 418401 3834274, 418415.5 3834287, 418427.3 3834302, 418436 3834319, 418441.1 3834338, 418442.7 3834357, 418440.5 3834376, 418434.7 3834395, 418189.4 3834971, 418116.4 3835210, 418081.2 3835351, 418074.8 3835369, 418065 3835386, 418052.3 3835400, 418037.1 3835412, 418019.9 3835421, 418001.4 3835426, 417982.3 3835427, 417963.3 3835425, 417870.8 3835405, 417866 3835404, 417755.8 3835375, 417754.4 3835374, 417658.9 3835347, 417529 3835310, 417525.1 3835309, 417390.3 3835265, 417380.5 3835261, 417290.4 3835221)), ((420559.2 3835138, 420548.8 3835160, 420533.4 3835179, 420362.3 3835342, 420340.4 3835358, 420266.5 3835398, 420243.8 3835407, 420108.7 3835441, 420099.7 3835443, 419858.3 3835481, 419840.7 3835482, 419823.2 3835480, 419697.1 3835455, 419678 3835449, 419660.3 3835439, 419645 3835426, 419632.5 3835411, 419568.5 3835311, 419562.5 3835300, 419495.9 3835161, 419489.2 3835142, 419486.2 3835123, 419487.1 3835103, 419491.8 3835084, 419500.2 3835066, 419540.8 3834998, 419552.2 3834983, 419566.4 3834970, 419582.8 3834960, 419600.9 3834953, 419620 3834950, 419639.3 3834950, 419658.1 3834955, 419675.8 3834962, 419873 3835074, 419941.7 3835085, 420042.2 3835006, 420053.4 3834998, 420284 3834863, 420303.8 3834854, 420325 3834850, 420512.3 3834832, 420532.1 3834832, 420551.5 3834836, 420569.8 3834844, 420586.1 3834855, 420600 3834869, 420610.8 3834886, 420618 3834904, 420621.5 3834924, 420621.1 3834944, 420616.8 3834963, 420559.2 3835138)), ((418861.2 3835143, 418852.2 3835139, 418844.1 3835135, 418837 3835128, 418831.2 3835121, 418826.8 3835113, 418824.2 3835103, 418823.3 3835094, 418823.3 3835047, 418823.9 3835039, 418825.9 3835032, 418860.3 3834928, 418875.5 3834820, 418810.4 3834797, 418799.4 3834792, 418730.8 3834747, 418547.6 3834663, 418538.8 3834657, 418531.2 3834650, 418525.2 3834642, 418521 3834633, 418518.8 3834623, 418518.8 3834612, 418520.8 3834602, 418524.9 3834593, 418530.8 3834584, 418538.3 3834577, 418627.9 3834509, 418635.7 3834504, 418644.2 3834501, 418653.2 3834499, 418662.3 3834499, 418671.3 3834501, 418896.4 3834562, 418933.6 3834529, 418942.3 3834523, 418952.1 3834519, 418962.5 3834517, 418973.1 3834517, 418983.4 3834520, 419162.7 3834585, 419171.4 3834589, 419179.2 3834594, 419185.8 3834602, 419190.8 3834610, 419194.1 3834619, 419195.7 3834628, 419206.4 3834801, 419206 3834811, 419203.4 3834821, 419198.8 3834830, 419001.6 3835142, 418995.2 3835150, 418987.1 3835157, 418977.9 3835162, 418967.9 3835165, 418957.5 3835166, 418947.2 3835164, 418861.2 3835143)))"

poly <- st_as_sfc(poly_wkt, crs = 26912)
st_area(poly)
#> 2531992 [m^2]

arc.write(paste0("test_poly.gdb/", "test_poly"), poly)  # yields -2531992.2 m2
arc.write("test_poly.shp", poly)  # yields -2531992.2 m2

st_write(poly, "test_poly_from_sf.shp")  # yields 2531992.2 m2
#> Writing layer `test_poly_from_sf' to data source `test_poly_from_sf.shp' using driver `ESRI Shapefile'
#> features:       1
#> fields:         0
#> geometry type:  Multi Polygon

Created on 2019-08-14 by the reprex package (v0.2.0).

Session info
devtools::session_info()
#> - Session info ----------------------------------------------------------
#>  setting  value                       
#>  version  R version 3.5.3 (2019-03-11)
#>  os       Windows 10 x64              
#>  system   x86_64, mingw32             
#>  ui       RTerm                       
#>  language (EN)                        
#>  collate  English_United States.1252  
#>  ctype    English_United States.1252  
#>  tz       America/Phoenix             
#>  date     2019-08-14                  
#> 
#> - Packages --------------------------------------------------------------
#>  package       * version   date       lib source                       
#>  arcgisbinding * 1.0.1.232 2018-07-12 [1] local                        
#>  assertthat      0.2.1     2019-03-21 [1] CRAN (R 3.5.3)               
#>  backports       1.1.3     2018-12-14 [1] CRAN (R 3.5.2)               
#>  callr           3.2.0     2019-03-15 [1] CRAN (R 3.5.3)               
#>  class           7.3-15    2019-01-01 [2] CRAN (R 3.5.3)               
#>  classInt        0.2-3     2018-04-16 [1] CRAN (R 3.5.1)               
#>  cli             1.1.0     2019-03-19 [1] CRAN (R 3.5.3)               
#>  crayon          1.3.4     2017-09-16 [1] CRAN (R 3.5.1)               
#>  DBI             1.0.0     2018-05-02 [1] CRAN (R 3.5.1)               
#>  desc            1.2.0     2018-05-01 [1] CRAN (R 3.5.1)               
#>  devtools        2.0.1     2018-10-26 [1] CRAN (R 3.5.3)               
#>  digest          0.6.18    2018-10-10 [1] CRAN (R 3.5.2)               
#>  e1071           1.7-0     2018-07-28 [1] CRAN (R 3.5.1)               
#>  evaluate        0.12      2018-10-09 [1] CRAN (R 3.5.2)               
#>  fs              1.2.7     2019-03-19 [1] CRAN (R 3.5.3)               
#>  glue            1.3.1     2019-03-12 [1] CRAN (R 3.5.3)               
#>  highr           0.7       2018-06-09 [1] CRAN (R 3.5.1)               
#>  htmltools       0.3.6     2017-04-28 [1] CRAN (R 3.5.1)               
#>  knitr           1.21      2018-12-10 [1] CRAN (R 3.5.2)               
#>  lwgeom          0.1-4     2018-01-28 [1] CRAN (R 3.5.1)               
#>  magrittr        1.5       2014-11-22 [1] CRAN (R 3.5.1)               
#>  memoise         1.1.0     2017-04-21 [1] CRAN (R 3.5.1)               
#>  pkgbuild        1.0.3     2019-03-20 [1] CRAN (R 3.5.3)               
#>  pkgload         1.0.2     2018-10-29 [1] CRAN (R 3.5.1)               
#>  prettyunits     1.0.2     2015-07-13 [1] CRAN (R 3.5.1)               
#>  processx        3.3.0     2019-03-10 [1] CRAN (R 3.5.3)               
#>  ps              1.3.0     2018-12-21 [1] CRAN (R 3.5.3)               
#>  R6              2.4.0     2019-02-14 [1] CRAN (R 3.5.3)               
#>  Rcpp            1.0.1     2019-03-17 [1] CRAN (R 3.5.3)               
#>  remotes         2.0.2     2018-10-30 [1] CRAN (R 3.5.1)               
#>  rlang           0.3.3     2019-03-29 [1] CRAN (R 3.5.3)               
#>  rmarkdown       1.11      2018-12-08 [1] CRAN (R 3.5.2)               
#>  rprojroot       1.3-2     2018-01-03 [1] CRAN (R 3.5.1)               
#>  sessioninfo     1.1.1     2018-11-05 [1] CRAN (R 3.5.1)               
#>  sf            * 0.7-2     2018-11-21 [1] Github (r-spatial/sf@acde18e)
#>  spData          0.2.9.4   2018-09-15 [1] CRAN (R 3.5.1)               
#>  stringi         1.2.4     2018-07-20 [1] CRAN (R 3.5.2)               
#>  stringr         1.3.1     2018-05-10 [1] CRAN (R 3.5.1)               
#>  testthat        2.0.0     2017-12-13 [1] CRAN (R 3.5.1)               
#>  units           0.6-1     2018-09-21 [1] CRAN (R 3.5.1)               
#>  usethis         1.4.0     2018-08-14 [1] CRAN (R 3.5.1)               
#>  withr           2.1.2     2018-03-15 [1] CRAN (R 3.5.1)               
#>  xfun            0.4       2018-10-23 [1] CRAN (R 3.5.2)               
#>  yaml            2.2.0     2018-07-25 [1] CRAN (R 3.5.1)               
#> 
#> [1] C:/Users/mking/Documents/R/win-library/3.5
#> [2] C:/Program Files/R/R-3.5.3/library

I suspect this is due to the ring direction, and I believe the sf package corrects this internally during read and write operations.

Negative areas can be fixed by running the "Repair Geometry" tool, but this was an unexpected result from arc.write. I wonder if this package could modified to either:

  1. Automatically repair these geometries during arc.write
  2. Throw a warning about invalid geometries/negative areas

It is feasible to do either one of these?

Many thanks for your work on this package!

version: 1.0.1.241 problem

Dear Devs,

I tried to install new version of arcgisbinding (v241) unfortunately not working. But v239 work fine. I just wanted to inform you about this problem.
Best regards
Console Error:
Failed to initialize R interpreter
Failed to execute

repeated fatal error in Rstudio after working with arcgisbinding

Hello,
I am running into repeated crashes of Rstudio after downloading and working with arcgisbinding. This happens sometimes before I load arcgisbinding in the project I am working with. ArcGIS Pro, R, and Rstudio are all up to date. Occurs every time I try to use arc.write. I am a beginner and having difficulty troubleshooting. Attaching diagnostics report.
diagnostics-report.txt

Python 3.7 in r-script

Has anyone tried using reticulate inside of an r-script executed through rbridge to run a python script that requires python 3.7? I can execute the script fine manually but when it's run through the geoprocessing task it seems to ignore my python configuration line and tries to run it under 2.x and errors out.

use_python('C:\Program Files\Python37\python.exe') is the line of code i'm using at the top of the R script right after the reticulate require. Somehow this doesn't work when it's executed through rbridge. Is there another way to specify a python version?

r-bridge crashes on chaining R script's in arcpy

Traceback (most recent call last):
File "", line 73, in execInThread
File "C:\Program Files (x86)\PyScripter\Lib\rpyc.zip\rpyc\core\netref.py", line 196, in call
File "C:\Program Files (x86)\PyScripter\Lib\rpyc.zip\rpyc\core\netref.py", line 71, in syncreq
File "C:\Program Files (x86)\PyScripter\Lib\rpyc.zip\rpyc\core\protocol.py", line 431, in sync_request
File "C:\Program Files (x86)\PyScripter\Lib\rpyc.zip\rpyc\core\protocol.py", line 379, in serve
File "C:\Program Files (x86)\PyScripter\Lib\rpyc.zip\rpyc\core\protocol.py", line 337, in _recv
File "C:\Program Files (x86)\PyScripter\Lib\rpyc.zip\rpyc\core\channel.py", line 50, in recv
File "C:\Program Files (x86)\PyScripter\Lib\rpyc.zip\rpyc\core\stream.py", line 166, in read
EOFError: [Errno 10054] An existing connection was forcibly closed by the remote host

Calling arc.check_portal() causes R Studio session to crash/abort.

I am having issues calling arc.check_portal() within R Studio. I am new to the arcgis bridge and am trying to test the functionality of the portal data access. I am running R version 4.0.2 and arcgisbinding package version 1.0.1.241. ArcGIS Pro is version 2.6.0.

The crash is occuring directly after loading the arcgisbinding package with library() and calling arc.check_product() as I have done with local uses of the bridge.

Please advise; thanks!

Error: Could not bind to a valid ArcGIS Pro installation

Biding fails (using both RStudio and RGui) with ArcGIS Pro, but successful with ArcGIS Desktop. ArcGIS Pro is using Single Use License (while also logged into ArcGIS Online account). Binding is successful to ArcGIS Pro on similarly configured machine (OS and software versions) with Named User License. License type issue?

Windows 10 Pro
arcgisbinding version 1.0.1.232

ArcGIS Pro Binding - FAILED
ArcGIS Pro 2.2.0
Single Use License - Advanced

R version 3.5.1 (2018-07-02) -- "Feather Spray"
Platform: x86_64-w64-mingw32/x64 (64-bit)

> library(arcgisbinding)
*** Please call arc.check_product() to define a desktop license.
> arc.check_product()
Error: Could not bind to a valid ArcGIS Pro installation.

Installation successfully confirmed from RIntegration.pyt script...

Running script RInstallDetails...
R (version 3.5.1), installed in: C:\Program Files\R\R-3.5.1
R packages will be installed into: D:\Documents\R\win-library\3.5
All R package libraries detected: D:\Documents\R\win-library\3.5;C:\Program Files\R\R-3.5.1\library
The ArcGIS R package (version 1.0.1.232) is installed at: D:\Documents\R\win-library\3.5\arcgisbinding
Completed script R Installation Details...

ArcGIS Desktop Binding SUCCESSFUL

R version 3.5.1 (2018-07-02) -- "Feather Spray"
Platform: i386-w64-mingw32/i386 (32-bit)

> library(arcgisbinding)
*** Please call arc.check_product() to define a desktop license.
> 
> arc.check_product()
product: ArcGIS Desktop ( 10.6.0.8321 )
license: Advanced 
version: 1.0.1.232 

creating an empty geodatabase?

I couldn't find anything about this in the manual or examples, but is it possible to create a empty geodatabase using the bridge?

ArcGIS crashes when running R 3.6.*

Both ArcGIS Pro and ArcGIS Desktop crash when running R code using the r-bridge with R 3.6.* and arcgisbinding 1.0.1.235. This behavior is reproducible on multiple Win 10.1709 computers. Based on the following test results, it appears the only current workaround is to run R 3.5.* WITH arcgisbinding 1.0.1.232.

ArcGIS
Works: ArcGIS Pro 2.4.0; R 3.5.1; arcgisbinding 1.0.1.232
Works: ArcGIS Desktop 10.7.1; R 3.5.1; arcgisbinding 1.0.1.232

Crash: ArcGIS Pro 2.4.0; R 3.5.1; arcgisbinding 1.0.1.235
Crash: ArcGIS Pro 2.4.0; R 3.6.1; arcgisbinding 1.0.1.235
Crash: ArcGIS Pro 2.4.0; R 3.6.1; arcgisbinding 1.0.1.232
Crash: ArcGIS Desktop 10.7.1; R 3.6.1; arcgisbinding 1.0.1.235
Crash: ArcGIS Desktop 10.7.1; R 3.6.1; arcgisbinding 1.0.1.232

R Console (RStudio)
Works: R 3.5.1 x64; arcgisbinding 1.0.1.235
Works: R 3.6.1 x64; arcgisbinding 1.0.1.235
Works: R 3.5.1 i386; arcgisbinding 1.0.1.235
Works: R 3.6.1 i386; arcgisbinding 1.0.1.235

Binding error by using the UC 2015 release version from the R-Shell environment

I am using ArcGIS Pro 1.1 and R 3.1.3 for Windows as suggested. The library loads fine into the x64 Version of the R-Shell. If I call check_product the following error occurs:

Error in .call_proxy("arc_AoInitialize"). "Could not bind to a valid ArcGIS Installation".

Is this UC release meant to be used with ArcGIS Pro 1.1 or are there any ArcGIS for Desktop dependencies?

R session crashes with arc.check_portal

I want to open a feature service in RStudio. I am signed into my active portal in ArcGIS Pro. In the code below everything works as expected until I get to arc.check_portal(). This call crashes R returning a 'R encountered a fatal error' message. So far I've tried restarting RStudio and restarting my PC.

Any ideas? Thanks!

Code:

library(arcgisbinding)
library(sf)
library(tidyverse)

sessionInfo()
arc.check_product()
arc.check_portal()

Relevant session info:
R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 16299)
other attached packages:
[1] arcgisbinding_1.0.1.241

arc.check_product() return:
product: ArcGIS Pro (12.6.0.24783)
license: Advanced
version: 1.0.1.241

cannot set library MODIS

I need to use MODIS from ArcGIS Pro, but when run the R scripit from ArcGIS Pro and reach the statement: library(MODIS)
get error despite the package installation was fine:

Running script Download Modis...
[1] "C:/D/proyectos/2020/arauco/ds/PilotoArauco"
[1] "C:/.../.Rprofile"
Attaching package: 'nlme'
The following object is masked from 'package:raster':
getData

spatstat 1.64-1 (nickname: 'Help you I can, yes!')
For an introduction to spatstat, type 'beginner'
Attaching package: 'spatstat'
The following objects are masked from 'package:raster':
area, rotate, shift
Registered S3 method overwritten by 'cli':
method from
print.boxx spatstat
Installing package into 'C:/Users/fhernandez/Documents/R/win-library/4.0'
(as 'lib' is unspecified)
trying URL 'http://cran.ma.imperial.ac.uk/bin/windows/contrib/4.0/MODIS_1.2.2.zip'
Content type 'application/zip' length 691222 bytes (675 KB)
downloaded 675 KB
package 'MODIS' successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\fhernandez\AppData\Local\Temp\RtmpqyJhOc\downloaded_packages

-Error in value[[3L]] : package or namespace load failed for 'MODIS':
- .onLoad failed in loadNamespace() for 'pkgload', details:
-  call: NULL
-  error: C stack usage  981968 is too close to the limit
- Failed to execute (DownLoad).

However the R script in RStudio does not arise any problem.

Details on attached file modis.docx

arc.write() with subset of data frame - length of shape != data.frame length error

First of all, arcgisbinding is an amazing product which enabled me accessing my Esri based datasets directly from R in read/write mode without rgdal hustle. Brilliant.

I wonder what is a proper syntax for filtering data frame and then exporting to a new feature class? Running this will work as expected, because I do arc.write() on the whole df:

library(arcgisbinding)
arc.check_product()

data = arc.open(path = 'C:\\Program Files (x86)\\ArcGIS\\Desktop10.4\\TemplateData\\TemplateData.gdb\\USA\\states')
df = arc.select(data,where_clause = "SUB_REGION = 'Pacific' ")

arc.write(path='C:\\GIS\\Temp\\statesPac.shp',data=df)

However, trying to filter rows in df and writing to the output on-the-fly like this:

library(arcgisbinding)
arc.check_product()

data = arc.open(path = 'C:\\Program Files (x86)\\ArcGIS\\Desktop10.4\\TemplateData\\TemplateData.gdb\\USA\\states')
df = arc.select(data)

arc.write(path='C:\\GIS\\Temp\\statesPacX.shp',data=df[df$SUB_REGION == "Pacific",])

results in an error message:

Warning messages:
1: In: arc.select() - ignoring field: Shape_Length,Shape_Area, 
2: In .call_proxy("arc_export2dataset", path, data, coords, shape_info) :
  length of shape != data.frame length

I do get a shapefile created, however, it contains correct states attributes yet the geometry of the features matches other states that were first in the original df index. Obviously, I need to filter the geometry of the features while filtering the df, but I cannot get how to do that.

Interestingly enough, using the SpatialDataFrame does allow me to get my sdf filtered on-the-fly:

library(arcgisbinding)
arc.check_product()

data = arc.open(path = 'C:\\Program Files (x86)\\ArcGIS\\Desktop10.4\\TemplateData\\TemplateData.gdb\\USA\\states')
df = arc.select(data) #where_clause = "SUB_REGION = 'Pacific' "

sdf = arc.data2sp(df)
sdf = subset(sdf, select = -OBJECTID)

arc.write(path='C:\\GIS\\Temp\\statesPac.shp',data=sdf[sdf$SUB_REGION == "Pacific",])

Am I supposed to use the sdf or there is a legal way to achieve sub-setting with df?

Support POSIXlt datetimes

If dates are contained within a POSIXlt object, arc.write currently fails. Here's a basic sample:

sample-15min.csv

datetime,jd,airt
2005-01-01 00:15,1,5.1
2005-01-01 00:30,1,5.0
2005-01-01 00:45,1,4.9
2005-01-01 01:00,1,4.7
2005-01-01 01:15,1,4.5
2005-01-01 01:30,1,4.6
2005-01-01 01:45,1,4.6
2005-01-01 02:00,1,4.7
2005-01-01 02:15,1,4.6
2005-01-01 02:30,1,4.6
2005-01-01 02:45,1,4.6
2005-01-01 03:00,1,4.4
2005-01-01 03:15,1,4.4
2005-01-01 03:30,1,4.4
2005-01-01 03:45,1,4.4
2005-01-01 04:00,1,4.3
2005-01-01 04:15,1,4.4
2005-01-01 04:30,1,4.5
2005-01-01 04:45,1,4.7

A basic script trying to write these out, after conversion to POSIXlt. Note that this is a forced example since the data is initially in POSIXct, but there are other cases where the data will already be in POSIXlt prior to export.

library(arcgisbinding)
arc.check_product()
o <- arc.open("sample-15min.csv")
s <- arc.select(o)
class(s$datetime[1]) # imported as POSIXct by default
# set to POSIXlt
s$datetime <- as.POSIXlt(s$datetime)
arc.write("sample_with_posixlt.dbf", s)
# DBF output errors with:
#   in .call_proxy("arc_export2dataset", path, data, coords, shape_info) : 
# unknown error

# Trying to an FGDB instead. The output is written, but the `datetime` column is dropped
arc.write("r_test.gdb/sample_with_posixlt", s)
# Warning message:
#   In .call_proxy("arc_export2dataset", path, data, coords, shape_info) :
#  unsupported data.field column type

Support mapping logical values into the closest supported type

As reported by Andrew Gilbert, when writing out logical (boolean) values with arc.write(), NA values will instead be written out as -1, which as.logical() will evaluate as TRUE. Logicals in R have the following possible values:

Name Possible values
True TRUE, T, 1
False FALSE, F, 0
Not Available NA

While NA and NULL are actually different concepts, for the purposes of the bridge, they can be treated as equivalent for data exchange. It'd make sense to retain these either as:

  • A string, with the values TRUE, FALSE and NULL. This is the best choice from an R perspective, as its tools can directly interpret these as logical values.
  • A short, with the values 1, 0, and NULL. R won't automatically recognize these are logical values, but they can be cast to the correct type with as.logical.

Read files from database connection

Not sure if this is an issue, or simply an inquiry about features. I'm trying to read layers from a database server connection. Is this possible? My connection string looks like this:

library(DBI)
library(odbc)
con <- dbConnect(odbc(), 
                 Driver = "SQL Server", 
                 Server = "GIS_DB", 
                 Database = "MY_PUBLIC_DB", 
                 UID = rstudioapi::askForPassword("Database user"),
                 PWD = rstudioapi::askForPassword("Database password"),
                 Trusted_Connection = "True")

Is there any way we can use arc.open() or another function on con? The issue is that I want to read tables and layers from the database, but raw SQL queries like the example below can sometimes block the connection to our server for other enterprise users

my_layer <- dbFetch(dbSendQuery(con, 'select * from MY_PUBLIC_DB.ARCMAP_ADMIN.MY_LAYER'))

Geographic Coordinate System

The way arc.write works appears to not be carrying over the full spatial reference. The sf package recently updated how this info was stored, but this also failed in previous versions and seemed to only be pulling the proj4string and not the EPSG which were stored separately.

require(sf)
require(arcgisbinding)
arc.check_product()
Shape<-st_read("Path to Shape")
arc.write("Path to gdb",Shape,validate = TRUE)

###output of st_crs(Shape)

st_crs(Shape)
Coordinate Reference System:
User input: WGS 84
wkt:
GEOGCRS["WGS 84",
DATUM["World Geodetic System 1984",
ELLIPSOID["WGS 84",6378137,298.257223563,
LENGTHUNIT["metre",1]]],
PRIMEM["Greenwich",0,
ANGLEUNIT["degree",0.0174532925199433]],
CS[ellipsoidal,2],
AXIS["latitude",north,
ORDER[1],
ANGLEUNIT["degree",0.0174532925199433]],
AXIS["longitude",east,
ORDER[2],
ANGLEUNIT["degree",0.0174532925199433]],
ID["EPSG",4326]]
CRS_wrong

  • There is a similar post below dealing with an sp object that was brought into R using this package. The solution was pull the formatted spatial reference prior the object being an sp object. It seems like arc.write should be able to deal with the major formats R users use. I would think arc.write could identify the type of object that is input, which would query the spatial info and output it in the desired format?

Error in .call_proxy("dataset.open", .Object, path)

Possibly related to this issue: #21 but none of the solutions in that thread worked.

I've previously been able to import feature classes from geodatabase using the r-bridge, but now I'm receiving an error that I never got before on the same code. I upgraded to R 4.02 and thus installed the latest version from here: #37. This also occurred in R version 3.6.3 with a previous version as well so it does not seem to be related to R 4.0.

I tried running the following on the sample data to troubleshoot but got the same error:

    filename <- system.file("extdata", "ca_ozone_pts.shp", package = "arcgisbinding")
    d <- arc.open(filename)

The console output was:

Error in .call_proxy("dataset.open", .Object, path) : 
  Class not registered

This is on a fresh install of R 4.0 and version 1.0.1.240 of arcgisbinding. Any suggestions? Thank you!

Issues with accents

Hello,
I've got an issue when I'm running my R-Script on ArcMap, using R-ArcGIS bridge.
I work with a feature class stored in a geodatabase. When I run the script on R-studio, everything works perfectly such as field calculator, saving of feature class and tables in my geodatabase and some plots as images. The bridge between the two softwares works very well.
Unfortunately, when I try to import my script on ArcMap to add my process in a toolbox, it seems that ArcGIS cannot read sentences which included accents (as you can perceived by my english, I'm french and we have a lot of accentuated words). So, it's a real problem that doesn't allow me to automatise my processing on ArcGIS.
I have this issue also with specials characters such as "µm" or exponent.
Does anyone know if my issue came from ArcGIS or the bridge between R and ArcGIS?

This is my data frame on R
image

And this s what ArcGIS is reading when I run my script on ArcGIS desktop
image

It misses all my data with accents.
If someone has ever had this problem or is acquainted with a solution, it will be time saving for me,

I thank you in advance,

Best regards,

Pauline

arc.select() drops relationship field.

Not sure why, but when you use arc.select() on dataset_type:Table it drops the relationship field.

test<-arc.open('//some/path/CO_EDT_User.sde/dbSCHMEA.Nest_Productivity')
test

Output:

> test
dataset_type    : Table
path            : //some/path/CO_EDT_User.sde/dbSCHMEA.Nest_Productivity
fields          : OBJECTID, ADM_UNIT_CD, NEST_ID, SURVEY_TYPE, SURVEY_DATE, SPECIES, ACTIVITY, 
fields          : NEST_CONDITION, NUM_ADULTS, NUM_YOUNG, ACT_OBS, NEST_STATUS, SRVY_COMMENT, 
fields          : NEST_GUID, GlobalID, created_user, created_date, last_edited_user, 
fields          : last_edited_date

NEST_GUID is in the field list.

But then:

> test%>%
+   arc.select()%>%
+   names()
 [1] "OBJECTID"         "ADM_UNIT_CD"      "NEST_ID"          "SURVEY_TYPE"     
 [5] "SURVEY_DATE"      "SPECIES"          "ACTIVITY"         "NEST_CONDITION"  
 [9] "NUM_ADULTS"       "NUM_YOUNG"        "ACT_OBS"          "NEST_STATUS"     
[13] "SRVY_COMMENT"     "GlobalID"         "created_user"     "created_date"    
[17] "last_edited_user" "last_edited_date"

NEST_GUID Disappears???? Is this the intended functionality?

arcgisbinding without ArcGIS?

Nice work on your part the R-ArcGIS Bridge!

My question: Is is possible to use some of the package functionalities without having ArcGIS installed? We would like to use the arcgisbinding Package to connect R to an ArcGIS Server, where some users might not necessarily have ArcGIS Installed.

PS: Is the package arcgisbinding going to be on CRAN at some point?

Error when installing

Hi Folks:
I'm using ArcGIS Pro and python. I'm having problems installing ArcGISBindings 1.0.1.13.2. The steps I took were as follows:

  1. Made a new Python environment in with Manage Environments using Manage Environments in ArcGIS Pro and switched to that new environment.

  2. Opened up the ArcGIS Pro Python command prompt and ran the following command and verified that the new environment was activated.

  3. Then I installed conda specific to that new enviroment: conda install -n env_1 r-essentials.

  4. In windows explorer I confirmed that R base was installed to "r-base-3.5.1-hac0af64_1"

  5. I opened Jupyter Notebook and created a new R notebook but received an error as shown in the top of the screen shot below. That caused Jupyter notebook to keep restarting as shown in the bottom of the screen shot below.

2018-11-21 14_22_23-clipboard

  1. Then I went into ArcGIS Pro and Examined my Geoprocessing environments and set the environment to r-base-3.5.1-hac0af64_1.

2018-11-21 14_26_42-clipboard

  1. When I tried to install the ArcGISPackage I get an error when i try to install.

2018-11-21 14_25_32-clipboard

I've searched this error but can't find anything on it. Please let me know if you have thoughts.

ArcGIS Pro Update 2.4.0: R Session crashes when using arc.write

After updating my ArcGIS Version to 2.4, using R / arcgisbinding to read and write data causes R to crash.

So in the following script, uncommenting arc.write("C:/Users/scratch.gdb/nc",nc) would cause RStudio to crash.

library(arcgisbinding)
#> *** Please call arc.check_product() to define a desktop license.

arc.check_product()
#> product: ArcGIS Pro ( 12.4.0.19948 )
#> license: Advanced 
#> version: 1.0.1.232

library(sf)
#> Warning: Paket 'sf' wurde unter R Version 3.6.1 erstellt
#> Linking to GEOS 3.6.1, GDAL 2.2.3, PROJ 4.9.3
nc <- st_read(system.file("shape/nc.shp", package="sf"))
#> Reading layer `nc' from data source `C:\Users\rata\Documents\R\R-3.6.0\library\sf\shape\nc.shp' using driver `ESRI Shapefile'
#> Simple feature collection with 100 features and 14 fields
#> geometry type:  MULTIPOLYGON
#> dimension:      XY
#> bbox:           xmin: -84.32385 ymin: 33.88199 xmax: -75.45698 ymax: 36.58965
#> epsg (SRID):    4267
#> proj4string:    +proj=longlat +datum=NAD27 +no_defs

# arc.write("C:/Users/scratch.gdb/nc",nc)
 

sessionInfo()
#> R version 3.6.0 (2019-04-26)
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
#> Running under: Windows 10 x64 (build 17134)
#> 
#> Matrix products: default
#> 
#> locale:
#> [1] LC_COLLATE=German_Switzerland.1252  LC_CTYPE=German_Switzerland.1252   
#> [3] LC_MONETARY=German_Switzerland.1252 LC_NUMERIC=C                       
#> [5] LC_TIME=German_Switzerland.1252    
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] sf_0.7-7                arcgisbinding_1.0.1.232
#> 
#> loaded via a namespace (and not attached):
#>  [1] Rcpp_1.0.2         class_7.3-15       digest_0.6.20     
#>  [4] grid_3.6.0         DBI_1.0.0          magrittr_1.5      
#>  [7] units_0.6-3        e1071_1.7-2        evaluate_0.14     
#> [10] KernSmooth_2.23-15 highr_0.8          stringi_1.4.3     
#> [13] rmarkdown_1.14     tools_3.6.0        stringr_1.4.0     
#> [16] xfun_0.8           yaml_2.2.0         compiler_3.6.0    
#> [19] classInt_0.4-1     htmltools_0.3.6    knitr_1.24

Created on 2019-08-09 by the reprex package (v0.3.0)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.