{"id":32207630,"url":"https://github.com/lance-waller-lab/envi","last_synced_at":"2026-02-22T19:05:31.221Z","repository":{"id":44709721,"uuid":"295176649","full_name":"lance-waller-lab/envi","owner":"lance-waller-lab","description":"Environmental Interpolation using Spatial Kernel Density Estimation","archived":false,"fork":false,"pushed_at":"2025-09-10T12:37:53.000Z","size":8189,"stargazers_count":2,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2026-02-15T09:12:52.444Z","etag":null,"topics":["cran","cran-r","ecological-niche","ecological-niche-modelling","geospatial","geospatial-analysis","kernel-density-estimation","niche-modeling","niche-modelling","non-euclidean-spaces","point-pattern","point-pattern-analysis","principal-component-analysis","r","r-package","rstats","rstats-package","spatial-analysis","species-distribution-modeling","species-distribution-modelling"],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lance-waller-lab.png","metadata":{"files":{"readme":"README.md","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2020-09-13T15:10:25.000Z","updated_at":"2025-09-21T17:12:49.000Z","dependencies_parsed_at":"2025-09-08T13:40:18.826Z","dependency_job_id":"d6598335-9a89-4e83-9016-7b0b4f5c50a0","html_url":"https://github.com/lance-waller-lab/envi","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/lance-waller-lab/envi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lance-waller-lab%2Fenvi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lance-waller-lab%2Fenvi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lance-waller-lab%2Fenvi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lance-waller-lab%2Fenvi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lance-waller-lab","download_url":"https://codeload.github.com/lance-waller-lab/envi/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lance-waller-lab%2Fenvi/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29723574,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-22T15:10:41.462Z","status":"ssl_error","status_checked_at":"2026-02-22T15:10:04.636Z","response_time":110,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cran","cran-r","ecological-niche","ecological-niche-modelling","geospatial","geospatial-analysis","kernel-density-estimation","niche-modeling","niche-modelling","non-euclidean-spaces","point-pattern","point-pattern-analysis","principal-component-analysis","r","r-package","rstats","rstats-package","spatial-analysis","species-distribution-modeling","species-distribution-modelling"],"created_at":"2025-10-22T05:56:28.565Z","updated_at":"2026-02-22T19:05:31.216Z","avatar_url":"https://github.com/lance-waller-lab.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"# envi: Environmental Interpolation using Spatial Kernel Density Estimation \n\u003cimg src='man/figures/envi.png' width='120' align='right' /\u003e\n\n\u003c!-- badges: start --\u003e\n[![R-CMD-check](https://github.com/lance-waller-lab/envi/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/lance-waller-lab/envi/actions/workflows/R-CMD-check.yaml)\n[![CRAN status](https://www.r-pkg.org/badges/version/envi)](https://cran.r-project.org/package=envi)\n[![CRAN version](https://www.r-pkg.org/badges/version-ago/envi)](https://cran.r-project.org/package=envi)\n[![CRAN RStudio mirror downloads total](https://cranlogs.r-pkg.org/badges/grand-total/envi?color=blue)](https://r-pkg.org/pkg/envi)\n[![CRAN RStudio mirror downloads monthly ](https://cranlogs.r-pkg.org/badges/envi)](https://www.r-pkg.org:443/pkg/envi)\n[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/license/apache-2-0)\n![GitHub last commit](https://img.shields.io/github/last-commit/lance-waller-lab/envi)\n[![](https://img.shields.io/badge/DOI-10.32614/CRAN.package.envi-1f57b6?style=flat\u0026link=https://doi.org/10.32614/CRAN.package.envi)](https://doi.org/10.32614/CRAN.package.envi)\n\u003c!-- badges: end --\u003e\n\n**Date repository last updated**: August 29, 2025\n\n\u003ch2 id='overview'\u003e\n\nOverview\n\n\u003c/h2\u003e\n\nThe `envi` package is a suite of `R` functions to estimate the ecological niche of a species and predict the spatial distribution of the ecological niche -- a version of environmental interpolation -- with spatial kernel density estimation techniques. A two-group comparison (e.g., presence and absence locations of a single species) is conducted using the spatial relative risk function that is estimated using the [sparr](https://CRAN.R-project.org/package=sparr) package. Internal cross-validation and basic visualization are also supported. \n\n\u003ch2 id='install'\u003e\n\nInstallation\n\n\u003c/h2\u003e\n\nTo install the release version from CRAN:\n\n    install.packages('envi')\n\nTo install the development version from GitHub:\n\n    devtools::install_github('lance-waller-lab/envi')\n\n\u003ch2 id='available-functions'\u003e\n\nAvailable functions\n\n\u003c/h2\u003e\n\n\u003ctable\u003e\n\u003ccolgroup\u003e\n\u003ccol width='30%'/\u003e\n\u003ccol width='70%'/\u003e\n\u003c/colgroup\u003e\n\u003cthead\u003e\n\u003ctr class='header'\u003e\n\u003cth\u003eFunction\u003c/th\u003e\n\u003cth\u003eDescription\u003c/th\u003e\n\u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n\u003ctd\u003e\u003ca href='R/lrren.R'\u003e\u003ccode\u003elrren\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n\u003ctd\u003eMain function. Estimate an ecological niche using the spatial relative risk function and predict its location in geographic space.\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctd\u003e\u003ca href='R/perlrren.R'\u003e\u003ccode\u003eperlrren\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n\u003ctd\u003eSensitivity analysis for \u003ca href='R/lrren.R'\u003e\u003ccode\u003elrren\u003c/code\u003e\u003c/a\u003e whereby observation locations are spatially perturbed ('jittered') with specified radii, iteratively.\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctd\u003e\u003ca href='R/plot_obs.R'\u003e\u003ccode\u003eplot_obs\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n\u003ctd\u003eDisplay multiple plots of the estimated ecological niche from \u003ca href='R/lrren.R'\u003e\u003ccode\u003elrren\u003c/code\u003e\u003c/a\u003e output.\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctd\u003e\u003ca href='R/plot_predict.R'\u003e\u003ccode\u003eplot_predict\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n\u003ctd\u003eDisplay multiple plots of the predicted spatial distribution from \u003ca href='R/lrren.R'\u003e\u003ccode\u003elrren\u003c/code\u003e\u003c/a\u003e output.\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctd\u003e\u003ca href='R/plot_cv.R'\u003e\u003ccode\u003eplot_cv\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n\u003ctd\u003eDisplay multiple plots of internal k-fold cross-validation diagnostics from \u003ca href='R/lrren.R'\u003e\u003ccode\u003elrren\u003c/code\u003e\u003c/a\u003e output.\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctd\u003e\u003ca href='R/plot_perturb.R'\u003e\u003ccode\u003eplot_perturb\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n\u003ctd\u003eDisplay multiple plots of output from \u003ca href='R/perlrren.R'\u003e\u003ccode\u003eperlrren\u003c/code\u003e\u003c/a\u003e including predicted spatial distribution of the summary statistics.\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctd\u003e\u003ca href='R/div_plot.R'\u003e\u003ccode\u003ediv_plot\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n\u003ctd\u003eCalled within \u003ca href='R/plot_obs.R'\u003e\u003ccode\u003eplot_obs\u003c/code\u003e\u003c/a\u003e, \u003ca href='R/plot_predict.R'\u003e\u003ccode\u003eplot_predict\u003c/code\u003e\u003c/a\u003e, and \u003ca href='R/plot_perturb.R'\u003e\u003ccode\u003eplot_perturb\u003c/code\u003e\u003c/a\u003e, provides functionality for basic visualization of surfaces with diverging color palettes.\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctd\u003e\u003ca href='R/seq_plot.R'\u003e\u003ccode\u003eseq_plot\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n\u003ctd\u003eCalled within \u003ca href='R/plot_perturb.R'\u003e\u003ccode\u003eplot_perturb\u003c/code\u003e\u003c/a\u003e, provides functionality for basic visualization of surfaces with sequential color palettes.\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctd\u003e\u003ca href='R/pval_correct.R'\u003e\u003ccode\u003epval_correct\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n\u003ctd\u003eCalled within \u003ca href='R/lrren.R'\u003e\u003ccode\u003elrren\u003c/code\u003e\u003c/a\u003e and \u003ca href='R/perlrren.R'\u003e\u003ccode\u003eperlrren\u003c/code\u003e\u003c/a\u003e, calculates various multiple testing corrections for the alpha level.\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\n\u003ch2 id='authors'\u003e\n\nAuthors\n\n\u003c/h2\u003e\n\n* **Ian D. Buller** - *DLH, LLC (formerly Social \u0026 Scientific Systems, Inc.), Bethesda, Maryland (current)* - *Occupational and Environmental Epidemiology Branch, Division of Cancer Epidemiology and Genetics, National Cancer Institute, National Institutes of Health, Rockville, Maryland (former)* - *Environmental Health Sciences, James T. Laney School of Graduate Studies, Emory University, Atlanta, Georgia. (original)* - [GitHub](https://github.com/idblr) - [ORCID](https://orcid.org/0000-0001-9477-8582)\n\nSee also the list of [contributors](https://github.com/lance-waller-lab/envi/graphs/contributors) who participated in this package, including:\n\n* **Lance A. Waller** - *Biostatistics and Bioinformatics, Emory University, Atlanta, Georgia.* - [GitHub](https://github.com/lance-waller) - [ORCID](https://orcid.org/0000-0001-5002-8886)\n\n## Usage\n\n### For the lrren() function\n\n```r\nset.seed(1234) # for reproducibility\n\n# ------------------ #\n# Necessary packages #\n# ------------------ #\n\nlibrary(envi)\nlibrary(spatstat.data)\nlibrary(spatstat.random)\n\n# -------------- #\n# Prepare inputs #\n# -------------- #\n\n# Using the 'bei' and 'bei.extra' data within {spatstat.data}\n\n# Environmental Covariates\nelev \u003c- bei.extra[[1]]\ngrad \u003c- bei.extra[[2]]\nelev$v \u003c- scale(elev)\ngrad$v \u003c- scale(grad)\nelev_raster \u003c- rast(elev)\ngrad_raster \u003c- rast(grad)\n\n# Presence data\npresence \u003c- bei\nmarks(presence) \u003c- data.frame(\n  'presence' = rep(1, presence$n),\n  'lon' = presence$x,\n  'lat' = presence$y\n)\nmarks(presence)$elev \u003c- elev[presence]\nmarks(presence)$grad \u003c- grad[presence]\n\n# (Pseudo-)Absence data\nabsence \u003c- rpoispp(0.008, win = elev)\nmarks(absence) \u003c- data.frame(\n  'presence' = rep(0, absence$n),\n  'lon' = absence$x,\n  'lat' = absence$y\n)\nmarks(absence)$elev \u003c- elev[absence]\nmarks(absence)$grad \u003c- grad[absence]\n\n# Combine\nobs_locs \u003c- superimpose(presence, absence, check = FALSE)\nobs_locs \u003c- marks(obs_locs)\nobs_locs$id \u003c- seq(1, nrow(obs_locs), 1)\nobs_locs \u003c- obs_locs[ , c(6, 2, 3, 1, 4, 5)]\n\n# Prediction Data\npredict_xy \u003c- crds(elev_raster)\npredict_locs \u003c- as.data.frame(predict_xy)\npredict_locs$elev \u003c- extract(elev_raster, predict_xy)[ , 1]\npredict_locs$grad \u003c- extract(grad_raster, predict_xy)[ , 1]\n\n# ----------- #\n# Run lrren() #\n# ----------- #\n\ntest1 \u003c- lrren(\n  obs_locs = obs_locs,\n  predict_locs = predict_locs,\n  predict = TRUE,\n  verbose = TRUE,\n  cv = TRUE\n)\n              \n# -------------- #\n# Run plot_obs() #\n# -------------- #\n\nplot_obs(test1)\n\n# ------------------ #\n# Run plot_predict() #\n# ------------------ #\n\nplot_predict(\n  test1,\n  cref0 = 'EPSG:5472',\n  cref1 = 'EPSG:4326'\n)\n\n# ------------- #\n# Run plot_cv() #\n# ------------- #\n\nplot_cv(test1)\n```\n\n![](man/figures/plot_obs1.png)\n![](man/figures/plot_obs2.png)\n![](man/figures/plot_obs3.png)\n![](man/figures/plot_predict1.png)\n![](man/figures/plot_predict2.png)\n![](man/figures/plot_cv1.png)\n\n```r \n# -------------------------------------- #\n# Run lrren() with Bonferroni correction #\n# -------------------------------------- #\n\ntest2 \u003c- lrren(\n  obs_locs = obs_locs,\n  predict_locs = predict_locs,\n  predict = TRUE,\n  p_correct = 'Bonferroni'\n)\n\n# Note: Only showing third plot\nplot_obs(test2)\n\n# Note: Only showing second plot\nplot_predict(\n  test2,\n  cref0 = 'EPSG:5472',\n  cref1 = 'EPSG:4326'\n)\n\n# Note: plot_cv() will display the same results because cross-validation only performed for the log relative risk estimate\n```\n\n![](man/figures/plot_obs4.png)\n![](man/figures/plot_predict3.png)\n\n### For the perlrren() function\n\n```r\nset.seed(1234) # for reproducibility\n\n# ------------------ #\n# Necessary packages #\n# ------------------ #\n\nlibrary(envi)\nlibrary(spatstat.data)\nlibrary(spatstat.random)\n\n# -------------- #\n# Prepare inputs #\n# -------------- #\n\n# Using the 'bei' and 'bei.extra' data within {spatstat.data}\n\n# Scale environmental covariates\nims \u003c- bei.extra\nims[[1]]$v \u003c- scale(ims[[1]]$v)\nims[[2]]$v \u003c- scale(ims[[2]]$v)\n\n# Presence data\npresence \u003c- bei\nmarks(presence) \u003c- data.frame(\n  'presence' = rep(1, presence$n),\n  'lon' = presence$x,\n  'lat' = presence$y\n)\n\n# (Pseudo-)Absence data\nabsence \u003c- rpoispp(0.008, win = ims[[1]])\nmarks(absence) \u003c- data.frame(\n  'presence' = rep(0, absence$n),\n  'lon' = absence$x,\n  'lat' = absence$y\n)\n\n# Combine and create 'id' and 'levels' features\nobs_locs \u003c- superimpose(presence, absence, check = FALSE)\nmarks(obs_locs)$id \u003c- seq(1, obs_locs$n, 1)\nmarks(obs_locs)$levels \u003c- as.factor(rpois(obs_locs$n, lambda = 0.05))\nmarks(obs_locs) \u003c- marks(obs_locs)[ , c(4, 2, 3, 1, 5)]\n\n# -------------- #\n# Run perlrren() #\n# -------------- #\n\n# Uncertainty in observation locations\n## Most observations within 10 meters\n## Some observations within 100 meters\n## Few observations within 500 meters\n\ntest3 \u003c- perlrren(\n  obs_ppp = obs_locs,\n  covariates = ims,\n  radii = c(10, 100, 500),\n  verbose = FALSE, # may not be availabe if parallel = TRUE\n  parallel = TRUE,\n  n_sim = 100\n)\n                 \n# ------------------ #\n# Run plot_perturb() #\n# ------------------ #\n\nplot_perturb(\n  test3,\n  cref0 = 'EPSG:5472',\n  cref1 = 'EPSG:4326',\n  cov_labs = c('elev', 'grad')\n)\n```\n\n![](man/figures/plot_perturb1.png)\n![](man/figures/plot_perturb2.png)\n![](man/figures/plot_perturb3.png)\n![](man/figures/plot_perturb4.png)\n![](man/figures/plot_perturb5.png)\n![](man/figures/plot_perturb6.png)\n![](man/figures/plot_perturb7.png)\n![](man/figures/plot_perturb8.png)\n\n### Funding\n\nThis package was developed while the author was originally a doctoral student in the [Environmental Health Sciences doctoral program](https://sph.emory.edu/degrees-programs/phd/environmental-health-sciences) at [Emory University](https://www.emory.edu/home/index.html) and later as a postdoctoral fellow supported by the [Cancer Prevention Fellowship Program](https://cpfp.cancer.gov/) at the [National Cancer Institute](https://www.cancer.gov/). Any modifications since December 05, 2022 were made while the author was an employee of [DLH, LLC](https://www.dlhcorp.com) (formerly Social \u0026 Scientific Systems, Inc.).\n\n### Acknowledgments\n\nWhen citing this package for publication, please follow:\n\n    citation('envi')\n\n### Questions? Feedback?\n\nFor questions about the package, please contact the maintainer [Dr. Ian D. Buller](mailto:ian.buller@alumni.emory.edu) or [submit a new issue](https://github.com/lance-waller-lab/envi/issues).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flance-waller-lab%2Fenvi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flance-waller-lab%2Fenvi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flance-waller-lab%2Fenvi/lists"}