[R-sig-Geo] v.split.length (GRASS) in R
Manuel Spínola
mspinola10 at gmail.com
Thu Nov 24 16:00:41 CET 2016
Thank you Jannes,
I installed the QGIS LTR, but I got the following error:
qgis_env <- set_env("C:/Program Files/QGIS 2.14")
ruta <- readOGR(dsn = ".", layer = "Ruta32_CRTM05_FINAL")
args <- get_args_man("grass7:v.split.length", qgis_env = qgis_env, options
= TRUE)
args$input <- ruta
args$length <- 500
args$output <- "ruta_s.shp"
out <- run_qgis(alg = "grass7:v.split.length", params = args, load_output =
args$output, qgis_env = qgis_env)
Error in .local(.Object, ...) :
Show Traceback
Error in .rasterObjectFromFile(x, band = band, objecttype = "RasterLayer",
: Cannot create a RasterLayer object from this file. (file does not exist)
2016-11-24 3:43 GMT-06:00 "Jannes Münchow" <malNamalJa at gmx.de>:
> 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
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>
>
> --
> *Manuel Spínola, Ph.D.*
> Instituto Internacional en Conservación y Manejo de Vida Silvestre
> Universidad Nacional
> Apartado 1350-3000
> Heredia
> COSTA RICA
> mspinola at una.cr <mspinola at una.ac.cr>
> mspinola10 at gmail.com
> Teléfono: (506) 8706 - 4662
> Personal website: Lobito de río
> <https://sites.google.com/site/lobitoderio/>
> Institutional website: ICOMVIS <http://www.icomvis.una.ac.cr/>
>
--
*Manuel Spínola, Ph.D.*
Instituto Internacional en Conservación y Manejo de Vida Silvestre
Universidad Nacional
Apartado 1350-3000
Heredia
COSTA RICA
mspinola at una.cr <mspinola at una.ac.cr>
mspinola10 at gmail.com
Teléfono: (506) 8706 - 4662
Personal website: Lobito de río <https://sites.google.com/site/lobitoderio/>
Institutional website: ICOMVIS <http://www.icomvis.una.ac.cr/>
[[alternative HTML version deleted]]
More information about the R-sig-Geo
mailing list