Home

Awesome

spatialEco (dev 2.0-3) <img src="man/figures/logo.png" align="right" height="132" />

<!-- badges: start -->

R-CMD-check CRAN status CRAN RStudio mirror downloads

<!-- badges: end -->

spatialEco R package with utilities to support spatial data manipulation, query, sampling and modeling. Functions include models for species population density, qudrat-based analysis and sampling, spatial smoothing, multivariate separability, point process model for creating pseudo- absences and sub-sampling, polygon and point-distance structural metrics, auto-logistic model, sampling models, cluster optimization and statistical exploratory tools.

News

In version 2.0-3

Fixed bug in aspline.downscale where, grid.search = TRUE option was producing an error

Fixed bug in sf.kde where error was returned when specifying ref argument

Fixed bug in raster.kendall where, other than the default, the method argument was not being reconized

Depreciated cgls.url due to digest files no longer reliable

Depreciated oli.aws due to AWS Registry of Open Data changing to the AWS Data Exchange 

As of version 2.0-2 I completley depreciated several functions (they no longer have aliasis) and cleaned up documentation. Other changes are;

Added suggest for the lwgeom package after sf dropped as Imports dependency

Added function to derive LAI (leaf area index) from NDVI

Fixed bug in sf.kde where bandwidth was not being reconized as argument

Reverted sf.kde to use modification of MASS 2dkde as, ks methods are somewhat
questionable with spatial data. 

In version 2.0-1

Fixed bug in sf.kde (thanks to Dirk Pflugmacher for pointing out rotation issue)  

Added function sf_dissolve for dissolving polygon features

Added function squareBuffer for creating square buffers

Fixed bug in raster.downsample where plot returned error when scatter=TRUE with one covariate  

Added function aspline.downscale for downscaling rasters using multivariate adaptive 
regression splines (thanks to discussion with Felipe Benavides)

Fixed a bug in breeding.density (thanks to Eric Newkirk) where st_distance was resulting 
in a units class object and crashing the function. 

Feature request (Alessandro Mondanaro), added an argument/option in sf_kde for using ks or the modified MASS kde2d function that
facilitates weights. The MASS kde2d was the KDE function in the sp.kde function.   

Fixed a bug in curvature (thanks to Rachel Wright) where type="mcnab" was returning source raster values 

Updated knn function to use sf class objects  

Fixed bug in wt.centroid when sf object is tibble (thanks to Andrew Gustar for drawing my attention to the bug) 

Fixed bug in stratified.random where if there are no replicates with replace = FALSE no results returned

Enhancement added support for prewhiting of autocorrelated time-series in kendall function

I jumped to a major release and pushed the version to 2.0-0. All spatial functions are now using the sf and terra packages due to sp, rgeos, rgdal, maptools and raster being retired. Sorry but, for the most part I removed backwards compatibility with these depreciated object classes so, you will need to make sure that you are using modern spatial object classes. In terra, there is now only one class type for multi or single band raster objects "SpatRaster" which can be read or coerced using terra::rast. For coercing sp class vector objects to sf you can use sf::st_as:sf or as(x, "sf") and, going from sf to sp you use as(x, "Spatial")

Available functions in development version of spatialEco 2.0-2

spatialEco FunctionDescription
all_pairwiseCreates a list of all pairwise combinations of a vector
annulus.matrixCreates a 0,1 matrix based on defined annulus parameters, can be used as a window matrix in a raster focal function
aspline.downscaleDownscale raster to a higher resolution using multivariate adaptive regression splines (MARS)
backgroundCreates a point sample that can be used as a NULL for SDM's and other modeling approaches (see pseudo.absence for alternate approach).
bbox_extentCreates a bounding box polygon representing the extent of a feature or raster
bearing.distanceCalculate new point based on bearing/distance
breeding.densityCalculates n-th percent breeding density areas base on a kernel density estimate of population counts.
built.indexremote sensing built-up index
cgls_urlsDepreciated Based on query, provide URL's for Copernicus Global Land Service datasets
chaeThe Canine-Human Age Equivalent (for fun)
class.comparisonDepreciated, with migration to terra, I collapsed into raster.change
classBreaksfor finding class breaks in a distribution
collinearTest for linear or nonlinear collinearity/correlation in data
combineCombines multiple rasters into an "all possible combinations" raster emulation the ESRI combine function
concordancePerforms a concordance/disconcordance (C-statistic) test on binomial models.
conf.intervalCalculates confidence interval for the mean or median of a distribution with with unknown population variance
convexHullDerives a convex hull of points using the alpha hull approach with adjustable tension. Please note that due to licensing reasons, this function is only available in the GitHub development version and not on CRAN. You must call the function from the package namespace using spatialEco:::convexHull
correlogramCalculates and plots a correlogram (spatially lagged correlations, "pearson", "kendall" or "spearman")
cross.tabCross tabulate two rasters, labels outputs
crossCorrelationCalculates the partial spatial cross-correlation function
csiCalculates cosine similarity and angular similarity on two vectors or a matrix
curvatureZevenbergen & Thorne, McNab's or Bolstad's surface (raster) curvature
dahiCalculates the DAHI (Diurnal Anisotropic Heat Index)
date_seqCreates date sequence, given defined start and stop dates, with options for day, week, month, quarter, year or, minute.
daymet.pointDownloads DAYMET climate variables for specified point and timeperiod
daymet.tilesReturns a vector of DAYMET tile id's within a specified extent
dispersionCalculates the dispersion ("rarity") of targets associated with planning units
dissectionEvans (1972) Martonne's modified dissection
divergenceKullback-Leibler Divergence (Cross-entropy)
download.daymetDepreciated
download.hansenDepreciated
download.prismDepreciated
effect.sizeCohen's-d effect size with pooled sd for a control and experimental group
erase.pointsErases points inside or outside a polygon feature class
explodeDepreciated due to redundancy with sf::st_cast
extract.verticesextracts (x,y) vertices coordinates from polygons and linesa
fuzzySumCalculates the fuzzy sum of a vector
gaussian.kernelCreates a Gaussian Kernel of specified size and sigma
geo.bufferBuffers data in geographic coordinate space using a temporary projection
group.pdfCreates a probability density plot of y for each group of x
hexagonsCreate hexagon polygon “fishnet” of defined size and extent.
hli.ptHeat Load Index for tabular "point" data with slope and aspect
hliHeat Load Index, now with support for southern hemisphere data
hspHierarchical Slope Position
hybrid.kmeansClustering using hierarchical clustering to define cluster-centers in k-means
idw.smoothingDistance weighted smoothing (IDW) of a variable in a spatial point object. The function is a smoothing interpolator at the point observation(s) level using a distance-weighted mean.
impute.loessImputes NA's or smooths data (or both) for a vector, intended mostly for time-series or serial data.
insertInserts a row or column into a data.frame
insert.valuesInserts new values into a vector at specified positions
is.emptyMethod, evaluates if vector is empty
is.wholeDepreciated after R release of base::is.whole in 4.1.0
kendallKendall tau trend with continuity correction for time-series
kl.divergenceCalculates the Kullback-Leibler divergence (relative entropy) between unweighted theoretical component distributions. Divergence is calculated as: int[f(x) (log f(x)
knnreturns ids, rownames and distance of nearest neighbors in two (or single) spatial objects. Optional radius distance constraint. Added optional covariates (weights)
laiCalculates two versions of Leaf Area Index
local.min.maxCalculates the local minimums and maximums in a numeric vector, indicating inflection points in the distribution.
loess.bootBootstrap of a Local Polynomial Regression (loess)
loess.ciCalculates a local polynomial regression fit with associated confidence intervals
logistic.regressionPerforms a logistic (binomial) and autologistic (spatially lagged binomial) regression using maximum likelihood estimation or penalized maximum likelihood estimation.
max_extentReturns the maximum extent of multiple spatial inputs
mean_angleReturns the mean of a vector of angles. Intended for focal and zonal functions on slope or aspect
momentsCalculate statistical moments of a distribution including percentiles, arithmetic-geometric-harmonic means, coefficient of variation, median absolute deviation, skewness, kurtosis, mode and number of modes.
morans.plotAutocorrelation plot
nniCalculates the nearest neighbor index (NNI) measure of clustering or dispersal
nth.vlaueReturns the Nth (smallest/largest) values in a numeric vector
oli.awsDepreciated Download Landsat 8 OLI from AWS.
o.ringCalculates inhomogeneous O-ring point pattern statistic (Wiegand & Maloney 2004)
optimal.kFind optimal k of k-Medoid partitions using silhouette widths
optimized.sample.varianceDraws an optimal sample that minimizes or maximizes the sample variance
outliersIdentify outliers using modified Z-score
overlapFor comparing the similarity of two niche estimates using Warren's-I
parea.sampleCreates a systematic or random point sample of polygons where n is based on percent area of each polygon
parse.bitsBased on integer value, pulls value(s) of specified bit(s)
parial.corPartial and Semi-partial correlation
plot.effect.sizePlot generic for effect size
plot.loess.bootPlot generic for loess boot
point.in.polyDepreciated because function is redundant with sf::st_intersection
polygon_extractDepreciated because of migration to terra. Required package only supports raster class
polyPerimeterCalculates the perimeter length(s) for a polygon object
poly.regressionsmoothing data in time-series and imputing missing (NA) values using polynomial regression
poly_trendDerives Nth order polynomial trend with confidence intervals
pp.subsampleGenerates random subsample based on point process intensity function of the observed data. This is a spatially informed data thinning model that can be used to reduce pseudo-replication or autocorrelation.
proximity.indexProximity index for a set of polygons
pseudo.absenceGenerates pseudo-absence samples based on the spatial intensity function of known species locations. This is akin to distance constrained but is informed by the spatial process of the observed data and is drawn from a probabilistic sample following the intensity function.
quadratsQuadrat sampling or analysis, variable size and angle options
random.rastercreates random raster/stack of defined dimensions and statistical distributions
raster.changeCompares two categorical rasters with a variety of statistical options
raster.deviationLocal deviation from the raster based on specified global statistic or a polynomial trend.
rasterDistanceThis replicates the raster distanceFromPoints function but uses the Arya & Mount Approximate Near Neighbor (ANN) C++ library for calculating distances. Which results in a notable increase in performance. It is not memory safe and does not use the GeographicLib (Karney, 2013) spheroid distance method for geographic data
raster.downscaleDownscale raster to a higher resolution raster using robust regression
raster.entropyCalculates entropy on integer raster (i.e., 8 bit 0-255)
raster.gaussian.smoothApplies a Gaussian smoothing kernel to smooth raster.h
raster.invertInverts value of a raster
raster.kendallCalculates Kendall's tau trend with continuity correction for raster time-series
raster.mdsMultidimensional scaling of raster values within an N x N focal window
raster.modified.ttestBivariate moving window correlation using Dutilleul's modified t-test
raster.momentsCalculates focal statistical moments of a raster
raster.transformationApplies specified statistical transformation to a raster
raster.volCalculates a percent volume on a raster or based on the entire raster or a systematic sample
raster.ZscoreCalculates the modified z-score for all cells in a raster
rasterCorrelationPerforms a simple moving window correlation between two rasters
remove_duplicatesRemoves duplicate duplicate feature geometries
remove.holesRemoves all holes (null geometry) in polygon sf class objects
rm.extRemoves file extentions from text string
rotate.polygonRotates a polygon by specified angle
sa.transTrigonometric transformation of a slope and aspect interaction
sample.annulusCreates sample points based on annulus with defined inner and outer radius
sample.lineDepreciated because sf::st_sample can aggregate samples by feature
sample.polyDepreciated because sf::st_sample can aggregate samples by feature
sampleTransectCreates random transects from points, generates sample points along each transect
separabilityCalculates variety of univariate separability metrics for nominal class samples
sf_dissolveDissolves polygon geometry using attribute, globally or overlap
sg.smoothSmoothing time-series data using a Savitzky-Golay filter
shannonsCalculates Shannon's Diversity Index and Shannon's Evenness Index
shiftShifts a vector by n lags without changing its length, can specify fill values
sieveCreates a minimum mapping unit by removing pixel clusters < specified area
similarityUses row imputation to identify "k" ecological similar observations
smooth.time.seriesSmoothing and imputing missing (NA) of pixel-level data in raster time-series using (local polynomial) LOESS regression
sobalApplies an isotropic image gradient operator (Sobel-Feldman) using a 3x3 window
spatial.selectPerforms a spatial select (feature subset) similar to ArcGIS
spectral.separabilityCalculates class-wise multivariate spectral separability
sf.kdeA weighted or un-weighted kernel density estimate (previously sp.kde now as alias)
sp.na.omit Depreciated as only relevant to sp class objects, for sf use base na.omit
squareBufferCreates a square buffer of feature class
srrSurface Relief Ratio
stratified.randomCreates a stratified random sample of an sp class object using a factor.
subsample.distanceMinimum, and optional maximum, distance constrained sub-sampling
swviSenescence weighted MSAVI or MTVI
time_to_eventReturns the time (sum to position) to a specified value
topo.distanceCalculates topographic corrected distance for a SpatialLinesDataFrame object
tpiCalculates topographic position using mean deviations within specified window
traspSolar-radiation Aspect Index
trend.lineCalculated specified (linear, exponential, logarithmic, polynomial) trend line of x,y and plots results.
triImplementation of the Riley et al (1999) Terrain Ruggedness Index
vrmImplementation of the Sappington et al., (2007) vector ruggedness measure
winsorizeRemoves extreme outliers using a winsorization transformation
wt.centroidCreates centroid of [x,y] coordinates, of a random field, based on a weights field in a point sample.
zonal.statsDepreciated in leu of exactextractr library

Bugs: Users are encouraged to report bugs here. Go to issues in the menu above, and press new issue to start a new bug report, documentation correction or feature request. You can direct questions to jeffrey_evans@tnc.org.

To install spatialEco in R use install.packages() to download current stable release from CRAN

for the development version, run the following (requires the remotes package): remotes::install_github("jeffreyevans/spatialEco")

You can also install from ROpenSci (R-Universe):

# Enable repository from jeffreyevans
options(repos = c(
  jeffreyevans = 'https://jeffreyevans.r-universe.dev',
  CRAN = 'https://cloud.r-project.org'))
  
# Download and install spatialEco in R
install.packages('spatialEco')