Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement valley as initial method for corridor delineation #59

Merged
merged 27 commits into from
Jan 20, 2025

Conversation

fnattino
Copy link
Contributor

No description provided.

@fnattino fnattino linked an issue Jan 13, 2025 that may be closed by this pull request
@fnattino fnattino marked this pull request as ready for review January 14, 2025 14:35
tests/testthat/test-osmdata.R Show resolved Hide resolved
tests/testthat/test-osmdata.R Show resolved Hide resolved
})

test_that("raster data are correctly retrieved and merged", {
skip_on_ci()

dem <- load_raster(bb, asset_urls) |> CRiSp::reproject(32635)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In addition to loading the raster, this test would also require reprojection to work, and that the previously-retrieved DEM would be equal to the one loaded here. I have simplified this to make it more specific to the functionality of load_raster.

tests/testthat/test-valley.R Show resolved Hide resolved
R/valley.R Show resolved Hide resolved
#' @export
get_valley <- function(dem, river, crs) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that data reprojection did not fit well in here, and it should be taken care outside of the function. I have only left a check on whether the datasets have the same CRS. I have, however, introduced the bbox to limit the area of interest, what do you think?

R/valley.R Show resolved Hide resolved
#' - [AWS Copernicus DEM datasets](https://copernicus-dem-30m.s3.amazonaws.com/readme.html)
#' - [Data license](https://docs.sentinel-hub.com/api/latest/static/files/data/dem/resources/license/License-COPDEM-30.pdf)
# nolint end
default_stac_dem <- list(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since these are some relevant default data parameters, and the two of them should always be paired together, I have thought about moving this to the global namespace.

@fnattino fnattino requested a review from cforgaci January 14, 2025 14:36
Copy link
Contributor

@cforgaci cforgaci left a comment

Choose a reason for hiding this comment

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

Looks good, @fnattino! I left a couple of comments where I was not sure what the intention was.

Fyi, this is what I get with method = "buffer":
image

And this is the result with method = "valley":
image

R/corridor.R Show resolved Hide resolved
R/valley.R Show resolved Hide resolved
tests/testthat/test-corridor.R Show resolved Hide resolved
tests/testthat/test-valley.R Show resolved Hide resolved
@fnattino
Copy link
Contributor Author

Thanks for the review and for the plots @cforgaci!

Concerning the example in the README, should I then update it with the options method = "valley", segments = TRUE following #55 ? To be honest, I also like the current example which illustrates how to run the code with defaults , but let me know your thoughts about this!

@cforgaci
Copy link
Contributor

cforgaci commented Jan 16, 2025

Concerning the example in the README, should I then update it with the options method = "valley", segments = TRUE following #55 ? To be honest, I also like the current example which illustrates how to run the code with defaults , but let me know your thoughts about this!

@fnattino, I would replace the example in the README with method = "valley", segments = TRUE, or at least method = "valley", as I expect that to become the default.

@fnattino
Copy link
Contributor Author

OK, so then I have updated the default initial method to be "valley" - so that the snippet in the README can remain simple and mostly based on defaults, but we now use the valley method.

@cforgaci could I kindly ask you to update the graphics in the README file?

Copy link
Contributor

@cforgaci cforgaci left a comment

Choose a reason for hiding this comment

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

Thanks @fnattino. I left a question and a suggestion.

R/delineate.R Outdated Show resolved Hide resolved
R/corridor.R Outdated Show resolved Hide resolved
@cforgaci
Copy link
Contributor

@cforgaci could I kindly ask you to update the graphics in the README file?

yes, will doo, asap

@cforgaci
Copy link
Contributor

@cforgaci could I kindly ask you to update the graphics in the README file?

yes, will doo, asap

I updated the figure.

@fnattino
Copy link
Contributor Author

Fixed the last issues, let me know whether you still see something that should still be addressed here @cforgaci - I will otherwise merge it

Copy link
Contributor

@cforgaci cforgaci left a comment

Choose a reason for hiding this comment

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

Looks good, @fnattino! I only left a couple of tiny suggestions on the documentation while reading through the code. Feel free to merge.

R/valley.R Outdated Show resolved Hide resolved
R/valley.R Outdated Show resolved Hide resolved
fnattino and others added 2 commits January 20, 2025 15:21
Co-authored-by: Claudiu Forgaci <[email protected]>
Co-authored-by: Claudiu Forgaci <[email protected]>
@fnattino fnattino merged commit eb0181d into main Jan 20, 2025
8 checks passed
@fnattino fnattino deleted the 52-corridor-valley-fn branch January 20, 2025 14:22
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.

Use valley functions to setup initial corridor
2 participants