Comments (20)
I´m neutral on this. Either option is fine. I can say in the vignette that they have to define the cost function in meters because the coordinate system is in meters for real landscapes. However, for hypothetical landscape that is not relevant, right?
from r-package.
It is: it unconditionally scales the cost by 1/1000.
E.g. in your landscape example the costs will be ~0.001 to ~0.0007 if you define your costs as 1 for unit costs.
from r-package.
humm, I had to scale to 1/100 to get to my previous euclidean distance to ~1:
my_cost_function <- function(x, h_x, y, h_y){
if(all(h_x, h_y)){
return(0.01) #scaling to 1/100 to get to the 1 eucledean distance
} else {
return(0.01) #scaling to 1/100 to get to the 1 euclidean distance of ~1
}
}
from r-package.
Interesting... If you print the summary from your converted rasters what are the values displayed?
> ras
class : RasterLayer
dimensions : 31, 31, 961 (nrow, ncol, ncell)
resolution : 1, 1 (x, y)
extent : 0.5, 31.5, 0.5, 31.5 (xmin, xmax, ymin, ymax)
crs : NA
source : memory
names : X0Ma
values : 19.11462, 20.2672 (min, max)
Using a raster such as this I get cost values of 1 for a cost function of 1, correction values of 1.41 or 1 (straight line or diagonal neighbour) and they get multiplied by an additional factor of 1/1000. I'm not quite sure how you'd get another factor of ten in there? What are the resolution, extents, and maybe crs in your rasters?
from r-package.
It looks like this:
temp[[1]]
#> class : RasterLayer
#> dimensions : 31, 31, 961 (nrow, ncol, ncell)
#> resolution : 1, 1 (x, y)
#> extent : 0.5, 31.5, 0.5, 31.5 (xmin, xmax, ymin, ymax)
#> crs : NA
#> source : memory
#> names : layer
#> values : 19.4393, 21.20974 (min, max)
but when I look into the produced distance matrix file without correcting the cost function:
449 450 480 481
449 0.0000 106.4857 110.6639 153.7683
450 106.4857 0.0000 153.7683 110.6639
480 110.6639 153.7683 0.0000 107.0343
481 153.7683 110.6639 107.0343 0.0000
when I correct the cost function as above (with 1/100), I get then closer to 1:
449 450 480 481
449 0.000000 1.067640 1.106587 1.539524
450 1.067640 0.000000 1.539524 1.106587
480 1.106587 1.539524 0.000000 1.072964
481 1.539524 1.106587 1.072964 0.000000
from r-package.
There are more than two distinct distance values in there... Can you send me 2 of your data frames, cost function, and the call to the create_input function you are using by mail?
from r-package.
that is all in the vignette create_input.Rmd in branch Juliano. I´m working on it right now. But I´m sending the vignette file to you per email then.
from r-package.
I have fixed the correction factor; a default reference coordinate system snuck in there and made it interpret your coordinates as a patch on the equator of earth. The distances were therefore ~100km, which corresponds to a 1 degree resolution on earth coordinates, explaining why you needed a 1/100 correction.
As such you'll have to multiply your cost by *1000 to get to cells values in you artificial inputs with this fix.
The overarching question of whether or not to have that 1/1000 inside the function or not remains.
from r-package.
I suppose I need to install the package again to get this fixed correction factor
from r-package.
can you tell me the version and need to install then? E.g. for the code:
install.packages("gen3sis_0.9.2.tar.gz", repos = NULL, type = "source")
from r-package.
or can you send me the current tar.gz file?
from r-package.
I would keep the correction factor and explain the in the vignette
from r-package.
but I suppose you should ask Oskar and Loic on what they prefer
from r-package.
I have fixed it on the master branch here, you can download it from the main repo view or with this link:
https://github.com/project-Gen3sis/R-package/archive/master.zip
from r-package.
I tried this as it is given in the rep and failed:
devtools::install_github(repo = "project-Gen3sis/R-package/", dependencies = T, build_vignettes = T)
Error in parse_git_repo(repo) :
Invalid git repo: project-Gen3sis/R-package/
from r-package.
install.packages("R-package-master.zip", repos = NULL, type = "source")
does not work either apparently.
Before I used install.packages("gen3sis_0.9.2.tar.gz", repos = NULL, type = "source") from the tar file Oskar send early this year. That is why I asked for the .tar.gz file.
from r-package.
I assume you're using Rstudio? If so checkout the master branch and use "Build" -> "Install and Restart" to install the current master branch as package.
I don't install private repos from github directly, but you need a way to authenticate yourself with github:
https://happygitwithr.com/github-pat.html
untested but looks about right
from r-package.
Yes, let's define it as meters! I feel tempted to remove the scaling but I rathre will let you do it, since you worked on that part recently. Let us know here when it's solved. This will make the package more intuitive! so, input units in m or whatever you want for landscapes without crs
from r-package.
So, the distance matrices look correct with that bug fixed. But Oskar wants to define as meters, so the user does not need to bother with adding a correction factor.
from r-package.
So, when that is decided the vignette can be updated. Otherwise the vignette for create_input() is more or less finished.
from r-package.
Related Issues (20)
- plot_summary fails if simulation ends before reaching step 0
- axis label for time series in summary plot is wrong
- specificy alternatives on plot_summary documentaiton regarding the sgen3sis.rds
- starting richness plots and range plots(pdfs) are not the same as when called for the first timestep in the call_observer function.
- multiple richenss plot with tag -1 when simulation starts with multiple species
- introduction vignette, richness plot
- versions history HOT 1
- Color palett of the ouput for color-blind people HOT 2
- misplaced loop_ecology() call HOT 1
- implement CI HOT 16
- South America distances missing HOT 4
- build package NOTE
- vignette problems in CRAN Should be corrected by 2021-10-19 to safely retain gen3sis on CRAN. HOT 1
- add colaborations file to git
- CRAN Fixes gen3sis 1.4 HOT 1
- add new check functions? HOT 1
- potential improvement of distance matrix calculation HOT 3
- NEWS version history HOT 1
- Check package for dependencies expiring soon. HOT 3
- accounting problem for speciation followed by extinction HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from r-package.