GithubHelp home page GithubHelp logo

dismo's Introduction

rspatial

R package with data sets used in the material on the https://rspatial.org website to teach spatial data analysis with R.

You can install the package like this

remotes::install_github("rspatial/rspatial")

dismo's People

Contributors

aniucd avatar rhijmans avatar stewartmacdonald avatar stragu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

dismo's Issues

R stops working when I try to run maxent()

Dear Prof. Hijmans,

I am having trouble since yesterday, and I am hoping you could give me some light!

I am using macOS Monterey version 12.2.1 ; R version 4.2.2.

Everything was working fine, and suddenly my R sessions started getting stuck forever. After chasing the bugs for quite a long time, I found out that every function that used plot involving characters was making it get stuck. I partially fixed the problem by including this line in the beginning of my code: "options(bitmapType='cairo')" .

However, dismo::maxent is still causing the problem to happen. It is not an issue with the data, because it problem also happens when I try to run the example provided by dismo.

Because of the issue with the plotting I found before, I suppose there is something going wrong with the plotting of the variable contribution, and causing R to be stuck. I tried to crack into the function and run line by line to understand exactly where the bug is, but I did not manage to figure it out.

Sorry for bothering with this long question. I have been cracking my head for more than 12 hours straight, and I wonder if you have come across similar issues.

Thank you very much,
Eduardo

Weird errors when running maxent()

Hey dev team,
I have been using dismo for quite a long time and I have never run into errors like this before. I have been troubleshooting for days now and haven't been able to resolve the issue.

So basically, if I run maxent() with other data, using identical script, it works just fine... But I have a new dataset that I'm using, which I have double and triple checked the data for (occurences, raster variables, matching projections, no NA values) and it does not run with maxent(). When I try to run the following code:

mod <- dismo::maxent(x=pder, #env conditions
p=pa, #1=presence; 0=absence
path=paste0(getwd(),"/output/maxent_outputs"),
args=prepPara(userfeatures="L",
betamultiplier = 2,
replicates=10, ## 10 replicates
replicatetype="bootstrap")) # parameter specifications

I get this error:
Warning: Setting randomseed to true so that replicates are not identical
Error: Error reading files
Error in h(simpleError(msg, call)) :
error in evaluating the argument 'x' in selecting a method for function 't': cannot open the connection
In addition: Warning message:
In file(file, "rt") :
cannot open file 'C:/Users/Russe/Desktop/SVW/CivetPaper/Output/output/maxent_outputs/maxentResults.csv': No such file or directory

There is nothing wrong with the file directory, no issues with spaces in the names, or anything. I have tried dozens of other directories at this point and all of them run the same error. However, when I run my other data (in which maxent runs fine), I can save the output to this same directory without issue.

My data occurences are a species in Vietnam, all predictor variables are cropped and masked to Vietnam. "pa" is a presence absence vector, "pder" is a dataframe of extracted environmental values from the raster stack. Again, there are no NA values in my dataset.

Please help, I have no idea what else I could possibly do and the others who have run into this issue online still have no resolution posted.

Can't install dismo dependencies

This happens on Ubuntu 16.04 (ok, almost EOL, but not there yet), and 18.04 with R versions v3.2.3, and v3.4.4 respectively. With Ubuntu and 20.04 and R v3.6.3 the error is different, but it still does not install.

Am I doing something wrong or do the dismo dependencies have an issue? FWIW it fails in the same way also with either dependencies=FALSE or without that argument on the older OSes, but installation succeeds with dependencies=FALSE on Ubuntu 20.04

$ sudo Rscript --slave --no-save --no-restore-history -e "install.packages(pkgs='dismo', dependencies=TRUE, repos=c('http://ftp.heanet.ie/mirrors/cran.r-project.org/'));"

Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
Warning: dependencies ‘raster’, ‘terra’, ‘rgdal’, ‘rgeos’, ‘ROCR’, ‘deldir’ are not available
trying URL 'http://ftp.heanet.ie/mirrors/cran.r-project.org/src/contrib/dismo_1.3-3.tar.gz'
Content type 'application/x-gzip' length 1811212 bytes (1.7 MB)
==================================================
downloaded 1.7 MB

ERROR: dependency ‘raster’ is not available for package ‘dismo’
* removing ‘/usr/local/lib/R/site-library/dismo’

The downloaded source packages are in
‘/tmp/Rtmp4ar6Jc/downloaded_packages’
Warning message:
In install.packages(pkgs = "dismo", dependencies = TRUE, repos = c("http://ftp.heanet.ie/mirrors/cran.r-project.org/")) :
  installation of package ‘dismo’ had non-zero exit status

gbm.step() doesn't iterate for large continuous response variables

The iteration loop in gbm.step() doesn't ever start for some large-value continuous response variables.

library(dismo)
data(Anguilla_train)
Anguilla_train = Anguilla_train[1:200,]

fitcont = gbm.step(data = Anguilla_train, gbm.x = c(3:5, 7:14), gbm.y = 6, family = "gaussian",
                   tree.complexity = 5, learning.rate = 0.01, bag.fraction = 0.5)

#>  GBM STEP - version 2.9 
#>  
#> Performing cross-validation optimisation of a boosted regression tree model 
#> for DSDist and using a family of gaussian 
#> Using 200 observations and 11 predictors 
#> creating 10 initial models of 50 trees 
#> 
#>  folds are unstratified 
#> total mean deviance =  8013.378 
#> tolerance is fixed at  8.0134 
#> ntrees resid. dev. 
#> 50    5300.797 
#> now adding trees...
 

#> mean total deviance = 8013.378 
#> mean residual deviance = 4755.488 
#>  
#> estimated cv deviance = 5300.796 ; se = 365.367 
#>  
#> training data correlation = 0.848 
#> cv correlation =  0.707 ; se = 0.075 
#>  
#> elapsed time -  0.01 minutes

I poked around a bit in gbm.step() and I believe this is caused by the delta.deviance variable that is used as a condition in the while() loop that iterates through the number of trees by the step size. This variable has been hard-coded to be 1 before starting the loop, which works great for family = "bernoulli" and for smaller range continuous variables.

For some continuous variables with a large range, the while loop condition delta.deviance > tolerance.test can never be met when delta.deviance is 1 and the tolerance.test is mean.total.deviance * tolerance. In such cases, like the example above, the while loop never starts since its conditions are never met.

I tried changing the hard-coded delta.deviance from 1 to mean.total.deviance and things appeared to work fine for bernoulli and gaussian models. However, I don't know what other repercussions this has.

Another option to bypass this problem without changing the function is to make the tolerance really small for such variables so tolerance.test goes below 1 (but this may have other impacts) or to scale the response variable. If these are the best fixes, maybe add them as suggestions in the documentation?

Created on 2021-06-16 by the reprex package (v2.0.0)

java.awt.HeadlessException error running maxent through rJava

I don't know if this is the right place to put this question but I am trying to run the maxent function in the dismo package on macOS through rJava and keep getting this error message.

Error in rJava::.jcall(mxe, "S", "fit", c("autorun", "-e", afn, "-o", : java.awt.HeadlessException

Has anyone seen it before and know how to fix it? Thank you so much!

evaluate() uses model even if x is missing

According to the documentation of dismo::evaluate():

model any fitted model, including objects inherting from 'DistModel'; not used when x is missing

However, model is still required when x is not provided.

Is that an error in the documentation? Sorry if I am missing something obvious, I am not very familiar with the package.

(also: typo in "inherting")

> sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.4 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so

locale:
 [1] LC_CTYPE=en_AU.UTF-8       LC_NUMERIC=C               LC_TIME=en_AU.UTF-8       
 [4] LC_COLLATE=en_AU.UTF-8     LC_MONETARY=en_AU.UTF-8    LC_MESSAGES=en_AU.UTF-8   
 [7] LC_PAPER=en_AU.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=en_AU.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] mgcv_1.8-31  nlme_3.1-147 dismo_1.1-4  raster_3.1-5 sp_1.4-1     readxl_1.3.1

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.4.6     rstudioapi_0.11  magrittr_1.5     splines_3.6.3    lattice_0.20-41 
 [6] rlang_0.4.5      fansi_0.4.1      tools_3.6.3      rgdal_1.4-8      grid_3.6.3      
[11] packrat_0.5.0    cli_2.0.2        ellipsis_0.3.0   assertthat_0.2.1 tibble_3.0.1    
[16] lifecycle_0.2.0  crayon_1.3.4     Matrix_1.2-18    vctrs_0.2.4      codetools_0.2-16
[21] glue_1.4.0       compiler_3.6.3   pillar_1.4.3     cellranger_1.1.0 pkgconfig_2.0.3 

Citing GBIF data properly

Hello I am writing from GBIF.

I am doing a small outreach to those R packages that use GBIF occurrence search.

Under the terms of the GBIF data user agreement, users who download data agree to cite a DOI. Good citation also rewards data-publishing institutions and individuals by reinforcing the value of sharing open data and demonstrating its impact to their funders.

https://docs.ropensci.org/rgbif/articles/gbif_citations.html
https://www.gbif.org/citation-guidelines

Unfortunately, when using the occurrence search, rather than the occurrence download, one does not receive a citable DOI.

Because occurrence search is easier for some users to use, we have created something called derived datasets, which allows users to create a citable DOI after they have pulled the data from the GBIF public API.

https://www.gbif.org/derived-dataset

As a package maintainer, it would be appreciated by GBIF, if you could remind users in the documentation or with warning messages to cite the GBIF mediated data properly, perhaps by linking to one of these articles:

https://docs.ropensci.org/rgbif/articles/gbif_citations.html
https://www.gbif.org/citation-guidelines
https://www.gbif.org/derived-dataset

Also important to remind users to keep the datasetKey column because this allows for proper attribution to the original data providers.

problems loading raster package

Thank you in advance. I work with students doing SDM and we rely on dismo for most of our modeling. Recently, when trying to load the library, two students got an error message- 'error package 'raster' could not be loaded'. Both students had recently loaded the newest version of R and RStudio and are looking to run SDM for the first time. Dismo loads fine on my computer, though I haven't updated R or Rstudio in a few months. Any help would be welcome.

gbm.plot add param 'centered' to omit response data centering

Hi Robert,

By default gbm.plot centres (L77) the response data that it gets from plot.gbm (L71).

It would be nice if that could be turned off, so that one can easily plot the data the same way that plot.gbm exports it to csv. I was going to clone the function in my package and add this but I was wondering if you'd mind implementing the change upstream so others could avail of it? I've seen others run into this issue at various times.

The easiest way I see for this to happen would be change L77 from:

responses[[j]] <- response.matrix[,2] - mean(response.matrix[,2])

to:

if (centered) {
responses[[j]] <- response.matrix[,2] - mean(response.matrix[,2])
} else {
responses[[j]] <- response.matrix[,2]
}

Then add to the function call:
centered = TRUE, # center the response data (y axis) over zero

Thanks in advance! Plus points if it allows UK English spelling (centre/centred) as well :)

Cheers,

Simon

'terra' input formats

Hello! Is there a plan to implement 'terra' input formats (SpatRaster, SpatVector) in 'dismo' any time soon? Cheers!

circles() fails again (still?) at -180 lon

I think this is the same issue as #4. The example from that issue works with the current code, but the following doesn't:

library(dismo)

tmpPts <- data.frame(decimalLongitude = -179.916667,
                     decimalLatitude = -29.25)

circles(tmpPts, 10000, lonlat = TRUE)

Error: TopologyException: side location conflict at -179.9201118234478 -29.160219827926703. This can occur if the input geometry is invalid.

Convex Hull not working properly in version 1.3-5

ConvHull returns the correct convex hull polygon for example data in version 1.1-4.

pts <- matrix(c(17, 42, 85, 70, 19, 53, 26, 84, 84, 46, 48, 85, 4, 95, 48, 54, 66, 
 74, 50, 48, 28, 73, 38, 56, 43, 29, 63, 22, 46, 45, 7, 60, 46, 34, 14, 51, 70, 31, 39, 26), ncol=2)
train <- pts[1:12, ]
ch <- convHull(train)
plot(ch)

image

In version 1.3-5 running the same code returns this:
image

gbm.plot: y axis values reported incorrectly to plot.default?

Hi folks, sorry for the multiple recent messages.

In my package, I call gbm.plot, and was looking to add a simple abline at 0:

png(filename = paste0("./",names(samples[i]),"/Gaus_Best_line_",as.character(get(Gaus_Best_Model)$gbm.call$predictor.names[p]),".png"),
            width = 4*480, height = 4*480, units = "px", pointsize = 80, bg = "white", res = NA, family = "", type = pngtype)
        par(mar = c(2.3,5,0.3,0.6), fig = c(0,1,0,1), las = 1, lwd = 8, bty = "n", mgp = c(1.25,0.5,0), xpd = NA)
        gbm.plot(get(Gaus_Best_Model),
                 variable.no = p,
                 n.plots = 1,
                 common.scale = FALSE, #added to try to get cvs values to match pngs
                 smooth = smooth, # typically TRUE
                 rug = TRUE,
                 write.title = FALSE,
                 y.label = "",
                 x.label = NULL,
                 show.contrib = TRUE,
                 plot.layout = c(1, 1))
        abline(a = 0, b = 0, lty = 2, lwd = 20) # https://github.com/SimonDedman/gbm.auto/issues/7
        mtext("Marginal Effect", side = 2, line = 4.05, las = 0)

I initially tried abline(h=0) which had the same result: regardless of input - which is otherwise plotting great - the abline is at the bottom:

Gaus_Best_line_X CC

In this example, Y crosses 0 both in the raw data, as well as when centred:

image

Somewhat regardless, all data should be centred due to these lines from gbm.plot:

response.matrix <- gbm::plot.gbm(gbm.object, k, return.grid = TRUE)
responses[[j]] <- response.matrix[, 2] - mean(response.matrix[, 2])
plot(predictors[[j]], responses[[j]], type = "l",  xlab = x.label, ylab = y.label, ...)

I've looked and looked and can't for the life of me work out why this isn't working. A simple abline call works fine:

plot(-5:5, -5:5)
abline(h=0)

On a whim, I tried adding ablines at 0, 0.5, 1, 2, 5, 10, 100, and get the following - the lines are in the same place for every plot regardless of changing Y axis scales, suggesting the underlying plot seemingly isn't operating on the standard plot scale somehow?

Gaus_Best_line_X CC

Any ideas or gut feelings very much appreciated.

CLOGLOG response curves

Hello!
I am using ENMeval to generate distribution models. I am converting the selected models to a CLOGLOG output through the "predict" function and everything turns out very well.

I would also like to see the response curves, but in CLOGLOG type. However, I don't know how to do it. I'm trying through the "response" function, but it doesn't work directly on the converted model since it is no longer of type "MaxEnt".
I would like to try the "fun" argument, but I don't understand how it works and I can't find any examples. https://www.rdocumentation.org/packages/dismo/versions/1.3-3/topics/response

I hope someone can help me, thank you...

install Error

install.packages("https://cran.r-project.org/src/contrib/Archive/dismo/dismo_1.3-3.tar.gz",repos=NULL,type="source")
Installing package into '/users/oks001/bin/R-oks/renv/library/R-3.6/x86_64-redhat-linux-gnu'
(as 'lib' is unspecified)
trying URL 'https://cran.r-project.org/src/contrib/Archive/dismo/dismo_1.3-3.tar.gz'
Content type 'application/x-gzip' length 1811212 bytes (1.7 MB)
==================================================
downloaded 1.7 MB

  • installing source package 'dismo' ...
    ** package 'dismo' successfully unpacked and MD5 sums checked
    ** using staged installation
    ** libs
    g++ -m64 -std=gnu++11 -I"/usr/include/R" -DNDEBUG -I"/users/oks001/bin/R-oks/renv/library/R-3.6/x86_64-redhat-linux-gnu/Rcpp/include" -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -c RcppExports.cpp -o RcppExports.o
    g++ -m64 -std=gnu++11 -I"/usr/include/R" -DNDEBUG -I"/users/oks001/bin/R-oks/renv/library/R-3.6/x86_64-redhat-linux-gnu/Rcpp/include" -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -c percRank.cpp -o percRank.o
    g++ -m64 -std=gnu++11 -shared -L/usr/lib64/R/lib -Wl,-z,relro -o dismo.so RcppExports.o percRank.o -L/usr/lib64/R/lib -lR
    installing to /users/oks001/bin/R-oks/renv/library/R-3.6/x86_64-redhat-linux-gnu/00LOCK-dismo/00new/dismo/libs
    ** R
    ** data
    ** inst
    ** byte-compile and prepare package for lazy loading
    Error in setMethod("convHull", signature(p = "matrix"), function(p, n = 1, :
    no existing definition for function 'convHull'
    Error: unable to load R code in package 'dismo'
    Execution halted
    ERROR: lazy loading failed for package 'dismo'
  • removing '/users/oks001/bin/R-oks/renv/library/R-3.6/x86_64-redhat-linux-gnu/dismo'
    Warning message:
    In utils::install.packages("https://cran.r-project.org/src/contrib/Archive/dismo/dismo_1.3-3.tar.gz", :
    installation of package '/tmp/RtmpBgCGVf/downloaded_packages/dismo_1.3-3.tar.gz' had non-zero exit status

Add exportMethods(plot) & exportClasses(ModelEvaluation) to NAMESPACE

Hi Robert, hope you're well. I was wondering if it would be possible for you to add

exportMethods(plot)
exportClasses(ModelEvaluation)

to dismo's NAMESPACE?

I'm trying to run a function which uses various dismo functions including evaluate, and then plotting the resultant object, but it's suddenly started failing with

plot: Error in as.double(x): cannot coerce type 'S4' to vector of type 'double'

I believe this may be because dismo doesn't export its plot method of ModelEvaluation class, so when run in a function, plot defaults to base graphics, and thus expects x to be a double rather than a ModelEvaluation class.

Thanks in advance, and thanks for all of your work on this!

gridSample: return spatialPoints object rather than matrix?

I'm using gridSample to thin my occurrence records. The records are stored as a spatialPointsDataframe, which already includes environmental values as columns in the dataframe. gridSample returns a matrix with the coordinates of the retained occurrences, but drops all the other data columns. Is it possible to thin the data in a way that retains the non-coordinate columns? Alternatively, is there a way to use the matrix returned by gridSample to subset the original spatialPointsDataframe?

Thanks

r studio crashing with maxent()

r studio crashes when i try to run this code:
[ Asclepias_curtissii_enm.mx <- maxent(species = Asclepias_curtissii_enm, env = envt.subset, test.prop = 0.25) ]

it also crashes with the same Java message when running maxent() in the example code in the documentation.

OS version: Catalina 10.15.7
Java version: 15.0.1
R version: 4.0.3
R studio version: 1.2.1335
Maxent version: 3.4.4

This is the message when it crashes. A specific error message doesnt print in the console.
image

gbm.step unable to fit some models

Hello,

I've been using dismo gbm function gbm.step with the following hyperparameters:

brt <- gbm.step(data = train,
                          gbm.x = 5:9, # column indices for covariates
                          gbm.y = 4, # column index for response (presence-absence)
                          family = "bernoulli",
                          tree.complexity = ifelse(prNum < 50, 1, 5),
                          learning.rate = 0.001,
                          bag.fraction = 0.75,
                          max.trees = 10000,
                          n.trees = 50,
                          n.folds = 5, # 5-fold cross-validation
                          silent = TRUE) # avoid printing the cv results

The issue that I am encountering is related (I think) to the max.trees parameter or n.trees parameter. Species with low prevalence (20~30 presences out of 449 absences) return the following error:

Error in UseMethod("predict") :
no applicable method for 'predict' applied to an object of class "NULL"
In addition: There were 50 or more warnings (use warnings() to see the first 50)

The model brt becomes NULL and my loop stops because of that. I tried to use ifelse for those species, changing the number of max.trees to 50, and it worked for some of them, but not all. Any idea about what is happening here? I haven't found anything like this on the internet. If needed, I can upload my script and rds files. Thanks!

Voronoi calculation errors

This question has full details https://stackoverflow.com/questions/62735729/voronoi-errors-with-dismovoronoi

As I understand it R lacks a methods to buffer polygons in a spatially exclusive way that preserves the topology of adjacent polygons. So I'm experimenting with an approach that generates voronoi polygons of the original polygon vertices. Results seem quite promising except for apparent errors in the voronoi generation.

This is a minimal code version:

require(rworldmap)
require(rgeos)
require(dismo)
require(purrr)
require(dplyr)
par(mai = rep(0,4))

p = rworldmap::countriesCoarse[,'ADMIN']
p = p[p$ADMIN %in% c('United States of America', 'Canada'),]
p$ADMIN = as.character(p$ADMIN)
p = rgeos::gBuffer(p, byid=T, width = 0) # precaution to ensure no badly-formed polygon nonsense

p_buff2 = rgeos::gBuffer(p, byid=T, width = -.00002) # order of 1 metre

vertices2 = map_df(p_buff2@polygons, ~ map2_df(.x@Polygons, rep(.x@ID, length(.x@Polygons)), 
                                               ~ as.data.frame(..1@coords) %>% `names<-`(c('x','y')) %>% mutate(id = ..2)))
coordinates(vertices2) = vertices2[,1:2]

vor2 = dismo::voronoi(vertices2)

plot(p_buff2)
plot(vertices2, add=T, pch=16, cex=.4, col = c('red','blue')[factor(vertices2$id)])
plot(vor2, add=T, border='#00000010', col = c('#FF000040','#0000FF40')[factor(vor2$id)])

image

Note the misclassified buts of British Colombia and Alaska.

Continuous data for binary distribution

change request

Dear developers,

I tried your gbm.step function to model continuous data in binomial distribution (e.g. proportion of successful cases). This is easy to run in original gbm but I need your additional function output. As the matter of fact your code restricts to binary input and the function fails with my continuous data. It would be really nice, if you could change the input to the full data range [0,1]. I have analysed your code and it would mean a change of code within two lines.

Cheers
Anne

Error when running ecocrop() function

When all values of minv are 0 in running .doEcocrop() inner function, maxper is also set 0. But this is incorrect because in .ecoSpat() inner function, the e@suitability[0] simply does not exist.
In my opinion, to solve this issue, in the line 215 of the code "ecocrop.R", the value of obj@maxper has to be 1 instead of 0.

Rug plot missing from first variable from gbm.plot()

If you're plotting all variables, then variable.no=0. The test for plotting the rug therefore fails, because the zeroth column is not a vector. In this test 'variable.no' should be replaced with 'k' I think. Or, the very first test there could be 'if (plot.count==1 & n.plots==1)'.

if (plot.count == 1) {
if (write.title) {
title(paste(response.name," - page ",n.pages,sep=""))
}
if (rug & is.vector(data[,gbm.call$gbm.x[variable.no]])) {
rug(quantile(data[,gbm.call$gbm.x[variable.no]], probs = seq(0, 1, 0.1), na.rm = TRUE))
}

Had some issues with factor plotting in ggPD_boot, plus y axis scale not responding to common.scale. 'Fixed' version attached

Hi there,

Had some issues plotting predictor-response plots with ggPD_boot in dismo. Appeared to be a problem whereby the code overwrote the plots created under is.factor == TRUE with the following lines for type.ci == "lines" or type.ci == "ribbon". Added an "else" between the two segments to avoid that. Also added na.rm = TRUE to the mean(), min() and max() commands that set the y axis limits when common.scales == T, as I was getting NAs. The issues may have been unique to my model (source file supplied as "model_outputs.R" in the zipfile in case you want to recreate the issues with the existing code) or I did something else stupid in setting up the model to plot, but the attached modified version of ggPD_boot (ggPD_boot_daveT) seems to work as expected. Would welcome any feedback!
ggPD_boot_daveT.zip

cv.threshold definition

Hello, I am using GBM and Dismo to created boosted regression trees for species distribution modelling, I then predict these models onto raster stacks, and classify this continuous raster into presence/absence using a threshold.

I have been trying to find a definition of cv.threshold (MODEL$cv.statistics$cv.threshold), as I think that is what I want to use as my threshold. But can't seem to find any definitions. Aside from mention in this paper

Thanks

Unsynchronized

The repository here appears to not be current with what is on CRAN. That is, CRAN is showing v1.3-14, whereas the DESCRIPTION here shows v1.3-10.

RandomPoints output

Hello,

I am using RandomPoints function to generate random points using a probability weight. Below, I compare the results using dismo vs raptr packages.

require(raster)
RR <- raster()
RR <- disaggregate(RR, 10)
RR[] <- 1:ncell(RR)/ncell(RR)
RandomDismo <- dismo::randomPoints(mask = RR, n = 10000, prob = TRUE)
RandomRaptr <- raptr::randomPoints(mask = RR, n = 10000, prob = TRUE)
plot(RR, box = F, axes = F, legend = F)
points(RandomDismo, pch = 19, cex = 0.25, col = "blue")

image

plot(RR, box = F, axes = F, legend = F)
points(RandomRaptr, pch = 19, cex = 0.25, col = "blue")

image

I expect more points to be sampled from green areas (higher values at the mask grid).
I understand that both functions should not be identical due to randomizations, but the pattern for dismo points is not convincing. I quote this from the help dismo::randomPoints function:

If the coordinate reference system (of mask) is longitude/latitude, sampling is weighted by the size of the cells. That is, because cells close to the equator are larger than cells closer to the poles, equatorial cells have a higher probability of being selected.

This may be the reason for the example provided above, but I noticed the same issue when using a mask layer in an equal area projection.

The intention of using the function was to produce spatially biased background locations to be used in a maxent model. The area of interest was the Nordic Sea (Arctic Ocean) with the mask layer projected in an equal-area projection.

Cheers,
Ahmed

CRAN push?

Hi folks,

Would you have any aversion to pushing the latest version of dismo to CRAN at some point when it's convenient?

I'm sorry to even ask - the reason is, I'm having to push recent edits of my package to CRAN in order to address previous dependencies on rgdal etc, but doing so will render the package unable to be installed, since it relies on dismo v1.3-10, which isn't on CRAN, but includes the tweaks you very kindly made a couple of months ago.

Many thanks in advance. Best wishes,

Simon

Can gbm.step (and other functions) have a line to automatically convert input data to data.frame OR warn if tibble, etc.?

Just spent an instructive half hour changing lines in the gbm.step code to get around an error which presented as:

Error in y.data[model.mask]:
! Can't subset columns with model.mask.
x Logical subscript model.mask must be size 1 or 1, not 3779.

Turns out I'd tidied up my code and deleted the line where I converted my dataset into a data.frame, meaning it was left as a tibble after importing the raw data and manipulating it with dplyr.

Result of this is that eval() interpreted by gbm.y variable as a one variable tibble not a vector. Subsequent attempts to subset the y variable for folding etc. then fail throughout the gbm.step code. I 'fixed' this by changing all the lines that didn't work, before realising that the problem was the format of my input data!!!

Can the gbm.step code be modified so that it either converts to a data.frame (with or without a message) OR exits with a warning that the input data are not in the correct format/class?

In the meantime I'll just follow the help file instructions that clearly say that the Argument 'data' must be a data.frame!!

Cheers!

David Tickler

package ‘dismo’ is not available (for R version 3.6.3)

Hi Dr Hijmans
I am having trouble installing dismo in my R version 3.6.3 (2020-02-29) on Ubuntu. Below you can find session info and the warning.
Can you help at all?
Thanks,
Rita

session_info()
─ Session info ───────────
setting value
version R version 3.6.3 (2020-02-29)
os Ubuntu 16.04.7 LTS
system x86_64, linux-gnu
ui RStudio
language (EN)
collate en_US.UTF-8
ctype en_US.UTF-8
tz Europe/Lisbon
date 2022-01-31
rstudio 1.3.1073 Giant Goldenrod (server)
pandoc NA

───────────
install.packages('dismo')
Installing packages into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
Warning in install.packages :
package ‘dismo’ is not available (for R version 3.6.3)

predicted value 0 when working with response() function

I am trying to make response curves from my maxent model using the response() function in dismo. However, whenever I plot the response curves I always get my predicted value as 0.0. Is there anyway to look into my maxent model to understand why it is doing this? Or has anyone else experienced this when working with the response function? Thank you so much!

circles() fails when polygons cross the antimeridian

When points lie close to +/-180° of longitude, it may happen that a polygon created by circles() has to cross the antimeridian. Depending on how "dissolve" is set, the command then either fails with

Error in rgeos::gUnaryUnion(ci@polygons) :
TopologyException: Input geom 0 is invalid: Self-intersection at or near point X Y

or the resulting polygons are broken. I hope the following example illustrates the issue:

library(dismo)
library(maptools)
data("wrld_simpl")

# example locations
locations <- SpatialPoints(coords=cbind(c(0,0,0,0, 175, -160), c(10, 30, 50, 70,0,-10)),
                    proj4string = CRS("+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0"))

plot(wrld_simpl)
points(locations, pch=19, col="blue")

# this gives an error because of self-intersection
buffer <- circles(p = locations, d = 1500000, lonlat=TRUE)

# this exercutes:
buffer <- circles(p = locations, d = 1500000, lonlat=TRUE, dissolve=FALSE)
# but looks weird:
plot(wrld_simpl)
plot(buffer, add=TRUE, col="red")
points(locations, pch=19, col="blue")
# ... and leads to problems later on
gUnaryUnion(buffer@polygons)

I've spend numerous hours now trying to find an alternative, somehow work around the issue, or manually clean up the broken output. But it's always one step forward and two steps back, so I hope this can somehow be fixed at the source …

plot in bioclim model

I am currently working with the dismo package in R, specifically utilizing the bioclim function to model species distribution. While exploring the plot function with objects obtained through the bioclim function, I encountered red crosses and green points in the generated plots. However, I'm struggling to understand the significance of these visual elements.

Could someone kindly explain what the red crosses and green points represent when executing the plot function with an object obtained using the bioclim function from the dismo package? Additionally, I'm curious why these red crosses and green points change when modifying the "p" parameter of the plot function.

I'm running
plot(bc, a=1, b=2, p=0.85)
plot(bc, a=1, b=2, p=0.75)

I'm still unclear on the interpretation of the red crosses and green points.
Any insights or explanations would be greatly appreciated.
Thank you in advance for your assistance!

Maxent License change

Maxent does not appear to have commercial/profit based restriction use after the change in 3.4 to an MIT license. The docs should be updated to reflect that. I also wonder if it's worth mentioning the alternative maxnet (n e t) R package made by the same group, as rJava continues to be a major installation trouble for users on all platforms.

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.