Skip to content

Commit

Permalink
Fix issue #55
Browse files Browse the repository at this point in the history
  • Loading branch information
dimitri-justeau committed Mar 15, 2023
1 parent 89bf373 commit 5aa9daf
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: restoptr
Type: Package
Title: Ecological Restoration Planning
Version: 1.0.4
Version: 1.0.5
Description:
Flexible framework for ecological restoration planning. It aims to identify priority areas for restoration efforts using optimization algorithms (based on Justeau-Allaire et al. 2021 <doi:10.1111/1365-2664.13803>). Priority areas can be identified by maximizing landscape indices, such as the effective mesh size (Jaeger 2000 <doi:10.1023/A:1008129329289>), or the integral index of connectivity (Pascual-Hortal & Saura 2006 <doi:10.1007/s10980-006-0013-z>). Additionally, constraints can be used to ensure that priority areas exhibit particular characteristics (e.g., ensure that particular places are not selected for restoration, ensure that priority areas form a single contiguous network). Furthermore, multiple near-optimal solutions can be generated to explore multiple options in restoration planning. The package leverages the 'Choco-solver' software to perform optimization using constraint programming (CP) techniques (<https://choco-solver.org/>).
Authors@R:
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# restoptr 1.0.5

- Fix issue related to a wrong argument name in terra::compareGeom (https://github.com/dimitri-justeau/restoptr/issues/55)

# restoptr 1.0.4

- Remove dependency to rgdal (see https://r-spatial.org/r/2022/04/12/evolution.html)
Expand Down
2 changes: 1 addition & 1 deletion R/restopt_solution.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ restopt_solution <- function(restopt_problem, solution_raster, metadata, id_solu
terra::hasValues(solution_raster),
terra::nlyr(solution_raster) == 1,
terra::compareGeom(
solution_raster, restopt_problem$data$existing_habitat, stopiffalse = FALSE
solution_raster, restopt_problem$data$existing_habitat, stopOnError = FALSE
)
)
# convert object to RestoptSolution
Expand Down
1 change: 1 addition & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ knitr::opts_chunk$set(fig.path = "man/figures/README-", fig.align = "center",
[![R-CMD-check-MacOS](https://github.com/dimitri-justeau/restoptr/actions/workflows/R-CMD-check-macos.yaml/badge.svg)](https://github.com/dimitri-justeau/restoptr/actions)
[![Coverage Status](https://codecov.io/github/dimitri-justeau/restoptr/coverage.svg?branch=master)](https://app.codecov.io/gh/dimitri-justeau/restoptr)
[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/restoptr)](https://github.com/dimitri-justeau/restoptr)
[![Downloads](https://cranlogs.r-pkg.org/badges/restoptr)](https://CRAN.R-project.org/package=restoptr)

```{r, include = FALSE}
devtools::load_all()
Expand Down
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
## Ecological Restoration Planning

[![lifecycle](https://img.shields.io/badge/Lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html)
[![R-CMD-check-Ubuntu](https://github.com/dimitri-justeau/rflsgen/actions/workflows/R-CMD-check-ubuntu.yaml/badge.svg)](https://github.com/dimitri-justeau/restoptr/actions)
[![R-CMD-check-Windows](https://github.com/dimitri-justeau/rflsgen/actions/workflows/R-CMD-check-windows.yaml/badge.svg)](https://github.com/dimitri-justeau/restoptr/actions)
[![R-CMD-check-MacOS](https://github.com/dimitri-justeau/rflsgen/actions/workflows/R-CMD-check-macos.yaml/badge.svg)](https://github.com/dimitri-justeau/restoptr/actions)
[![R-CMD-check-Ubuntu](https://github.com/dimitri-justeau/restoptr/actions/workflows/R-CMD-check-ubuntu.yaml/badge.svg)](https://github.com/dimitri-justeau/restoptr/actions)
[![R-CMD-check-Windows](https://github.com/dimitri-justeau/restoptr/actions/workflows/R-CMD-check-windows.yaml/badge.svg)](https://github.com/dimitri-justeau/restoptr/actions)
[![R-CMD-check-MacOS](https://github.com/dimitri-justeau/restoptr/actions/workflows/R-CMD-check-macos.yaml/badge.svg)](https://github.com/dimitri-justeau/restoptr/actions)
[![Coverage
Status](https://codecov.io/github/dimitri-justeau/restoptr/coverage.svg?branch=master)](https://app.codecov.io/gh/dimitri-justeau/restoptr)
[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/restoptr)](https://github.com/dimitri-justeau/restoptr)
[![Downloads](https://cranlogs.r-pkg.org/badges/restoptr)](https://CRAN.R-project.org/package=restoptr)

<p id="logo-credit" align="right">
Logo by Camille Salmon
Expand Down Expand Up @@ -318,7 +319,7 @@ existing habitat, or (`3`) selected as a priority area for restoration.
solution <- solve(problem)
```

## Good news: the solver found 1 solution statisfying the constraints that was proven optimal ! (solving time = 0.19 s)
## Good news: the solver found 1 solution statisfying the constraints that was proven optimal ! (solving time = 1.04 s)

``` r
# preview solution
Expand All @@ -330,7 +331,7 @@ print(solution)
## resolution : 447.1792, 475.8943 (x, y)
## extent : 419768.2, 495788.7, 227390.1, 283069.8 (xmin, xmax, ymin, ymax)
## coord. ref. : RGNC91-93 / Lambert New Caledonia (EPSG:3163)
## source : memory
## source(s) : memory
## categories : label
## name : Solution 1
## min value : Locked out
Expand Down Expand Up @@ -360,7 +361,7 @@ get_metadata(solution, area_unit = "ha")
## min_restore total_restorable nb_planning_units nb_components diameter
## 1 219.3772 [ha] 219.3772 [ha] 15 3 2280.175 [m]
## optimality_proven search_state solving_time mesh_initial mesh
## 1 TRUE TERMINATED 0.187 13667.84 [ha] 14232.66 [ha]
## 1 TRUE TERMINATED 1.024 13667.84 [ha] 14232.66 [ha]
## mesh_best
## 1 14232.66 [ha]

Expand Down
Binary file modified man/figures/README-habitat_data-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-locked_out_data-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-solution-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tests/testthat/test_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ test_that("spatial properties", {
x1 <- terra::rast(f1)
x2 <- terra::rast(f2)
x3 <- terra::vect(f3)
expect_true(terra::compareGeom(x1, x2, res = TRUE, stopiffalse = FALSE))
expect_true(terra::compareGeom(x1, x2, res = TRUE, stopOnError = FALSE))
expect_false(terra::is.lonlat(x1))
expect_false(terra::is.lonlat(x2))
expect_false(terra::is.lonlat(x3))
Expand Down

0 comments on commit 5aa9daf

Please sign in to comment.