Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple attempts required to open feature layers through ArcSDE connections #76

Open
jngtz opened this issue Feb 6, 2023 · 1 comment
Assignees

Comments

@jngtz
Copy link

jngtz commented Feb 6, 2023

Describe the bug
Opening a feature though an ArcSDE connection file (.sde) always fails on the first attempt, but works on the following attempt. This problem occurs in both R-Studio and R IDE. Whenever this occurs the working directory is automatically changed to C:/Program Files/ArcGIS/Pro/

multiple_request_sde_arc_binding

arcgisbinding info (please complete the following information):

arc.check_portal output:
product: ArcGIS Pro (13.0.2.36056)
license: Advanced
version: 1.0.1.300

R: R version 4.2.1 - arcgisbinding version 1.0.1.300

OS: Windows 10 Enterprise

@jngtz
Copy link
Author

jngtz commented Feb 22, 2023

I've made the following function as a workaround. It tries multiple attempts to open the SDE path, and maintains the original working directory - where x is a string containing the file path (e.g. "C:/PATH_TO/SDE_CONNECTION_FILE.sde/A_FEATURE_LAYER")

arc.openSDE <- function(x, max_attempts = 5) {
  
  wd <- getwd()
  attempt <- 1
  
  while (attempt <= max_attempts) {
    openSDE <- tryCatch(arc.open(x), error = function(err) err)
    
    if (inherits(openSDE, "error")) {
      cat("Attempt", attempt, "failed. Retrying...\n")
      attempt <- attempt + 1
      next
    }
    
    on.exit(setwd(wd))
    return(openSDE)
    
  }
  
  stop("Max attempts exceeded")
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants