Skip to content

Commit

Permalink
edit LinearDist script
Browse files Browse the repository at this point in the history
  • Loading branch information
walterASEL committed Mar 12, 2024
1 parent 950b358 commit f77a9df
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions LinearDistScript.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ library(polyCub)#replaces gpclib function
library(OneR)#bin function
library(sf)
library(terra)
library(dplyr)
```

3\. Now let's have a separate section of code to include projection information we will use throughout the exercise. In previous versions, these lines of code were within each block of code
Expand Down Expand Up @@ -156,6 +157,21 @@ segs.y <- c(segs[,c(2,4)])
segs.owin <- as.owin(c(range(segs.x),range(segs.y)))#create a new "owin" class because
#roads occur outside our bdy.owin created above
roadSegs <- as(cliproads, "Spatial")
roadSegs <- lapply(1:length(roadSegs), function(x) roadSegs[x,])
roadSplit <- lapply(roadSegs[1:219], splitLines, dist = 50)
segs <- st_segments(cliproads,units::set_units(50,m))
new_lines <- segs %>%
st_as_sf(coords = c("x", "y"), crs = 5070) %>%
group_by(LINEARID) %>%
dplyr::summarize() %>% # do_union=FALSE doesn't work as well
filter(st_is_empty(.) == FALSE) %>%
st_cast("MULTILINESTRING")
plot(st_geometry(new_lines))
segs.owin <- as.owin(new_lines)
#The segments as a planar segment pattern:
segs.psp <- as.psp(segs, window=segs.owin)
plot(segs.psp)
Expand Down

0 comments on commit f77a9df

Please sign in to comment.