Hi Manuel,
overall we recommend to use RQGIS with the long-term release of QGIS
(2.14). Nevertheless, RQGIS works also with QGIS 2.18. However, there is a
bug in the QGIS Python code. Therefore, one needs to manually change the
Python code. Here you find how you can do that:
https://github.com/jannes-m/RQGIS#qgis-216-modifications.
Regarding this issue, we have already notified the QGIS developers, and
they told us that they fixed the issue. Hence, with the release of the next
QGIS patch release, the manual adjustment of the Python code should no
longer be necessary.
Best regards,
Jannes
*Gesendet:* Mittwoch, 23. November 2016 um 20:49 Uhr
*Von:* "Manuel Sp?nola" <mspinola10 at gmail.com>
*An:* "Jannes M?nchow" <malNamalJa at gmx.de>
*Cc:* "r-sig-geo at r-project.org" <r-sig-geo at r-project.org>
*Betreff:* Re: [R-sig-Geo] v.split.length (GRASS) in R
Thank you very much Jannes.
Does the example works with QGIS 2.18 or should I do some setting in QGIS
before running the code?
Manuel
2016-11-23 8:45 GMT-06:00 "Jannes M?nchow" <malNamalJa at gmx.de>:
To achieve this, you can also use the RQGIS-package in conjunction with
GRASS given you have installed QGIS along with GRASS (for more information
have a look at vignette("install_guide", package = "RQGIS"):
# construct a SpatialPointsDataFrame (which will be accepted as input by
# run_qgis)
library("sp")
# from the sp vignette:
l1 <- cbind(c(1, 2, 3), c(3, 2, 2))
rownames(l1) <- letters[1:3]
l1a <- cbind(l1[, 1] + 0.05, l1[, 2] + 0.05)
rownames(l1a) <- letters[1:3]
l2 <- cbind(c(1, 2, 3), c(1, 1.5, 1))
rownames(l2) <- letters[1:3]
Sl1 <- Line(l1)
Sl1a <- Line(l1a)
Sl2 <- Line(l2)
S1 <- Lines(list(Sl1, Sl1a), ID = "a")
S2 <- Lines(list(Sl2), ID = "b")
Sl <- SpatialLines(list(S1, S2))
# convert it to a SpatialLinesDataFrame
Sl <- SpatialLinesDataFrame(Sl, data = data.frame(1:2), match.ID = FALSE)
proj4string(Sl) <- CRS("+proj=longlat +datum=WGS84")
# Now use RQGIS
library("RQGIS")
# indicate where QGIS is installed on your computer
qgis_env <- set_env("C:/OSGeo4W64/")
args <- get_args_man("grass7:v.split.length", qgis_env = qgis_env,
options = TRUE)
# have a look at the GRASS online help
open_help("grass7:v.split.length", qgis_env = qgis_env)
# specify the necessary arguments
args$input <- Sl
# here length corresponds to one decimal degree
args$length <- "1"
args$output <- file.path(tempdir(), "out.shp")
# load the output directly into R again
out <- run_qgis(alg = "grass7:v.split.length", params = args,
load_output = args$output,
qgis_env = qgis_env)
length(Sl) # 2 line objects
length(out) # 9 line objects
# Have a look at the output
plot(out, col = rep(c("blue", "green", "black"), 3))
Cheers,
Jannes