GithubHelp home page GithubHelp logo

danddr / use Goto Github PK

View Code? Open in Web Editor NEW
5.0 1.0 1.0 26.11 MB

A R package to perform uniform sampling in the environmental space

Home Page: https://danddr.github.io/USE/

R 100.00%
environment sampling-methods species-distribution-modelling uniform

use's People

Contributors

danddr avatar olivroy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

ailich

use's Issues

Allow Subsample for RasterPCA

Fitting a PCA on large rasters can take a lot of time, so it could be useful to allow for a subsample of data to be used. This was done in RSToolbox via the nsamples argument. I believe this feature would only require a minor change to the code here, by allowing for a user specified value in rastPCA to be passed to the maxcell argument of terra::layerCor.

rastPCA code suggestions

I noticed a minor mistake and something that could be made more efficient in rastPCA.

In rastPCA, an NA mask is created using maskNA <- is.na(env.rast[[1]]), but the [[1]] indicates that it is only checking for NA values in the first layer rather than all layers. RSToolbox uses totalMask <- !sum(calc(img, is.na)) to check across all layers. RSToolbox uses the raster package, but the equivalent terra code would be totalMask <- !sum(app(img, is.na)).

I also noticed that the entire raster is coerced to a dataframe to get the sample size in eigenDecomp$n.obs <- nrow(as.data.frame(env.rast[[1]])). Converting the dataset to a dataframe slows things down and isn't memory safe. It'd be better to count up the valid cells (i.e. cells that don't have NA values in any layer). In RSToolbox this is done with model$n.obs <- cellStats(!any(is.na(img)), sum). The equivalent terra code would be model$n.obs <- global(!any(is.na(img)), sum)$sum

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.