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

Add resistance reclass and reclass file option #231

Open
sean-streich opened this issue Apr 21, 2020 · 13 comments
Open

Add resistance reclass and reclass file option #231

sean-streich opened this issue Apr 21, 2020 · 13 comments
Assignees

Comments

@sean-streich
Copy link

Hello,
I am just starting to use Ciruitscape and have had success running my data. I am experimenting with different resistance vales in my raster and will eventually be testing dozens of different large maps. Would the reclass option allow me to use a single raster and adjust resistance values through different reclass files instead of the extensive work of making many large resistance files.

If so is there a guide or example I could follow to make a correct reclass file. I have not come across one in the examples given.
Thanks,
Sean

@vlandau
Copy link
Member

vlandau commented May 5, 2020

Hi Sean, sorry for the late response here. AKAIK, the reclass option is not supported in Circuitscape.jl. It is something that was used in the old Python version only.

@ranjanan can verify. Ranjan, the only place I saw it in the code was in config.jl here and in some test .ini files -- it doesn't appear to be used or referenced anywhere else in the code.

We should probably get rid of that option (remove from defaults and from any documentation). I did not see mention of it in old Circuitscape docs though.

@ranjanan
Copy link
Member

ranjanan commented May 5, 2020

Yes, this is something I haven't ported from the old Circuitscape because nobody asked for it. Honestly, I don't understand reclass files and what they do, or how to make one. @vlandau do you understand this piece of code? Happy to just put that in here blindly if that will just help @sean-streich

@vlandau
Copy link
Member

vlandau commented May 5, 2020

I'm pretty sure it's basically equivalent to a bunch of replace!() commands, where you replace the value in column one of the table with the corresponding value in column 2 in the resistance layer.

@vlandau
Copy link
Member

vlandau commented May 5, 2020

That is what a reclass does for sure -- but I meant that would be an equivalent way to implement it in Julia.

@vlandau
Copy link
Member

vlandau commented May 5, 2020

Makes sense to use if you have only a few (i.e. less than 100) different values in the resistance surface.

@ranjanan
Copy link
Member

ranjanan commented May 5, 2020

Ah I see. That makes sense, because practitioners tend to use only a few values and would simply like 1 value to be replaced by another. Is there a huge convenience to do this in Circuitscape? Don't GIS softwares have this feature? Users export their grids from GIS softwares anyway, don't they?

@vlandau
Copy link
Member

vlandau commented May 5, 2020

GIS programs certainly have this. The point being made by the OP is that this would require creating many large files instead of just computing and storing them in memory during computation.

@sean-streich
Copy link
Author

Thanks Vlandau,
Yes, this was my hope and I think it would be useful to have in the future. Creating each resistance file takes time and uploading it a server leads to about 20 minutes per file for me. A way to re-class values in julia (2=10, 3=5, ect) could possibly be a nice addition to more easily run many files if the goal was fit models. I have been following the Sackett et al. 2012 paper, where they fit 120 conductance models to genetic data, but maybe making such high numbers of models is not common.
I am new to julia and amateur in Linux. I was able to get Circuitscape working with my data it took a lot of effort. A new manual, or at least an addition could be helpful for more people to be able use this cool program. Like other recent posts, understanding memory usage and how many threads can be used in parallel took me a while to figure out.

@vlandau vlandau changed the title reclass file Add resistance reclass and reclass file option May 5, 2020
@vlandau
Copy link
Member

vlandau commented May 5, 2020

Okay -- we will keep that in mind. I believe there are goals to improve and develop documentation specific to Circuitscape.jl, but for now, the manual related to .ini file development can be found here: https://circuitscape.org/docs/ (that's presumably the one you already saw). It is specific to Circuitscape in Python, but nearly all of the .ini options are identical for Circuitscape.jl

@ranjanan, will of course leave the decision about whether to implement the reclass stuff to you.

@vlandau
Copy link
Member

vlandau commented Aug 7, 2020

I added a reclass feature for Omniscape and it didn't take much code. Something similar can probably be just as easily done for Circuitscape, so someone should feel free to do a PR and use my code.

Relevant code blocks here, here, and here.

@vlandau
Copy link
Member

vlandau commented Aug 7, 2020

@vlandau do you understand this piece of code? Happy to just put that in here blindly if that will just help @sean-streich

@ranjanan I think that code might actually be erroneous (unless I'm missing something, I'm not well-versed in Python), because of the way it's iteratively applied in a for loop to the object that is being reclassified. It might change 1's to 2's, then in the next loop, change 2's to 3's, which would incorrectly change the 1's that were changed to 2's to 3's as well. I tried something similar in my first pass in Omniscape and realized it's updating values that had already been updated once (I hadn't looked at the CS.py code). You'll see what I did to handle this in the links to my code above.

@ViralBShah
Copy link
Member

That code may be from @tanmaykm from a very long time ago, if he can remember.

@ViralBShah
Copy link
Member

FWIW, I personally don't remember the reclass option in the code. So, I'd go with your understanding of it and reproducing the feature in Circuitscape.jl.

@vlandau vlandau self-assigned this Dec 25, 2020
@ranjanan ranjanan mentioned this issue Jun 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants