envi
Environmental Interpolation using Spatial Kernel Density Estimation
Science Score: 49.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 5 DOI reference(s) in README -
○Academic publication links
-
✓Committers with academic emails
1 of 3 committers (33.3%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (14.5%) to scientific vocabulary
Keywords
Repository
Environmental Interpolation using Spatial Kernel Density Estimation
Basic Info
Statistics
- Stars: 1
- Watchers: 3
- Forks: 3
- Open Issues: 0
- Releases: 12
Topics
Metadata Files
README.md
envi: Environmental Interpolation using Spatial Kernel Density Estimation

Date repository last updated: August 29, 2025
Overview
The 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 package. Internal cross-validation and basic visualization are also supported.
Installation
To install the release version from CRAN:
install.packages('envi')
To install the development version from GitHub:
devtools::install_github('lance-waller-lab/envi')
Available functions
| Function | Description | lrren |
Main function. Estimate an ecological niche using the spatial relative risk function and predict its location in geographic space. | perlrren |
Sensitivity analysis for lrren whereby observation locations are spatially perturbed ('jittered') with specified radii, iteratively. |
plot_obs |
Display multiple plots of the estimated ecological niche from lrren output. |
plot_predict |
Display multiple plots of the predicted spatial distribution from lrren output. |
plot_cv |
Display multiple plots of internal k-fold cross-validation diagnostics from lrren output. |
plot_perturb |
Display multiple plots of output from perlrren including predicted spatial distribution of the summary statistics. |
div_plot |
Called within plot_obs, plot_predict, and plot_perturb, provides functionality for basic visualization of surfaces with diverging color palettes. |
seq_plot |
Called within plot_perturb, provides functionality for basic visualization of surfaces with sequential color palettes. |
pval_correct |
Called within lrren and perlrren, calculates various multiple testing corrections for the alpha level. |
|---|
Authors
- Ian D. Buller - DLH, LLC (formerly Social & 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 - ORCID
See also the list of contributors who participated in this package, including:
- Lance A. Waller - Biostatistics and Bioinformatics, Emory University, Atlanta, Georgia. - GitHub - ORCID
Usage
For the lrren() function
```r set.seed(1234) # for reproducibility
------------------
Necessary packages
------------------
library(envi) library(spatstat.data) library(spatstat.random)
--------------
Prepare inputs
--------------
Using the 'bei' and 'bei.extra' data within {spatstat.data}
Environmental Covariates
elev <- bei.extra[[1]] grad <- bei.extra[[2]] elev$v <- scale(elev) grad$v <- scale(grad) elevraster <- rast(elev) gradraster <- rast(grad)
Presence data
presence <- bei marks(presence) <- data.frame( 'presence' = rep(1, presence$n), 'lon' = presence$x, 'lat' = presence$y ) marks(presence)$elev <- elev[presence] marks(presence)$grad <- grad[presence]
(Pseudo-)Absence data
absence <- rpoispp(0.008, win = elev) marks(absence) <- data.frame( 'presence' = rep(0, absence$n), 'lon' = absence$x, 'lat' = absence$y ) marks(absence)$elev <- elev[absence] marks(absence)$grad <- grad[absence]
Combine
obslocs <- superimpose(presence, absence, check = FALSE) obslocs <- marks(obslocs) obslocs$id <- seq(1, nrow(obslocs), 1) obslocs <- obs_locs[ , c(6, 2, 3, 1, 4, 5)]
Prediction Data
predictxy <- crds(elevraster) predictlocs <- as.data.frame(predictxy) predictlocs$elev <- extract(elevraster, predictxy)[ , 1] predictlocs$grad <- extract(gradraster, predictxy)[ , 1]
-----------
Run lrren()
-----------
test1 <- lrren( obslocs = obslocs, predictlocs = predictlocs, predict = TRUE, verbose = TRUE, cv = TRUE )
--------------
Run plot_obs()
--------------
plot_obs(test1)
------------------
Run plot_predict()
------------------
plot_predict( test1, cref0 = 'EPSG:5472', cref1 = 'EPSG:4326' )
-------------
Run plot_cv()
-------------
plot_cv(test1) ```

```r
--------------------------------------
Run lrren() with Bonferroni correction
--------------------------------------
test2 <- lrren( obslocs = obslocs, predictlocs = predictlocs, predict = TRUE, p_correct = 'Bonferroni' )
Note: Only showing third plot
plot_obs(test2)
Note: Only showing second plot
plot_predict( test2, cref0 = 'EPSG:5472', cref1 = 'EPSG:4326' )
Note: plot_cv() will display the same results because cross-validation only performed for the log relative risk estimate
```

For the perlrren() function
```r set.seed(1234) # for reproducibility
------------------
Necessary packages
------------------
library(envi) library(spatstat.data) library(spatstat.random)
--------------
Prepare inputs
--------------
Using the 'bei' and 'bei.extra' data within {spatstat.data}
Scale environmental covariates
ims <- bei.extra ims[[1]]$v <- scale(ims[[1]]$v) ims[[2]]$v <- scale(ims[[2]]$v)
Presence data
presence <- bei marks(presence) <- data.frame( 'presence' = rep(1, presence$n), 'lon' = presence$x, 'lat' = presence$y )
(Pseudo-)Absence data
absence <- rpoispp(0.008, win = ims[[1]]) marks(absence) <- data.frame( 'presence' = rep(0, absence$n), 'lon' = absence$x, 'lat' = absence$y )
Combine and create 'id' and 'levels' features
obslocs <- superimpose(presence, absence, check = FALSE) marks(obslocs)$id <- seq(1, obslocs$n, 1) marks(obslocs)$levels <- as.factor(rpois(obslocs$n, lambda = 0.05)) marks(obslocs) <- marks(obs_locs)[ , c(4, 2, 3, 1, 5)]
--------------
Run perlrren()
--------------
Uncertainty in observation locations
Most observations within 10 meters
Some observations within 100 meters
Few observations within 500 meters
test3 <- perlrren( obsppp = obslocs, covariates = ims, radii = c(10, 100, 500), verbose = FALSE, # may not be availabe if parallel = TRUE parallel = TRUE, n_sim = 100 )
------------------
Run plot_perturb()
------------------
plotperturb( test3, cref0 = 'EPSG:5472', cref1 = 'EPSG:4326', covlabs = c('elev', 'grad') ) ```

Funding
This package was developed while the author was originally a doctoral student in the Environmental Health Sciences doctoral program at Emory University and later as a postdoctoral fellow supported by the Cancer Prevention Fellowship Program at the National Cancer Institute. Any modifications since December 05, 2022 were made while the author was an employee of DLH, LLC (formerly Social & Scientific Systems, Inc.).
Acknowledgments
When citing this package for publication, please follow:
citation('envi')
Questions? Feedback?
For questions about the package, please contact the maintainer Dr. Ian D. Buller or submit a new issue.
Owner
- Name: lance-waller-lab
- Login: lance-waller-lab
- Kind: organization
- Email: lwaller@emory.edu
- Location: United States of America
- Repositories: 3
- Profile: https://github.com/lance-waller-lab
Lance Waller's Lab GitHub
GitHub Events
Total
- Push event: 3
Last Year
- Push event: 3
Committers
Last synced: over 1 year ago
Top Committers
| Name | Commits | |
|---|---|---|
| Ian Buller, PhD, MA | i****r@n****v | 65 |
| idblr | i****r@g****m | 21 |
| Ege Rubak | r****k@m****k | 2 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 1
- Total pull requests: 2
- Average time to close issues: 5 days
- Average time to close pull requests: 2 days
- Total issue authors: 1
- Total pull request authors: 1
- Average comments per issue: 4.0
- Average comments per pull request: 3.5
- Merged pull requests: 2
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- rsbivand (1)
Pull Request Authors
- rubak (2)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- cran 659 last-month
- Total dependent packages: 1
- Total dependent repositories: 1
- Total versions: 13
- Total maintainers: 1
cran.r-project.org: envi
Environmental Interpolation using Spatial Kernel Density Estimation
- Homepage: https://github.com/lance-waller-lab/envi
- Documentation: http://cran.r-project.org/web/packages/envi/envi.pdf
- License: Apache License (≥ 2.0)
-
Latest release: 1.0.1
published 6 months ago
Rankings
Maintainers (1)
Dependencies
- R >= 3.5.0 depends
- ROCR * imports
- concaveman * imports
- cvAUC * imports
- doFuture * imports
- doRNG * imports
- fields * imports
- foreach * imports
- future * imports
- grDevices * imports
- graphics * imports
- iterators * imports
- methods * imports
- pls * imports
- raster * imports
- rgeos * imports
- sp * imports
- sparr * imports
- spatstat.geom * imports
- stats * imports
- R.rsp * suggests
- spatstat.data * suggests
- spatstat.random * suggests
- spelling * suggests
- testthat * suggests
- utils * suggests
- actions/checkout v3 composite
- r-lib/actions/check-r-package v2 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
- r-hub/actions/checkout v1 composite
- r-hub/actions/platform-info v1 composite
- r-hub/actions/run-check v1 composite
- r-hub/actions/setup v1 composite
- r-hub/actions/setup-deps v1 composite
- r-hub/actions/setup-r v1 composite