envi

Environmental Interpolation using Spatial Kernel Density Estimation

https://github.com/lance-waller-lab/envi

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

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
Last synced: 6 months ago · JSON representation

Repository

Environmental Interpolation using Spatial Kernel Density Estimation

Basic Info
  • Host: GitHub
  • Owner: lance-waller-lab
  • License: apache-2.0
  • Language: R
  • Default Branch: main
  • Homepage:
  • Size: 7.81 MB
Statistics
  • Stars: 1
  • Watchers: 3
  • Forks: 3
  • Open Issues: 0
  • Releases: 12
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
Created over 5 years ago · Last pushed 6 months ago
Metadata Files
Readme Changelog License

README.md

envi: Environmental Interpolation using Spatial Kernel Density Estimation

R-CMD-check CRAN status CRAN version CRAN RStudio mirror downloads total CRAN RStudio mirror downloads monthly License GitHub last commit <!-- badges: end -->

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

Lance Waller's Lab GitHub

GitHub Events

Total
  • Push event: 3
Last Year
  • Push event: 3

Committers

Last synced: over 1 year ago

All Time
  • Total Commits: 88
  • Total Committers: 3
  • Avg Commits per committer: 29.333
  • Development Distribution Score (DDS): 0.261
Past Year
  • Commits: 2
  • Committers: 1
  • Avg Commits per committer: 2.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email 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
enhancement (1)
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

  • Versions: 13
  • Dependent Packages: 1
  • Dependent Repositories: 1
  • Downloads: 659 Last month
Rankings
Forks count: 17.2%
Dependent repos count: 24.3%
Average: 26.8%
Dependent packages count: 27.9%
Downloads: 29.9%
Stargazers count: 34.7%
Maintainers (1)
Last synced: 6 months ago

Dependencies

DESCRIPTION cran
  • 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
.github/workflows/R-CMD-check.yaml actions
  • 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
.github/workflows/rhub.yaml actions
  • 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