r-bridge icon indicating copy to clipboard operation
r-bridge copied to clipboard

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

Open ratnanil opened this issue 5 years ago • 13 comments

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)

ratnanil avatar Aug 09 '19 09:08 ratnanil

Looks like problem with installation/upgrade of arcgisbinding. Lets troubleshoot it first. start Rgui.exe and evaluate following commands (first example in ?arc.write doc):

library(arcgisbinging);library(arcgisbinging)
## Example #1. write a shapefile
fc <- arc.open(system.file("extdata", "ca_ozone_pts.shp", package="arcgisbinding"))
d <- arc.select(fc, 'ozone')
d[1,] <- 0.6
arc.write(tempfile("ca_new", fileext=".shp"), d)

If you have problem to execute it then close all sessions of R, including Rgui, ArcGIS, RStudio, VSCode etc. Delete existing arcgisbinding package (check C:\Users\rata\Documents\R\R-3.6.0\library\arcgisbinding) Download arcgisbinding_1.0.1.232.zip. Start fresh instance of Rgui.exe and from menu>Packages>"Install packages from local file..." navigate to Download folder and pick arcgisbinding_1.0.1.232.zip file. Re-do Example #1.

dpavlushko avatar Aug 13 '19 00:08 dpavlushko

library(arcgisbinging)

was that a typo? why call the library twice? Was omitting arc.check_product() intentional?

I ran the following lines in Rgui.exe (64-bit) and it didn't crash:

library(arcgisbinding)
arc.check_product()
fc <- arc.open(system.file("extdata", "ca_ozone_pts.shp", package="arcgisbinding"))
d <- arc.select(fc, 'ozone')
d[1,] <- 0.6
arc.write(tempfile("ca_new", fileext=".shp"), d)

ratnanil avatar Aug 13 '19 05:08 ratnanil

Short solution - change output location from "C:/Users/scratch.gdb/nc" to other where you have permission to write a new file. Like "C:/Users/rata/scratch.gdb/nc" or file.path(tempdir(), scratch.gdb/nc

I'll try to fix hard crash by the next release.

dpavlushko avatar Aug 14 '19 21:08 dpavlushko

change output location from "C:/Users/scratch.gdb/nc" to other where you have permission to write a new file.

Tried this within RStudio IDE, still results in a hard crash

ratnanil avatar Aug 16 '19 12:08 ratnanil

Thanks for trying that out, sorry to hear it didn't work. It possibly could be a DLL conflict between the R environment and ArcGIS, though we haven't been able to reproduce it yet on our end. Could you see if you can reproduce this crash in just an Rgui.exe session? Could you also try @dpavlushko's sample code, adding in a library(sf) call and see if that crashes? sf should be statically linked to its own copy of GDAL/GEOS/PROJ, but wanted to see if any of the above has an effect.

scdub avatar Aug 16 '19 15:08 scdub

This is really confusing. I just ran the following lines in Rgui and RStudio, and neither crashed!

library(arcgisbinding)
arc.check_product()
fc <- arc.open(system.file("extdata", "ca_ozone_pts.shp", package="arcgisbinding"))
d <- arc.select(fc, 'ozone')
d[1,] <- 0.6
arc.write("C:/Users/rata/Downloads/test.gdb/data",d)

ratnanil avatar Aug 19 '19 07:08 ratnanil

Im having a maybe related problem, but it seems to have been fixed by installing arcgisbinding_1.0.1.232.zip as you suggested. Prior I was using the most recent version.

At first I thought the problem was specific to rstudio as I was getting an error related to libobjects_pro.dll when trying to load arcgisbinding from rstudio. I could could load from the R Console without error, both 64 and 32 bit, most of the time. I say most of the time as there were 1 instance where I got the same error in the Console. So I agree this is confusing!

However, I got an persistent error when using either arc.write or arc.open in the Console. I'm sorry I don't recollect what the error was. Finally, ArcGIS Pro was crashing within seconds when trying to run an R script. This is my first R script i ArcGIS so difficult to assess if it was something with my R code or ArcGIS, but given all of the above I'm guessing it's arcgisbinding that's the problem.

Hopefully this is helpful, please let me know if you need more info.

atle1 avatar Oct 06 '19 09:10 atle1

This issue is certainly confusing. Sometimes arc.write works as expected for me, and other times it crashes RStudio (abort session). I am running version 1.0.1.237. Anyone have further guidance since the last post? Thank you

a-brasch avatar Oct 13 '20 05:10 a-brasch

I'm having a very similar issue running 1.0.1.241 with frequent RStudio crashes.

ChristopherTracey avatar Oct 21 '20 15:10 ChristopherTracey

I am having a similar issue. Downloaded arcgisbinding a few days ago but started working with it today. Now getting fatal errors when I run Rstudio code with arcgisbinding in it. Sometimes even before loading the package. Uninstall/reinstall of R and Rstudio did not fix issue. Could it be related to the environment I set up in ArcGIS pro?

(I am a beginner)

ggold602 avatar Nov 10 '20 05:11 ggold602

EDIT: resolved my fatal error. Newest version of arcgisbinding allows ability to import from ArcPro and manipulate data other ways in R, just not arc.write to a .gdb

zeb-yoko avatar Apr 01 '21 19:04 zeb-yoko

For anyone affected by this, can you see if you're able to reproduce in just the plain RGUI interface? And if you do get a crash in RStudio, there should be a crash dump located at %LOCALAPPDATA%\R\crashpad_database\reports which is generated, which hopefully we can access. RStudio will get these crashes so we don't see them on our end, and we're not able to reproduce this locally on a few different machines.

scdub avatar Apr 08 '21 22:04 scdub

So, I'm going to follow up my edited follow-up. I can get it to run arc.write without fatal error, but only in administrator mode, and after running the test code mentioned and provided by @ratnanil :

`library(arcgisbinding) arc.check_product() fc <- arc.open(system.file("extdata", "ca_ozone_pts.shp", package="arcgisbinding")) d <- arc.select(fc, 'ozone') class(d) d[1,] <- 0.6 arc.write(tempfile("ca_new", fileext=".shp")'

After running that, arc.write works for my personal code if in the same session. Without running that first in a session, I get fatal error when trying to run arc.write line

zeb-yoko avatar Apr 14 '21 16:04 zeb-yoko