<html><head></head><body><div style="font-family: Verdana;font-size: 12.0px;"><div>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"):<br/>
<br/>
# construct a SpatialPointsDataFrame (which will be accepted as input by<br/>
# run_qgis)<br/>
library("sp")<br/>
# from the sp vignette:<br/>
l1 <- cbind(c(1, 2, 3), c(3, 2, 2))<br/>
rownames(l1) <- letters[1:3]<br/>
l1a <- cbind(l1[, 1] + 0.05, l1[, 2] + 0.05)<br/>
rownames(l1a) <- letters[1:3]<br/>
l2 <- cbind(c(1, 2, 3), c(1, 1.5, 1))<br/>
rownames(l2) <- letters[1:3]<br/>
Sl1 <- Line(l1)<br/>
Sl1a <- Line(l1a)<br/>
Sl2 <- Line(l2)<br/>
S1 <- Lines(list(Sl1, Sl1a), ID = "a")<br/>
S2 <- Lines(list(Sl2), ID = "b")<br/>
Sl <- SpatialLines(list(S1, S2))<br/>
# convert it to a SpatialLinesDataFrame<br/>
Sl <- SpatialLinesDataFrame(Sl, data = data.frame(1:2), match.ID = FALSE)<br/>
proj4string(Sl) <- CRS("+proj=longlat +datum=WGS84")<br/>
<br/>
# Now use RQGIS<br/>
library("RQGIS")<br/>
# indicate where QGIS is installed on your computer<br/>
qgis_env <- set_env("C:/OSGeo4W64/")<br/>
args <- get_args_man("grass7:v.split.length", qgis_env = qgis_env,<br/>
options = TRUE)<br/>
# have a look at the GRASS online help<br/>
open_help("grass7:v.split.length", qgis_env = qgis_env)<br/>
<br/>
# specify the necessary arguments<br/>
args$input <- Sl<br/>
# here length corresponds to one decimal degree<br/>
args$length <- "1"<br/>
args$output <- file.path(tempdir(), "out.shp")<br/>
# load the output directly into R again<br/>
out <- run_qgis(alg = "grass7:v.split.length", params = args,<br/>
load_output = args$output,<br/>
qgis_env = qgis_env)<br/>
length(Sl) # 2 line objects<br/>
length(out) # 9 line objects<br/>
# Have a look at the output<br/>
plot(out, col = rep(c("blue", "green", "black"), 3))<br/>
</div>
<div> </div>
<div><br/>
Cheers,<br/>
<br/>
Jannes</div></div></body></html>