Giter Club home page Giter Club logo

Comments (20)

julianoscabral avatar julianoscabral commented on May 29, 2024

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.

benj919 avatar benj919 commented on May 29, 2024

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.

julianoscabral avatar julianoscabral commented on May 29, 2024

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.

benj919 avatar benj919 commented on May 29, 2024

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.

julianoscabral avatar julianoscabral commented on May 29, 2024

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.

benj919 avatar benj919 commented on May 29, 2024

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.

julianoscabral avatar julianoscabral commented on May 29, 2024

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.

benj919 avatar benj919 commented on May 29, 2024

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.

julianoscabral avatar julianoscabral commented on May 29, 2024

I suppose I need to install the package again to get this fixed correction factor

from r-package.

julianoscabral avatar julianoscabral commented on May 29, 2024

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.

julianoscabral avatar julianoscabral commented on May 29, 2024

or can you send me the current tar.gz file?

from r-package.

julianoscabral avatar julianoscabral commented on May 29, 2024

I would keep the correction factor and explain the in the vignette

from r-package.

julianoscabral avatar julianoscabral commented on May 29, 2024

but I suppose you should ask Oskar and Loic on what they prefer

from r-package.

benj919 avatar benj919 commented on May 29, 2024

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.

julianoscabral avatar julianoscabral commented on May 29, 2024

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.

julianoscabral avatar julianoscabral commented on May 29, 2024

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.

benj919 avatar benj919 commented on May 29, 2024

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.

ohagen avatar ohagen commented on May 29, 2024

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.

julianoscabral avatar julianoscabral commented on May 29, 2024

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.

julianoscabral avatar julianoscabral commented on May 29, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.