Skip to content

Commit

Permalink
unioning roads using lots of memory. try removing
Browse files Browse the repository at this point in the history
  • Loading branch information
see24 committed Apr 2, 2024
1 parent 894f545 commit 92ecc06
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions R/pathsToLines.R
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,14 @@ pathsToLines <- function(sim){
cellsToKeep <- v[keep[[1]]]
cellsToKeep <- na.omit(cellsToKeep)
outLine <- sf::st_linestring(terra::xyFromCell(sim$weightRaster,
cellsToKeep)) %>%
sf::st_sfc()
cellsToKeep))
} else {
outLine <- lapply(keep, function(x){
cellsToKeep <- v[x]
cellsToKeep <- na.omit(cellsToKeep)
sf::st_linestring(terra::xyFromCell(sim$weightRaster, cellsToKeep))
})
outLine <- sf::st_union(outLine %>% sf::st_as_sfc())
outLine <- do.call(c, outLine)
}


Expand All @@ -153,8 +152,6 @@ pathsToLines <- function(sim){
return(slice(sim$roads, 0))
}

outLines <- do.call(c, linelist) %>%
sf::st_union()
outLines <- sf::st_sf(geometry = outLines)
outLines <- sf::st_sf(geometry = linelist %>% sf::st_as_sfc())
return(sf::st_set_crs(outLines, sf::st_crs(sim$roads)))
}

0 comments on commit 92ecc06

Please sign in to comment.