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

Store results for calculate_lsm #154

Closed
mhesselbarth opened this issue Dec 19, 2019 · 8 comments
Closed

Store results for calculate_lsm #154

mhesselbarth opened this issue Dec 19, 2019 · 8 comments
Labels
enhancement New feature or request

Comments

@mhesselbarth
Copy link
Member

Not sure how complicated this will be (if even possible), but maybe we can somehow store results for e.g. the patch area and other values we need for several metrics during the calculation of calculate_lsm() so we don't need to calculate them n times.

@bitbacchus
Copy link
Member

Would make sense...

We'd need some class where we can store values and intermediate values as member variables alongside the functions. Each time such a value is needed in a function, it is retrieved from the member variable if it was calculated, already. Otherwise, it is calculated and stored to that member variable.

An alternative could be to give each function a List as an additional parameter, where it retrieves values if existing or stores them if not existing. This List is passed from one metric calculation to the next.

Maybe we should try one of the two with say, patch area, and see how messy it gets.

@mhesselbarth
Copy link
Member Author

Yes, that was my idea as well. I will have a look in the new year :)

@Nowosad Nowosad added the enhancement New feature or request label Jan 14, 2020
@bitbacchus
Copy link
Member

Idea: we could change landscapemetrics so that there would always be an lsm object on which the calculations would be performed, e.g.

lsm <- lsm(landscape_raster)

circle <- lsm.p_circle(directions = 8)
metrics <- lsm.calculate(level = c("class", "landscape"), 
                                 type = "aggregation metric")

This way, all interim results for the individual metrics could be saved in the lsm object and reused for subsequent calculations. And the lsm object can also be used as a container format, in which the raster can be stored/saved together with the calculated metrics.

@mhesselbarth
Copy link
Member Author

Not sure if I like this idea. I see that this approach would make it quite easy to store all the information needed. However, I like that is is currently possible to use raster objects without any need to modify/change/convert them. I think that this makes it convenient for many applications (e.g. allows to use a pipe quite easily).

@bitbacchus
Copy link
Member

Just a note, PyLandStats apparently has this feature. Maybe we can get some inspirations from there.

@mhesselbarth
Copy link
Member Author

FYI @Nowosad made some major progress and will be part of v2.1

@Nowosad
Copy link
Member

Nowosad commented Oct 2, 2023

@Nowosad
Copy link
Member

Nowosad commented Oct 6, 2023

#308

@Nowosad Nowosad closed this as completed Oct 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants