Git Product home page Git Product logo

botanyenmworkshops's Issues

installation of rangeBuilder *must* be through github

^ Otherwise errors will occur leading you to multipolygon (sf) objects. To install 'correctly' use
remotes::install_github('ptitle/rangeBuilder')
version should be 1.6 as of 02/20/2023,
2.0 is the Cran version and does not work with our current scripts.

rangeBuilder and rnaturalearth fails to successfully call API

In Lesson 4 ClimateProcessing there is an erroneous API call that will cause getDynamicAlphaHull() to fail.

hull <- rangeBuilder::getDynamicAlphaHull(x = alldfsp@coords, fraction = 1, # min. fraction of records we want included partCount = 1, # number of polygons initialAlpha = 20, # initial alpha size, 20m clipToCoast = "terrestrial") # proj = "+proj=longlat +datum=WGS84") # Appears that this is currently disfunctional.

Will yield:

Downloading a world basemap for clipping. This only needs to happen once.


trying URL 'http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/50m/physical/ne_50m_land.zip'
Error in utils::download.file(file.path(address), zip_file <- tempfile()) : 
  cannot open URL 'http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/50m/physical/ne_50m_land.zip'
In addition: Warning message:
In utils::download.file(file.path(address), zip_file <- tempfile()) :
  cannot open URL 'https://www.naturalearthdata.com/http/www.naturalearthdata.com/download/50m/physical/ne_50m_land.zip': HTTP status was '404 Not Found'

The failed call appears to be related to the missing '/' in 'https://www.naturalearthdata.com/http/www.naturalearthdata.com/download/50m/physical/ne_50m_land.zip' after the 'http/' as pointed out by Makenzi.

Fix currenlty is to run
install.packages("rnaturalearth")
As rnaturalearth seems to be the root of the erroneous call. This fix does not seem to be ubiquitous across systems however as it didnt resolve my errors until trying it at a later time (possibly calling the API too many times?).
Possible reasons listed prior were firewalls by university internet (seems unlikely), Rversion, or Operating System.

Fix has been tested on the cluster using versions 4.0 & 4.2 without errors. Will try on Windows operating system on non-university wifi at a later date.

EcoSpat requires older versions

Issues exist on R version 4.2 for ecospat related to failing to download biomod2 dependent package correctly.

Current fix:
Use R version 4.1
install.packages("biomod2") install.packages("biospat") packageVersion("ecospat)

Version should be '3.5'

06_Ecological_niche_modeling rJava memory allocation

The current memory allocation using options(java.parameters = "- Xmx16g") raises the following error when running dismo::maxent(...)
Loading required namespace: rJava
Unrecognized option: - Xmx16g
Error in .jinit(parameters = parameters) :
Unable to create a Java class loader.
In addition: Warning message:
In .local(x, p, ...) :
1 (0.06%) of the presence points have NA predictor values

Solution seems to be the removal of the spacing between -()Xmx16g -> options(java.parameters = "-Xmx8g") . This could be a linux thing as I haven't tested it on another OSs.

Also Possible comment to add to the beginning of script: Removal of present variables and restarting Rstudio session is necessary when using options(java.parameters=...) in order to avoid previous package loadspace issues. (see https://stackoverflow.com/questions/34624002/r-error-java-lang-outofmemoryerror-java-heap-space)

06_Ecological_Niche_Modeling_jtmod.txt

sessionInfo()
R version 4.3.0 (2023-04-21)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 22.04.2 LTS

Matrix products: default
BLAS/LAPACK: /usr/lib/x86_64-linux-gnu/libmkl_rt.so; LAPACK version 3.8.0

locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8
[6] LC_MESSAGES=en_US.UTF-8 LC_PAPER=en_US.UTF-8 LC_NAME=en_US.UTF-8 LC_ADDRESS=en_US.UTF-8 LC_TELEPHONE=en_US.UTF-8
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=en_US.UTF-8

time zone: America/Havana
tzcode source: system (glibc)

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

other attached packages:
[1] kuenm_1.1.10 viridis_0.6.3 viridisLite_0.4.2 ggplot2_3.4.2 ENMeval_2.0.4 magrittr_2.0.3 dismo_1.3-14 dplyr_1.1.2
[9] gtools_3.9.4 raster_3.6-20 sp_1.6-0

loaded via a namespace (and not attached):
[1] gtable_0.3.3 compiler_4.3.0 tidyselect_1.2.0 Rcpp_1.0.10 gridExtra_2.3 scales_1.2.1 fastmap_1.1.1 lattice_0.21-8 R6_2.5.1
[10] generics_0.1.3 knitr_1.42 iterators_1.0.14 tibble_3.2.1 munsell_0.5.0 pillar_1.9.0 rlang_1.1.1 rgdal_1.6-6 utf8_1.2.3
[19] terra_1.7-29 xfun_0.38 cli_3.6.1 withr_2.5.0 digest_0.6.30 foreach_1.5.2 grid_4.3.0 rJava_1.0-6 rstudioapi_0.14
[28] lifecycle_1.0.3 vctrs_0.6.1 evaluate_0.20 glue_1.6.2 codetools_0.2-19 fansi_1.0.4 colorspace_2.1-0 rmarkdown_2.21 purrr_1.0.1
[37] htmltools_0.5.5 tools_4.3.0 pkgconfig_2.0.3

RStoolbox is not available for standard installation on R version 4.3.0

install.packages("RStoolbox")
Installing package into ‘/home/jt-miller/R/x86_64-pc-linux-gnu-library/4.3’
(as ‘lib’ is unspecified)
Warning in install.packages :
  package ‘RStoolbox’ is not available for this version of R

A version of this package for your version of R might be available elsewhere,
see the ideas at
https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages

Looks like they haven't followed their CRAN updates: https://cran.r-project.org/web/packages/RStoolbox/index.html
Suggest to add it as a github_install along with rmaxent, kuenm, and gatoRs.
library(devtools) install_github("bleutner/RStoolbox")

Rversion:
platform x86_64-pc-linux-gnu
arch x86_64
os linux-gnu
system x86_64, linux-gnu
status
major 4
minor 3.0
year 2023
month 04
day 21
svn rev 84292
language R
version.string R version 4.3.0 (2023-04-21)
nickname Already Tomorrow

05_PointBased: ecospat.grid.clim.dyn suggests there are not enough relocations available.

The code chunk:

Kernel density estimates

create occurrence density grids based on the ordination data

z1 <- ecospat.grid.clim.dyn(scores.clim, scores.clim, p1.score, R = 100)
z2 <- ecospat.grid.clim.dyn(scores.clim, scores.clim, p2.score, R = 100)
z3 <- ecospat.grid.clim.dyn(scores.clim, scores.clim, p3.score, R = 100)
z4 <- ecospat.grid.clim.dyn(scores.clim, scores.clim, p4.score, R = 100)
zlist <- list(z1, z2, z3, z4)

Currently will error out: Error in adehabitatHR::kernelUD(sp::SpatialPoints(xr[, 1:2]), h = "href", :
At least 5 relocations are required to fit an home range

scores.clim are built off the PCAs per species, there seems to be adequate sample size for relocation. Unsure whats actually happening here.

Note: My ecospat version is 3.5.1

Bug for spacial correction of small datasets

Hi
I noticed an issue with the spacial correction script (lines 123-128 in the data cleaning section) when applied to small datasets with relatively uniform spacing among points. I initially ran the script on a 34 observation dataset and a 2.5'' resolution geotif, and I got back 3 points after correction. I integrated data from other sources to get my initial sample size up to 48, but this time I got back 2 points after correction. I realized that by filling in gaps in the distribution, the additional data made the observations more uniformly distributed. To illustrate, imagine 100 points in a line spaced 1 m apart. Attempting to satisfy a 2 m resolution by sequentially eliminating points with the smallest distance from its neighbor will result in deleting all but one data point because of uniform distribution. I have a workaround which is highly inelegant and computationally inefficient but seems to reasonably mitigate the glitch:

orginal:

Remove a point which nearest neighbor distance is smaller than the resolution size

aka remove one point in a pair that occurs within one pixel

while(min(nndist(df[,6:7])) < rasterResolution){
nnD <- nndist(df[,6:7])
df <- df[-(which(min(nnD) == nnD) [1]), ]
}

My soultion: 1) use a conditional to only apply the fix on data sets that have <300 observations (where the issue is most likely to be observed), 2) randomly choose which minimum distance point will be deleted from the pool of equally spaced candidates in each iteration of the while loop, and 3) repeat the while loop 50x and keep the iteration that retained the highest number of observations:

if (nrow(df) < 300) {
testdf <- df
result_holder = list()
for (i in 1:50){
result_holder[[i]] <- testdf
while(min(nndist(result_holder[[i]][,6:7])) < rasterResolution) {
nnD <- nndist(result_holder[[i]][,6:7])
result_holder[[i]] <- result_holder[[i]][-(sample(which(min(nnD) == nnD)) [1]), ]
}
}
df <- result_holder[[which.max(sapply(result_holder, nrow))]]
}
else {
while(min(nndist(df[,6:7])) < rasterResolution){
nnD <- nndist(df[,6:7])
df <- df[-(which(min(nnD) == nnD) [1]), ]
}
}

Best,
Tito

00_Setup has out of date packages

When fresh install is performed on packages, some packages will be newer than the listed version in setup.csv. Additionally, some packages are part of base R, therefore will fail any standard installation.

Here is a list of packages that are more up-to-date then currently the setup.csv suggests.

R session info:
platform x86_64-pc-linux-gnu
arch x86_64
os linux-gnu
system x86_64, linux-gnu
status
major 4
minor 3.0
year 2023
month 04
day 21
svn rev 84292
language R
version.string R version 4.3.0 (2023-04-21)
nickname Already Tomorrow

Correct proj 4 string on lesson 4

In lesson 4 there is an assignment of WGS84 via the ESPG code, that seems to be defunct at the moment, use proj 4 string instead.

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.