ELSA-UNDP / elsar

Creative Commons Attribution 4.0 International
1 stars 0 forks source link

Combine functions that have the same structure #2

Open sandra-neubert opened 1 month ago

sandra-neubert commented 1 month ago

There are lots of functions that have a very similar structure that could easily be combined in a single function or there could be a data reading + rescaling utils function that is then simply called in the over-arching function. Thoughts @scabecks?

Very similar functions are:

~- [x] - make_certified_forests() (https://www.dropbox.com/scl/fi/k4fbd5buv7sr6zkebmt6f/FML_v3.2_near_cog.tif?rlkey=qcc0iza918cwf4addf8zwticr&dl=0)~

Similar but uses terra

Stand-alone functions seem to be:

sandra-neubert commented 1 month ago

A lot of the functions above (especially the similar ones) use very similar calculations (e.g. vals < 0 are set to 0; NAs are set to 0); are there any datasets where vals are accepted < 0 or are these general rules that could be integrated in a generic function @scabecks ?

scabecks commented 1 month ago

Currently any negative values in input layers are normalised to [0,1] since I believe negative values cause problems for the optimisation model.

sandra-neubert commented 1 month ago

@scabecks I'm more wondering about the way this is done. Why not rescale with the negative values to 0-1? Why set them to 0 before the rescaling? This might potentially not represent the original distribution of the data anymore and the rescaling also works with negative values. (also just fyi, with the next update of priortizr, it will take negative values for the maximum utility objective function)