[R-sig-Geo] Error in file.exists(params[[i]]) : invalid 'file' argument when using v.clean function in RQGIS

Glenn Stauffer gestauffer at gmail.com
Fri Jan 26 20:22:30 CET 2018


I am working with SpatialLines in R, and want to split lines at every point
where lines cross (like the Planarize function in ArcGIS). The R package
RQGIS makes QGIS functionality accessible in R (see example from Jannes
Muenchow at
http://r-sig-geo.2731867.n2.nabble.com/v-split-length-GRASS-in-R-td7590611.h
tml ), and the GRASS function v.clean should do exactly what I want.
However, I have not been able to get it to work, and have run into two
problems.

 

First, when I run the get_args_man() function I apparently a window that
pops up and says "

Runtime Error! 

Program: C\Program Files\R\R-3.4.0\bin\x64\RGui.exe

R6034

An application has made an attempt to load the C runtime library in
correctly.

Please contact the application's support team for more information."

 

I only get this the first time I run try running the get_args_man()
function, and despite the popup, the arguments are retrieved (the function
seems to work). Subsequent calls to the function do not generate the
message.

 

Secondly, when I call the run_qgi()s function, with 'alg="grass7:v.clean"',
I always get the error message "Error in file.exists(params[[i]]) : invalid
'file' argument". This does not happen when I run the example from the link
I referenced above (with alg="v.split"). I've tried running the function
line-by-line, and it trips at the following line within the run_qgis()
function:

"params <- pass_args(alg, params = params, NA_flag = NA_flag,qgis_env =
qgis_env)"

 

Can anyone suggest a cause or solution for either of these problems (but
especially the latter)? On the first problem, could this be related to a
permissions issue? 

 

Below is a contrived example that should illustrate what I am talking about
(unless the problems are specific to my computer). 

 

Thanks,

Glenn

 

#################

# Example Code

#################

 

library(sp)

library(RQGIS)

 

pts <- cbind(c(120:123,121,125),c(100,100,104,102,99,98))

pt2 <- cbind(c(124,124,123,118,124,125),c(100,97,100,104,106,110))

projstr <- "+init=epsg:3071"         # make everything in meters

L <- SpatialLines(list(Lines(list(Line(pts),Line(pt2)),"X")),proj4string =
CRS(projstr)) 

plot(L)

# indicate where QGIS is installed on your computer

qgis_env <- set_env("C:/Program Files/QGIS 2.14")

# get args for GRASS function (generates runtime error when first called)

args <- get_args_man("grass7:v.clean", qgis_env = qgis_env, options = TRUE)

# have a look at the GRASS online help

open_help("grass7:v.clean", qgis_env = qgis_env)

 

# specify the necessary arguments

args$input <- L

args$tool <- "break"

args$output <- file.path(tempdir(), "out.shp")

# load the output directly into R again

out <- run_qgis(alg = "grass7:v.clean", params = args,

                load_output = TRUE,

                qgis_env = qgis_env)

 

 

 

 


	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list