Skip to content

Raster to terra update- KHuber#38

Open
kehuber wants to merge 1 commit into
steps-dev:masterfrom
kehuber:terra-update
Open

Raster to terra update- KHuber#38
kehuber wants to merge 1 commit into
steps-dev:masterfrom
kehuber:terra-update

Conversation

@kehuber

@kehuber kehuber commented Feb 25, 2026

Copy link
Copy Markdown

Raster to Terra updates.
Notable changes:

  • no longer supports multisessions due to terra C++ pointers breaking if SpatRaster passed between sessions
  • package raster data now available as function calls (egk_pop(), egk_hab(), etc.) due to C++ pointer issue with loading data with data()
  • all function calls working with RasterLayers are converted to SpatRasters

Passing all tests and checks prior to pushing. Documentation and helpfiles updated where appropriate.

habitat_dynamics = NULL,
timesteps = 10,
replicates = 3,
timesteps = 3,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you change the test values? timesteps and replicates.

Are the simulations running slower with the terra version of the package and this change is to stay under the maximum time limit of the CRAN checks? Old values breaking the tests? Or just tinkering?


pop_dyn_kd_large <- population_dynamics(change = NULL,
dispersal = kernel_dispersal(exponential_dispersal_kernel(distance_decay = 8000), max_distance = 100000),
dispersal = kernel_dispersal(exponential_dispersal_kernel(distance_decay = 8000), max_distance = 1000),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why have you reduced max_distance?

dispersal = cellular_automata_dispersal(min_cells = 0,
max_cells = 10),
dispersal = cellular_automata_dispersal(min_cells = c(0, 0, 0),
max_cells = c(5, 10, 10)),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why change these values? Is it just setting them age class specific?

@Doi90 Doi90 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've gone through the changes and they generally look fine, and I ran some tests locally to compare the numbers that come out of the raster vs terra versions of the package and they're identical. Nice work.

Before I merge this PR in though I've left a couple of questions about parameter value changes in the tests. Can you say why they got changed? If the simulations are running slower with terra such that they need to be reduced for stay under CRAN time limits then we'll need to look at ways to speed things back up.

@kehuber

kehuber commented Jul 15, 2026

Copy link
Copy Markdown
Author

Hi @Doi90,

Thanks for posting your comments to the pull request. I believe the first two changes you noted were from me reducing testing time for my debugging, forgetting to switch back to original values. Apologies for not noting them in my original report out- I must have forgotten about those changes.

  • The test_population_change_functions.R script takes 11.76 seconds to run with the original values.

  • test_population_change_functions.R script takes 70.33 seconds with max_distance = 1000 and 96.95 s with the original max_distance = 100000.

  • My changes to the cellular_automata_dispersal() call in that test_population_change_functions.R script were to avoid the many warnings that arise with the original single values: "3 life stages exist but 1 maximum cell movement(s) of 10 were specified. All life stages will use this distance." No failures, just warnings. Passing in vectors instead avoids these.

  • Testing the package fully takes 206 s with the original values.

Full package check takes 667s, which is a little over 11 minutes, with the original parameter values. This may be slightly long for CRAN, but I will defer to you on this. I don't have easy access to perform a check on the original steps package (raster version) currently, so I will leave it up to you if you think the terra implementation is taking too long to run and needs more optimization.

Thanks for your time reviewing this! Please keep me updated with anything else I can help with.

Best,
Kate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants