Skip to content

Commit

Permalink
more resolving
Browse files Browse the repository at this point in the history
  • Loading branch information
josie-hughes committed Jun 18, 2024
1 parent 0e9cb39 commit f174ad0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 32 deletions.
26 changes: 7 additions & 19 deletions R/projectRoads.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@
#' * "snap": Connects each landing to the closest (by Euclidean distance) road without,
#' reference to the weights or other landings.
#'
<<<<<<< HEAD
#' @param landings sf polygons or points, RasterLayer, SpatialPolygons*,
#' SpatialPoints*, or matrix, containing features to be connected
#' to the road network. Matrix should contain columns x, y with coordinates,
#' all other columns will be ignored.
#' all other columns will be ignored. Polygon and raster inputs will be
#' processed by `getLandingsFromTarget` to get the centroid of harvest blocks.
#' @param weightRaster SpatRaster or RasterLayer. A `weightRaster` and `weightFunction`
#' together determine the cost to build a road between two adjacent raster cells.
#' For the default `weightFunction = simpleCostFn`, the `weightRaster` should specify the cost of
#' construction across each raster cell. The value of existing roads should be set to 0; if not
#' construction across each raster cell. The value of cells that contain existing roads should be set to 0; if not
#' set `roadsInWeight = FALSE` to adjust the cost of existing roads. To use the alternative grade penalty method,
#' set `weightFunction = gradePenaltyFn`, and provide a `weightRaster` in which:
#' * NA indicates a road cannot be built
Expand All @@ -54,18 +54,6 @@
#' interpreted as 100% grade).
#' @param roads sf lines, SpatialLines*, RasterLayer, SpatRaster. The existing road network.
#' @param roadMethod Character. Options are "ilcp", "mst", "lcp", and "snap".
=======
#' @param landings sf polygons or points, SpatRaster, RasterLayer, SpatialPolygons*,
#' SpatialPoints*, matrix, containing features to be connected
#' to the road network. Matrix should contain columns x, y with coordinates,
#' all other columns will be ignored. Polygon and raster inputs will be
#' processed by `getLandingsFromTarget` to get the centroid of harvest blocks.
#' @param weightRaster SpatRaster or RasterLayer. weights Raster where existing
#' roads must be the only cells with a weight of 0. If existing roads do not
#' have 0 weight set `roadsInWeight = FALSE` and they will be burned in.
#' @param roads sf lines, SpatialLines*, RasterLayer, SpatRaster. Existing road network.
#' @param roadMethod Character. Options are "ilcp", "mst", "lcp", "snap".
>>>>>>> b96540ec721aa63598cf23506b7ccfc903e0b443
#' @param plotRoads Boolean. Should the resulting road network be plotted.
#' Default FALSE.
#' @param mainTitle Character. A title for the plot
Expand Down Expand Up @@ -224,18 +212,18 @@ setMethod(
roadMethod = roadMethod,
landings = landings,
roadsInWeight = roadsInWeight)

# Check memeory requirements
rast_cells <- terra::ncell(weightRaster)
ram_needed_Mb <- 10^(-1.6+0.769*log10(rast_cells))
ram_avail_Mb <- terra::free_RAM()/1000

if(ram_needed_Mb > ram_avail_Mb){
warning("This road projection is expected to require ", ram_needed_Mb,
warning("This road projection is expected to require ", ram_needed_Mb,
" Mb of RAM but only ", ram_avail_Mb, "Mb is available. ",
"Consider closing other applications and/or running on a larger machine")
}

# browser()
sim$landingsIn <- sim$landings

Expand Down
7 changes: 0 additions & 7 deletions man/getLandingsFromTarget.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 1 addition & 6 deletions man/projectRoads.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f174ad0

Please sign in to comment.