├── .Rbuildignore ├── .github ├── .gitignore └── workflows │ └── R-CMD-check.yaml ├── .gitignore ├── DESCRIPTION ├── LICENSE ├── NAMESPACE ├── R ├── TM5-data.R ├── all_pairwise.R ├── annulus.matrix.R ├── ants-data.R ├── aspline.downscale.R ├── background.R ├── bbox_poly.R ├── bearing.distance.R ├── breeding.density.R ├── built.index.R ├── cgls_urls.R ├── chae.R ├── chen-data.R ├── classBreaks.R ├── collinear.R ├── combine.R ├── concordance.R ├── conf.interval.R ├── convexHull.R ├── cor.data.R ├── correlogram.R ├── cross.tab.R ├── crossCorrelation.R ├── csi.R ├── curvature.R ├── dahi.R ├── date_seq.R ├── daymet.point.R ├── daymet.tiles.R ├── dispersion.R ├── dissection.R ├── divergence.R ├── effect.size.R ├── elev-data.R ├── erase.points.R ├── extract_vertices.R ├── fuzzySum.R ├── gaussian.kernel.R ├── geo.buffer.R ├── group.pdf.R ├── hexagons.R ├── hli.R ├── hli.pt.R ├── hsp.R ├── hybrid.kmeans.R ├── idw.smoothing.R ├── impute.loess.R ├── insert.R ├── insert.values.R ├── is.empty.R ├── kendall.R ├── kl.divergence.R ├── knn.R ├── lai.R ├── local.min.max.R ├── loess.boot.R ├── loess.ci.R ├── logistic.regression.R ├── max_extent.R ├── mean_angle.R ├── moments.R ├── morans.plot.R ├── nni.R ├── nth.values.R ├── o.ring.R ├── oli.aws.R ├── optimal.k.R ├── optimized.sample.variance.R ├── outliers.R ├── overlap.R ├── parea.sample.R ├── parse.bits.R ├── partial.cor.R ├── plot.effect.size.R ├── plot.loess.boot.R ├── poly.regression.R ├── polyPerimeter.R ├── poly_trend.R ├── pp.subsample.R ├── print.cross.cor.R ├── print.effect.size.R ├── print.loess.boot.R ├── print.poly.trend.R ├── proximity.index.R ├── pseudo.absence.R ├── pu-data.R ├── quadrats.R ├── random.raster.R ├── raster.Zscore.R ├── raster.change.R ├── raster.deviation.R ├── raster.downscale.R ├── raster.entropy.R ├── raster.gaussian.smooth.R ├── raster.invert.R ├── raster.kendall.R ├── raster.mds.R ├── raster.modified.ttest.R ├── raster.moments.R ├── raster.transformations.R ├── raster.vol.R ├── rasterCorrelation.R ├── rasterDistance.R ├── remove.holes.R ├── remove_duplicates.R ├── rm.ext.R ├── rotate.polygon.R ├── sa.trans.R ├── sample.annulus.R ├── sampleTransect.R ├── sar.R ├── separability.R ├── sf.kde.R ├── sf_dissolve.R ├── sg.smooth.R ├── shannons.R ├── shift.R ├── sieve.R ├── similarity.R ├── smooth.time.series.R ├── sobel.R ├── spatial.select.R ├── spatialEcoNews.R ├── spectral.separability.R ├── spherical.sd.R ├── squareBuffer.R ├── srr.R ├── stratified.random.R ├── subsample.distance.R ├── summary.cross.cor.R ├── summary.effect.size.R ├── summary.loess.boot.R ├── swvi.R ├── time_to_event.R ├── topo.distance.R ├── tpi.R ├── trasp.R ├── trend.line.R ├── tri.R ├── vrm.R ├── winsorize.R └── wt.centroids.R ├── README.md ├── _pkgdown.yml ├── data ├── ants.rda ├── chen.rda ├── cor.data.rda └── pu.rda ├── docs ├── 404.html ├── LICENSE-text.html ├── _config.yml ├── authors.html ├── bootstrap-toc.css ├── bootstrap-toc.js ├── docsearch.css ├── docsearch.js ├── index.html ├── link.svg ├── pkgdown.css ├── pkgdown.js ├── pkgdown.yml └── reference │ ├── DAYMET_tiles.html │ ├── Rplot001.png │ ├── Rplot002.png │ ├── Rplot003.png │ ├── Rplot004.png │ ├── annulus.matrix.html │ ├── ants.html │ ├── background-1.png │ ├── background-2.png │ ├── background-3.png │ ├── background-4.png │ ├── background.html │ ├── bearing.distance.html │ ├── breeding.density-1.png │ ├── breeding.density.html │ ├── built.index.html │ ├── cgls_urls.html │ ├── chae-1.png │ ├── chae.html │ ├── chen.html │ ├── class.comparison-1.png │ ├── class.comparison-2.png │ ├── class.comparison-3.png │ ├── class.comparison.html │ ├── classBreaks-1.png │ ├── classBreaks.html │ ├── collinear-1.png │ ├── collinear-2.png │ ├── collinear.html │ ├── combine.html │ ├── concordance.html │ ├── conf.interval-1.png │ ├── conf.interval.html │ ├── convexHull.html │ ├── cor.data.html │ ├── correlogram-1.png │ ├── correlogram.html │ ├── cross.tab.html │ ├── crossCorrelation-1.png │ ├── crossCorrelation.html │ ├── csi.html │ ├── curvature-1.png │ ├── curvature.html │ ├── dahi-1.png │ ├── dahi.html │ ├── date_seq.html │ ├── daymet.point.html │ ├── daymet.tiles.html │ ├── dispersion-1.png │ ├── dispersion.html │ ├── dissection-1.png │ ├── dissection.html │ ├── divergence.html │ ├── download.daymet.html │ ├── download.hansen.html │ ├── download.prism.html │ ├── effect.size-1.png │ ├── effect.size.html │ ├── elev.html │ ├── erase.point-1.png │ ├── erase.point.html │ ├── explode.html │ ├── extract.vertices-1.png │ ├── extract.vertices-2.png │ ├── extract.vertices.html │ ├── focal.lmetrics.html │ ├── fuzzySum.html │ ├── gaussian.kernel-1.png │ ├── gaussian.kernel.html │ ├── geo.buffer-1.png │ ├── geo.buffer.html │ ├── group.pdf-1.png │ ├── group.pdf.html │ ├── hexagons-1.png │ ├── hexagons.html │ ├── hli-1.png │ ├── hli.html │ ├── hsp-1.png │ ├── hsp.html │ ├── hybrid.kmeans-1.png │ ├── hybrid.kmeans.html │ ├── idw.smoothing-1.png │ ├── idw.smoothing.html │ ├── impute.loess-1.png │ ├── impute.loess.html │ ├── index.html │ ├── insert.html │ ├── insert.values.html │ ├── is.empty.html │ ├── is.whole.html │ ├── kde.2D.html │ ├── kendall.html │ ├── kl.divergence-1.png │ ├── kl.divergence.html │ ├── knn-1.png │ ├── knn.html │ ├── land.metrics.html │ ├── local.min.max-1.png │ ├── local.min.max-2.png │ ├── local.min.max.html │ ├── loess.boot-1.png │ ├── loess.boot.html │ ├── loess.ci-1.png │ ├── loess.ci.html │ ├── logistic.regression.html │ ├── max_extent-1.png │ ├── max_extent.html │ ├── moments-1.png │ ├── moments.html │ ├── morans.plot-1.png │ ├── morans.plot-2.png │ ├── morans.plot.html │ ├── mwCorr.html │ ├── nni.html │ ├── nth.values.html │ ├── o.ring-1.png │ ├── o.ring.html │ ├── oli.asw.html │ ├── optimal.k-1.png │ ├── optimal.k-2.png │ ├── optimal.k-3.png │ ├── optimal.k.html │ ├── optimized.sample.variance-1.png │ ├── optimized.sample.variance-2.png │ ├── optimized.sample.variance.html │ ├── outliers.html │ ├── overlap.html │ ├── parea.sample-1.png │ ├── parea.sample.html │ ├── parse.bits.html │ ├── partial.cor.html │ ├── plot.effect.size.html │ ├── plot.loess.boot-1.png │ ├── plot.loess.boot.html │ ├── point.in.poly-1.png │ ├── point.in.poly.html │ ├── poly.regression-1.png │ ├── poly.regression-2.png │ ├── poly.regression.html │ ├── polyPerimeter.html │ ├── polygon_extract-1.png │ ├── polygon_extract-2.png │ ├── polygon_extract.html │ ├── pp.subsample-1.png │ ├── pp.subsample.html │ ├── print.cross.cor.html │ ├── print.effect.size.html │ ├── print.loess.boot.html │ ├── proximity.index-1.png │ ├── proximity.index-2.png │ ├── proximity.index-3.png │ ├── proximity.index.html │ ├── pseudo.absence-1.png │ ├── pseudo.absence-2.png │ ├── pseudo.absence.html │ ├── pu.html │ ├── quadrats.html │ ├── random.raster.html │ ├── raster.Zscore.html │ ├── raster.change-1.png │ ├── raster.change.html │ ├── raster.deviation-1.png │ ├── raster.deviation.html │ ├── raster.downscale.html │ ├── raster.entropy-1.png │ ├── raster.entropy.html │ ├── raster.gaussian.smooth-1.png │ ├── raster.gaussian.smooth.html │ ├── raster.invert-1.png │ ├── raster.invert.html │ ├── raster.kendall.html │ ├── raster.mds-1.png │ ├── raster.mds.html │ ├── raster.modified.ttest.html │ ├── raster.moments.html │ ├── raster.transformation.html │ ├── raster.vol-1.png │ ├── raster.vol.html │ ├── rasterCorrelation-1.png │ ├── rasterCorrelation.html │ ├── rasterDistance.html │ ├── remove.holes-1.png │ ├── remove.holes.html │ ├── rm.ext.html │ ├── rotate.polygon-1.png │ ├── rotate.polygon.html │ ├── sa.trans.html │ ├── sample.annulus-1.png │ ├── sample.annulus.html │ ├── sample.line-1.png │ ├── sample.line.html │ ├── sample.poly-1.png │ ├── sample.poly.html │ ├── sampleTransect-1.png │ ├── sampleTransect.html │ ├── sar-1.png │ ├── sar.html │ ├── se.news.html │ ├── separability-1.png │ ├── separability.html │ ├── sg.smooth-1.png │ ├── sg.smooth.html │ ├── shannons.html │ ├── shift.html │ ├── similarity-1.png │ ├── similarity.html │ ├── smooth.time.series.html │ ├── sobal-1.png │ ├── sobal.html │ ├── sp.kde-1.png │ ├── sp.kde-2.png │ ├── sp.kde-3.png │ ├── sp.kde-4.png │ ├── sp.kde.html │ ├── sp.na.omit-1.png │ ├── sp.na.omit.html │ ├── spatial.select-1.png │ ├── spatial.select-2.png │ ├── spatial.select.html │ ├── spectral.separability.html │ ├── spherical.sd-1.png │ ├── spherical.sd.html │ ├── srr-1.png │ ├── srr.html │ ├── stratified.random-1.png │ ├── stratified.random.html │ ├── subsample.distance-1.png │ ├── subsample.distance-2.png │ ├── subsample.distance.html │ ├── summary.cross.cor.html │ ├── summary.effect.size.html │ ├── summary.loess.boot.html │ ├── swvi.html │ ├── time_to_event.html │ ├── topo.distance-1.png │ ├── topo.distance.html │ ├── tpi-1.png │ ├── tpi.html │ ├── trasp-1.png │ ├── trasp.html │ ├── trend.line-1.png │ ├── trend.line.html │ ├── tri-1.png │ ├── tri.html │ ├── vrm-1.png │ ├── vrm.html │ ├── winsorize-1.png │ ├── winsorize.html │ ├── wt.centroid-1.png │ ├── wt.centroid.html │ ├── zonal.stats-1.png │ └── zonal.stats.html ├── inst ├── CITATION ├── NEWS └── extdata │ ├── Landsat_TM5.tif │ └── elev.tif └── man ├── TM5.Rd ├── all_pairwise.Rd ├── annulus.matrix.Rd ├── ants.Rd ├── aspline.downscale.Rd ├── background.Rd ├── bbox_poly.Rd ├── bearing.distance.Rd ├── breeding.density.Rd ├── built.index.Rd ├── cgls_urls.Rd ├── chae.Rd ├── chen.Rd ├── classBreaks.Rd ├── collinear.Rd ├── combine.Rd ├── concordance.Rd ├── conf.interval.Rd ├── convexHull.Rd ├── cor.data.Rd ├── correlogram.Rd ├── cross.tab.Rd ├── crossCorrelation.Rd ├── csi.Rd ├── curvature.Rd ├── dahi.Rd ├── date_seq.Rd ├── daymet.point.Rd ├── daymet.tiles.Rd ├── dispersion.Rd ├── dissection.Rd ├── divergence.Rd ├── effect.size.Rd ├── elev.Rd ├── erase.point.Rd ├── extract.vertices.Rd ├── figures └── logo.png ├── fuzzySum.Rd ├── gaussian.kernel.Rd ├── geo.buffer.Rd ├── group.pdf.Rd ├── hexagons.Rd ├── hli.Rd ├── hli.pt.Rd ├── hsp.Rd ├── hybrid.kmeans.Rd ├── idw.smoothing.Rd ├── impute.loess.Rd ├── insert.Rd ├── insert.values.Rd ├── is.empty.Rd ├── kendall.Rd ├── kl.divergence.Rd ├── knn.Rd ├── lai.Rd ├── local.min.max.Rd ├── loess.boot.Rd ├── loess.ci.Rd ├── logistic.regression.Rd ├── max_extent.Rd ├── mean_angle.Rd ├── moments.Rd ├── morans.plot.Rd ├── nni.Rd ├── nth.values.Rd ├── o.ring.Rd ├── oli.aws.Rd ├── optimal.k.Rd ├── optimized.sample.variance.Rd ├── outliers.Rd ├── overlap.Rd ├── parea.sample.Rd ├── parse.bits.Rd ├── partial.cor.Rd ├── plot.effect.size.Rd ├── plot.loess.boot.Rd ├── poly.regression.Rd ├── polyPerimeter.Rd ├── poly_trend.Rd ├── pp.subsample.Rd ├── print.cross.cor.Rd ├── print.effect.size.Rd ├── print.loess.boot.Rd ├── print.poly.trend.Rd ├── proximity.index.Rd ├── pseudo.absence.Rd ├── pu.Rd ├── quadrats.Rd ├── random.raster.Rd ├── raster.Zscore.Rd ├── raster.change.Rd ├── raster.deviation.Rd ├── raster.downscale.Rd ├── raster.entropy.Rd ├── raster.gaussian.smooth.Rd ├── raster.invert.Rd ├── raster.kendall.Rd ├── raster.mds.Rd ├── raster.modified.ttest.Rd ├── raster.moments.Rd ├── raster.transformation.Rd ├── raster.vol.Rd ├── rasterCorrelation.Rd ├── rasterDistance.Rd ├── remove.holes.Rd ├── remove_duplicates.Rd ├── rm.ext.Rd ├── rotate.polygon.Rd ├── sa.trans.Rd ├── sample.annulus.Rd ├── sampleTransect.Rd ├── sar.Rd ├── separability.Rd ├── sf.kde.Rd ├── sf_dissolve.Rd ├── sg.smooth.Rd ├── shannons.Rd ├── shift.Rd ├── sieve.Rd ├── similarity.Rd ├── smooth.time.series.Rd ├── sobal.Rd ├── spatial.select.Rd ├── spatialEcoNews.Rd ├── spectral.separability.Rd ├── spherical.sd.Rd ├── squareBuffer.Rd ├── srr.Rd ├── stratified.random.Rd ├── subsample.distance.Rd ├── summary.cross.cor.Rd ├── summary.effect.size.Rd ├── summary.loess.boot.Rd ├── swvi.Rd ├── time_to_event.Rd ├── topo.distance.Rd ├── tpi.Rd ├── trasp.Rd ├── trend.line.Rd ├── tri.Rd ├── vrm.Rd ├── winsorize.Rd └── wt.centroid.Rd /.Rbuildignore: -------------------------------------------------------------------------------- 1 | cran-comments.md 2 | README.md 3 | LICENSE 4 | .git 5 | .github 6 | ^CRAN-RELEASE$ 7 | ^.*\.Rproj$ 8 | ^\.Rproj\.user$ 9 | ^_pkgdown\.yml$ 10 | ^docs$ 11 | ^pkgdown$ 12 | ^extdata$ 13 | ^\.github$ 14 | -------------------------------------------------------------------------------- /.github/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | -------------------------------------------------------------------------------- /.github/workflows/R-CMD-check.yaml: -------------------------------------------------------------------------------- 1 | # Workflow derived from https://github.com/r-lib/actions/tree/v2/examples 2 | # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help 3 | on: 4 | push: 5 | branches: [main, master] 6 | pull_request: 7 | branches: [main, master] 8 | 9 | name: R-CMD-check 10 | 11 | jobs: 12 | R-CMD-check: 13 | runs-on: ${{ matrix.config.os }} 14 | 15 | name: ${{ matrix.config.os }} (${{ matrix.config.r }}) 16 | 17 | strategy: 18 | fail-fast: false 19 | matrix: 20 | config: 21 | - {os: windows-latest, r: 'release'} 22 | env: 23 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 24 | R_KEEP_PKG_SOURCE: yes 25 | 26 | steps: 27 | - uses: actions/checkout@v3 28 | 29 | - uses: r-lib/actions/setup-pandoc@v2 30 | 31 | - uses: r-lib/actions/setup-r@v2 32 | with: 33 | r-version: ${{ matrix.config.r }} 34 | http-user-agent: ${{ matrix.config.http-user-agent }} 35 | use-public-rspm: true 36 | 37 | - uses: r-lib/actions/setup-r-dependencies@v2 38 | with: 39 | extra-packages: any::rcmdcheck 40 | needs: check 41 | 42 | - uses: r-lib/actions/check-r-package@v2 43 | with: 44 | upload-snapshots: true 45 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | docs 2 | .Rproj.user 3 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: spatialEco 2 | Type: Package 3 | Title: Spatial Analysis and Modelling Utilities 4 | Version: 2.0-3 5 | Date: 2025-03-03 6 | Authors@R: c( 7 | person(family="Evans", given="Jeffrey S.", email = "jeffrey_evans@tnc.org", 8 | role = c("aut", "cre"), comment = c(ORCID = "0000-0002-5533-7044")), 9 | person(family="Murphy", given="Melanie A.", role = "ctb"), 10 | person(family="Ram", given="Karthik", role = "ctb") ) 11 | Description: Utilities to support spatial data manipulation, query, sampling 12 | and modelling in ecological applications. Functions include models for species 13 | population density, spatial smoothing, multivariate separability, point process 14 | model for creating pseudo- absences and sub-sampling, Quadrant-based sampling and 15 | analysis, auto-logistic modeling, sampling models, cluster optimization, statistical 16 | exploratory tools and raster-based metrics. 17 | Depends: R (>= 4.2) 18 | Imports: 19 | sf, 20 | terra 21 | Suggests: 22 | alphahull, 23 | spatstat.geom (>= 3.0-3), 24 | spatstat.explore, 25 | spdep, 26 | ks, 27 | cluster, 28 | readr, 29 | RCurl, 30 | RANN, 31 | rms, 32 | yaImpute, 33 | mgcv, 34 | zyp, 35 | SpatialPack (>= 0.3), 36 | MASS, 37 | caret, 38 | dplyr, 39 | earth, 40 | Matrix, 41 | gstat, 42 | spatstat.data, 43 | methods, 44 | units, 45 | sp, 46 | stringr, 47 | lwgeom, 48 | geodata 49 | Maintainer: Jeffrey S. Evans 50 | License: GPL-3 51 | URL: https://github.com/jeffreyevans/spatialEco, https://jeffreyevans.github.io/spatialEco/ 52 | BugReports: https://github.com/jeffreyevans/spatialEco/issues 53 | NeedsCompilation: no 54 | Repository: CRAN 55 | LazyData: true 56 | Encoding: UTF-8 57 | RoxygenNote: 7.3.2 58 | -------------------------------------------------------------------------------- /R/TM5-data.R: -------------------------------------------------------------------------------- 1 | #' @name TM5 2 | #' @docType data 3 | #' 4 | #' @title Landsat 5 TM Scene 5 | #' 6 | #' @description 7 | #' Subset of Landsat 5 TM Scene: LT52240631988227CUB02 Contains six bands of surface reflectance 8 | #' path 224/row 63 acquisition date: 1988-08-14 13:00:47 GMT, EPSG:32622 9 | #' 10 | #' @format A tif (inst/extdata/Landsat_TM5.tif) with 30m 6 bands: 11 | #' \describe{ 12 | #' \item{Blue}{0.45 - 0.52 µm} 13 | #' \item{Green}{0.52 - 0.60 µm} 14 | #' \item{Red}{0.63 - 0.69 µm} 15 | #' \item{NIR Near-Infrared}{0.76 - 0.90 µm} 16 | #' \item{SWIR1 Near-Infrared}{1.55 - 1.75 µm} 17 | #' \item{SWIR2 Mid-Infrared}{2.08 - 2.35 µm} 18 | #' } 19 | #' 20 | NULL 21 | -------------------------------------------------------------------------------- /R/all_pairwise.R: -------------------------------------------------------------------------------- 1 | #' @title All pairwise combinations 2 | #' @description Creates all pairwise combinations list for iteration 3 | #' 4 | #' @param x A numeric or character vector 5 | #' 6 | #' @details 7 | #' This returns a list of vector combinations starting with 8 | #' pairwise, as the first nested list element, then in groups of 9 | #' threes, fours, to length of the vector. 10 | #' 11 | #' @return A list object with increasing all combination objects, 12 | #' the first list element are the pairwise comparisons 13 | #' 14 | #' @author Jeffrey S. Evans tnc.org> 15 | #' 16 | #' @examples 17 | #' classes <- paste0("class", 1:10) 18 | #' 19 | #' all_pairwise(classes)[[1]] 20 | #' 21 | #' #### How to use as an iterator 22 | #' # dataframe with 4 cols, 100 rows 23 | #' d <- as.data.frame(matrix(runif(100*4), 100, 4)) 24 | #' names(d) <- paste0("class", 1:4) 25 | #' 26 | #' ( idx <- all_pairwise(colnames(d))[[1]] ) 27 | #' 28 | #' opar <- par(no.readonly=TRUE) 29 | #' par(mfrow=c(2,3)) 30 | #' lapply(idx, function(i) { 31 | #' plot(d[,i[1]], d[,i[2]], main=paste0(i[1], " vs ", i[2]) ) 32 | #' }) 33 | #' par(opar) 34 | #' 35 | #' @export 36 | all_pairwise <- function(x) { 37 | if(!is.vector(x)) 38 | stop(deparse(substitute(x)), " must be a vector object") 39 | n <- length(x) 40 | idx <- lapply(2:n, function(y) { 41 | utils::combn(x, y, simplify = FALSE) 42 | }) 43 | return(idx) 44 | } 45 | -------------------------------------------------------------------------------- /R/ants-data.R: -------------------------------------------------------------------------------- 1 | #' @name ants 2 | #' @docType data 3 | #' 4 | #' @title Ant Biodiversity Data 5 | #' 6 | #' @description Roth et al., (1994) Costa Rican ant diversity data 7 | #' 8 | #' @format A data.frame with 82 rows (species) and 5 columns (covertypes): 9 | #' \describe{ 10 | #' \item{species}{Ant species (family)} 11 | #' \item{Primary.Forest}{Primary forest type} 12 | #' \item{Abandoned.cacao.plantations}{Abandoned cacao plantations type} 13 | #' \item{Productive.cacao.plantations}{Active cacao plantations type} 14 | #' \item{Banana.plantations}{Active banana plantations type} 15 | #' } 16 | #' 17 | #' @references Roth, D. S., I. Perfecto, and B. Rathcke (1994) The effects of management systems on 18 | #' ground-foraging ant diversity in Costa Rica. Ecological Applications 4(3):423-436. 19 | #' 20 | NULL -------------------------------------------------------------------------------- /R/bearing.distance.R: -------------------------------------------------------------------------------- 1 | #' @title Bearing and Distance 2 | #' @description Calculates a new point [X,Y] based on defined 3 | #' bearing and distance 4 | #' 5 | #' @param x x coordinate 6 | #' @param y y coordinate 7 | #' @param distance Distance to new point (in same units as x,y) 8 | #' @param azimuth Azimuth to new point 9 | #' @param EastOfNorth Specified surveying convention 10 | #' 11 | #' @details East of north is a surveying convention and defaults to true. 12 | #' 13 | #' @return a new point representing location of baring and distance 14 | #' 15 | #' @author Jeffrey S. Evans 16 | #' 17 | #' @examples 18 | #' pt <- cbind( x=480933, y=4479433) 19 | #' bearing.distance(pt[1], pt[2], 1000, 40) 20 | #' 21 | #' @export bearing.distance 22 | bearing.distance <- function(x, y, distance, azimuth, EastOfNorth = TRUE) { 23 | radians <- function(a) { a * (pi / 180) } 24 | if(EastOfNorth) { 25 | pt <- cbind( X = (x + distance * sin(radians(azimuth))), 26 | Y = (y + distance * cos(radians(azimuth)))) 27 | } else { 28 | pt <- cbind( X = (x + distance * cos(radians(azimuth))), 29 | Y = (y + distance * sin(radians(azimuth)))) 30 | } 31 | return(pt) 32 | } 33 | -------------------------------------------------------------------------------- /R/cgls_urls.R: -------------------------------------------------------------------------------- 1 | #' @title Provide URL's for Copernicus Global Land Service datasets 2 | #' @description Returns URL's of a product/version/resolution 3 | #' 4 | #' @param ... not used 5 | #' 6 | #' @details 7 | #' Given the changes to ESA-Copenricus data distribution, using digests is 8 | #' no longer reliable. Plese use the Sentinel Hub or a STAC API for data 9 | #' acccess 10 | #' 11 | #' @export cgls_urls 12 | cgls_urls <- function(...) { 13 | .Deprecated("cgls_urls", package="spatialEco", 14 | msg="Given the changes to ESA-Copenricus data distribution, using the data 15 | digest is no longer reliable") 16 | message("Plese use the Sentinel Hub or a STAC API for data acccess") 17 | } 18 | -------------------------------------------------------------------------------- /R/chae.R: -------------------------------------------------------------------------------- 1 | #' @title Canine-Human Age Equivalent 2 | #' @description Calculates canines equivalent human age (for fun) 3 | #' 4 | #' @param x numeric vector, dog age 5 | #' @return numeric vector, equivalent human age 6 | #' 7 | #' @references 8 | #' Wang, T., J. M, A.N. Hogan, S. Fong, K. Licon et al. (2020) quantitative 9 | #' translation of dog-to-human aging by conserved remodeling of epigenetic 10 | #' networks. Cell Systems 11(2)176-185 11 | #' 12 | #' @author Jeffrey S. Evans 13 | #' 14 | #' @examples 15 | #' dat <- data.frame(DogAge = seq(0,18,0.25), 16 | #' HumanAge=chae(seq(0,18,0.25)))[-1,] 17 | #' 18 | #' plot(dat$DogAge, dat$HumanAge, "l", 19 | #' main="Canine-Human Age Equivalence", 20 | #' ylab="Human Age", xlab="Dog Age") 21 | #' points( 15, chae(15), col="red", pch=19, cex=1.5) 22 | #' points( 10, chae(10), col="blue", pch=19, cex=1.5) 23 | #' points( 3, chae(3), col="black", pch=19, cex=1.5) 24 | #' legend("bottomright", legend=c("Camas (15-YO)", "Kele (10-YO)", "Aster (3-YO)"), 25 | #' pch=c(19,19,19), cex=c(1.5,1.5,1.5), 26 | #' col=c("red","blue","black")) 27 | #' 28 | #' @export 29 | chae <- function(x) { round(16 * log(x) + 31, 2) } 30 | -------------------------------------------------------------------------------- /R/chen-data.R: -------------------------------------------------------------------------------- 1 | #' @name chen 2 | #' @docType data 3 | #' 4 | #' @title Cross-correlation data from Chen (2015) 5 | #' 6 | #' @description Urbanization and economic development data from Chen (2015) 7 | #' compiled from, National Bureau of Statistics of China 8 | #' 9 | #' @format A list object with 3 elements: 10 | #' \describe{ 11 | #' \item{X}{per capita GRP(yuan)} 12 | #' \item{Y}{Level of urbanization percent} 13 | #' \item{M}{Railway Distance (km) matrix of 29 Chinese regions} 14 | #' } 15 | #' 16 | #' @references 17 | #' Chen, Y.G. (2012) On the four types of weight functions for spatial contiguity 18 | #' matrix. Letters in Spatial and Resource Sciences 5(2):65-72 19 | #' @references 20 | #' Chen, Y.G. (2013) New approaches for calculating Moran’s index of spatial 21 | #' autocorrelation. PLoS ONE 8(7):e68336 22 | #' @references 23 | #' Chen, Y.G. (2015) A New Methodology of Spatial Cross-Correlation Analysis. 24 | #' PLoS One 10(5):e0126158. doi:10.1371/journal.pone.0126158 25 | #' 26 | #' @source \url{https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0126158} 27 | NULL -------------------------------------------------------------------------------- /R/cor.data.R: -------------------------------------------------------------------------------- 1 | #' @name cor.data 2 | #' @description linear and nonlinear correlated data examples 3 | #' @docType data 4 | #' 5 | #' @title Various correlation structures 6 | #' 7 | #' @description 8 | #' A list object with various linear and nonlinear correlation structures 9 | #' 10 | #' @format A list object with 4 elements containing data.frames: 11 | #' \describe{ 12 | #' \item{example 1}{two columns with nonlinear wave function relationship} 13 | #' \item{example 2}{two columns with simple nonlinear relationship} 14 | #' \item{example 3}{two columns with nonlinear multi-level wave function relationship} 15 | #' \item{example 4}{4 columns with first two having linear relationship} 16 | #' } 17 | #' 18 | NULL -------------------------------------------------------------------------------- /R/dahi.R: -------------------------------------------------------------------------------- 1 | #' @title Diurnal Anisotropic Heat Index 2 | #' @description 3 | #' Simple approximation of the anisotropic diurnal heat (Ha) distribution 4 | #' 5 | #' @param x An elevation raster of class terra SpatRaster 6 | #' @param amax The Alpha Max (amax) parameter in degrees defined 7 | #' as: minimum = 0, maximum = 360 with the default = 202.500 8 | #' 9 | #' @details 10 | #' The Diurnal Anisotropic Heat Index is based on this equation. 11 | #' Ha = cos(amax - a) * arctan(b) 12 | #' Where; amax defines the aspect with the maximum total heat 13 | #' surplus, a is the aspect and b is the slope angle. Please 14 | #' note that all parameters are converted to radians. 15 | #' 16 | #' @return terra SpatRaster class object Diurnal Anisotropic Heat Index 17 | #' 18 | #' @author Jeffrey S. Evans 19 | #' 20 | #' @references 21 | #' Boehner, J., and Antonic, O. (2009) Land-surface parameters specific to 22 | #' topo-climatology. In: Hengl, T., & Reuter, H. (Eds.), Geomorphometry - 23 | #' Concepts, Software, Applications. Developments in Soil Science, 24 | #' 33:195-226 25 | 26 | #' @examples 27 | #' library(terra) 28 | #' elev <- rast(system.file("extdata/elev.tif", package="spatialEco")) 29 | #' Ha <- dahi(elev) 30 | #' plot(Ha, col=grey(0:100/100), smooth=TRUE) 31 | #' 32 | #' @export dahi 33 | dahi <- function(x, amax = 202.500) { 34 | if(!inherits(x, "SpatRaster")) 35 | stop(deparse(substitute(x)), " must be a terra SpatRaster object") 36 | amax = amax * (pi/180) 37 | tr <- terra::terrain(x, v=c("slope", "aspect"), unit="radians") 38 | return( cos(amax - tr[[2]]) * atan(tr[[1]]) ) 39 | } 40 | -------------------------------------------------------------------------------- /R/daymet.tiles.R: -------------------------------------------------------------------------------- 1 | #' @title DAYMET Tile ID's 2 | #' @description Returns a vector of DAYMET tile id's within a specified extent 3 | #' 4 | #' @param ... ignored 5 | #' 6 | #' @return 7 | #' Vector of DAYMET tile IDS or if sp = TRUE a sp class SpatialPolygonsDataFrame 8 | #' 9 | #' @note 10 | #' Function accepts sp, raster or extent class object or bounding coordinates. 11 | #' All input must be in the same projection as the tile index SpatialPolygonsDataFrame. 12 | #' The library includes the DAYMAT tile index "DAYMET_tiles" which can be add using 13 | #' data(), see examples. 14 | #' 15 | #' @author Jeffrey S. Evans 16 | #' 17 | #' @export daymet.tiles 18 | daymet.tiles <- function(...) { 19 | message("Because THREDDS has moved to a NetCDF Markup Language (NcML) query service, 20 | this function is currently depreciated") 21 | message("You can access the North America NetCDF subset tool here: 22 | https://thredds.daac.ornl.gov/thredds/ncss/grid/daymet-v3-agg/na.ncml/dataset.html") 23 | .Deprecated("daymet.tiles", package="spatialEco", 24 | msg="Function is deprecated due to significant changes to the ORNL DAAC THREDDS server") 25 | } 26 | -------------------------------------------------------------------------------- /R/dissection.R: -------------------------------------------------------------------------------- 1 | #' @title Dissection 2 | #' @description Calculates the Evans (1972) Martonne's modified 3 | #' dissection 4 | #' 5 | #' @param x A terra SpatRaster class object 6 | #' @param s Focal window size 7 | #' @param ... Additional arguments passed to terra::lapp 8 | #' 9 | #' @details 10 | #' Dissection is calculated as: 11 | #' ( z(s) - min(z(s)) ) / ( max(z(s)) - min(z(s)) ) 12 | #' 13 | #' @return A SpatRaster class object of Martonne's modified dissection 14 | #' 15 | #' @author Jeffrey S. Evans 16 | #' 17 | #' @examples 18 | #' \donttest{ 19 | #' library(terra) 20 | #' elev <- rast(system.file("extdata/elev.tif", package="spatialEco")) 21 | #' d <- dissection(elev, s=3) 22 | #' plot(d, main="dissection") 23 | #' } 24 | #' 25 | #' @export dissection 26 | dissection <- function(x, s=5, ...) { 27 | if (!inherits(x, "SpatRaster")) 28 | stop(deparse(substitute(x)), " must be a terra SpatRaster object") 29 | if( length(s) == 1) s = c(s[1],s[1]) 30 | m <- matrix(1, nrow=s, ncol=s) 31 | rmin <- terra::focal(x, w=m, fun=min) 32 | rmax <- terra::focal(x, w=m, fun=max) 33 | return( terra::lapp(c(x,rmin,rmax), fun = function(x,y,z) { (x - y ) / 34 | ( z - y ) }, ... ) ) 35 | } 36 | -------------------------------------------------------------------------------- /R/divergence.R: -------------------------------------------------------------------------------- 1 | #' @title divergence 2 | #' @description Kullback-Leibler Divergence (Cross-entropy) 3 | #' 4 | #' @param x a vector of integer values, defining observed 5 | #' @param y a vector of integer values, defining estimates 6 | #' @param type Type of divergence statistic c("Kullback-Leibler", 7 | #' "cross-entropy") 8 | #' 9 | #' @return single value vector with divergence statistic 10 | #' 11 | #' @author Jeffrey S. Evans 12 | #' 13 | #' @examples 14 | #' x <- round(runif(10,1,4),0) 15 | #' y <- round(runif(10,1,4),0) 16 | #' 17 | #' divergence(x, y) 18 | #' divergence(x, y, type = "cross-entropy") 19 | #' 20 | #' @export divergence 21 | divergence <- function(x, y, type = c("Kullback-Leibler", "cross-entropy")) { 22 | type = type[1] 23 | if(!is.vector(x) | !is.vector(y)) 24 | stop("x and y must be numeric of character vectors") 25 | if(any(type %in% c("Kullback-Leibler", "cross-entropy")==FALSE)) 26 | stop("Not a valid option for statistic type") 27 | q <- table(x) / sum(table(x)) # observed or approximated 28 | p <- table(y) / sum(table(y)) # estimated or probability 29 | classes <- intersect(names(q), names(p)) 30 | p <- p[which(names(p) %in% classes)] 31 | q <- q[which(names(q) %in% classes)] 32 | if(type == "cross-entropy") { 33 | message("Cross-Entropy", "\n") 34 | return( -sum( q, log(p) ) ) 35 | } else if(type == "Kullback-Leibler") { 36 | message("Kullback-Leibler", "\n") 37 | return( sum( p * log(p / q) ) ) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /R/elev-data.R: -------------------------------------------------------------------------------- 1 | #' @name elev 2 | #' @docType data 3 | #' 4 | #' @title Elevation raster 5 | #' 6 | #' @description elevation raster of Switzerland 7 | #' 8 | #' @format A raster RasterLayer class object: 9 | #' \describe{ 10 | #' \item{resoultion}{5 arc-minute 0.00833 (10000m)} 11 | #' \item{nrow}{264} 12 | #' \item{ncol}{564} 13 | #' \item{ncell}{148896} 14 | #' \item{xmin}{5.9} 15 | #' \item{xmax}{10.6} 16 | #' \item{ymin}{45.7} 17 | #' \item{ymax}{47.9} 18 | #' \item{proj4string}{+proj=longlat +ellps=WGS84} 19 | #' } 20 | #' 21 | #' @source \url{http://www.diva-gis.org/Data} 22 | NULL 23 | -------------------------------------------------------------------------------- /R/fuzzySum.R: -------------------------------------------------------------------------------- 1 | #' @title Fuzzy Sum 2 | #' @description Calculates the fuzzy sum of a vector 3 | #' 4 | #' @param x Vector of values to apply fuzzy sum 5 | #' 6 | #' @details 7 | #' The fuzzy sum is an increasing linear combination of values. 8 | #' This can be used to sum probabilities or results of multiple 9 | #' density functions. 10 | #' 11 | #' @return Value of fuzzy sum 12 | #' 13 | #' @author Jeffrey S. Evans 14 | #' 15 | #' @examples 16 | #' p = c(0.8,0.76,0.87) 17 | #' fuzzySum(p) 18 | #' sum(p) 19 | #' 20 | #' p = c(0.3,0.2,0.1) 21 | #' fuzzySum(p) 22 | #' sum(p) 23 | #' 24 | #' @export 25 | fuzzySum <- function(x) { return( 1 - prod( (1 - x) ) ) } 26 | -------------------------------------------------------------------------------- /R/gaussian.kernel.R: -------------------------------------------------------------------------------- 1 | #' @title Gaussian Kernel 2 | #' @description Creates a Gaussian Kernel of specified size and sigma 3 | #' 4 | #' @param sigma sigma (standard deviation) of kernel (defaults 2) 5 | #' @param s scale defining the number of rows and columns for kernel (default 5) 6 | #' 7 | #' @return Symmetrical (NxN) matrix of a Gaussian distribution 8 | #' 9 | #' @author Jeffrey S. Evans 10 | #' 11 | #' @examples 12 | #' opar <- par() 13 | #' par(mfrow=c(2,2)) 14 | #' persp(gaussian.kernel(sigma=1, s=27), theta = 135, 15 | #' phi = 30, col = "grey", ltheta = -120, shade = 0.6, 16 | #' border=NA ) 17 | #' persp(gaussian.kernel(sigma=2, s=27), theta = 135, phi = 30, 18 | #' col = "grey", ltheta = -120, shade = 0.6, border=NA ) 19 | #' persp(gaussian.kernel(sigma=3, s=27), theta = 135, phi = 30, 20 | #' col = "grey", ltheta = -120, shade = 0.6, border=NA ) 21 | #' persp(gaussian.kernel(sigma=4, s=27), theta = 135, phi = 30, 22 | #' col = "grey", ltheta = -120, shade = 0.6, border=NA ) 23 | #' par(opar) 24 | #' @export 25 | gaussian.kernel <- function(sigma=2, s=5) { 26 | m <- matrix(ncol=s, nrow=s) 27 | mcol <- rep(1:s, s) 28 | mrow <- rep(1:s, each=s) 29 | x <- mcol - ceiling(s/2) 30 | y <- mrow - ceiling(s/2) 31 | m[cbind(mrow, mcol)] <- 1/(2*pi*sigma^2) * exp(-(x^2+y^2)/(2*sigma^2)) 32 | m / sum(m) 33 | } 34 | -------------------------------------------------------------------------------- /R/geo.buffer.R: -------------------------------------------------------------------------------- 1 | #' @title Buffer geographic data 2 | #' @description Buffers data in geographic (Latitude/Longitude) projection 3 | #' 4 | #' @param x A sf or sp vector class object 5 | #' @param r Buffer radius in meters 6 | #' @param ... Additional arguments passed to sf::st_buffer 7 | #' 8 | #' @details 9 | #' Projects (Latitude/Longitude) data in decimal-degree geographic projection 10 | #' using an on-the-fly azimuthal equidistant projection in meters centered on 11 | # each feature. 12 | #' 13 | #' @return an sp or sf polygon class object representing buffer for each feature 14 | #' 15 | #' @author Jeffrey S. Evans 16 | #' 17 | #' @examples 18 | #' library(sf) 19 | #' e <- c(61.87125, 23.90153, 76.64458, 37.27042) 20 | #' names(e) <- c("xmin", "ymin", "xmax", "ymax") 21 | #' s <- st_as_sf(st_sample(st_as_sfc(st_bbox(e)), size=100, 22 | #' type = "regular")) 23 | #' st_crs(s) <- st_crs(4326) 24 | #' s$id <- 1:nrow(s) 25 | #' 26 | #' b <- geo.buffer(x=s, r=1000) 27 | #' plot(st_geometry(b[1,])) 28 | #' plot(st_geometry(s[1,]), pch=20,cex=2, add=TRUE) 29 | #' 30 | #' @seealso \code{\link[sf]{st_buffer}} for st_buffer ... arguments 31 | #' 32 | #' @export geo.buffer 33 | geo.buffer <- function(x, r, ...) { 34 | prj <- sf::st_crs("+proj=aeqd +R=6371000 +lat_0=51 +lon_0=7") 35 | if(missing(x) | missing(r)) 36 | stop("must supply x and r arguments") 37 | if(!inherits(x, "sf")) 38 | stop(deparse(substitute(x)), " must be an sf POINT object") 39 | if(unique(as.character(sf::st_geometry_type(x))) != "POINT") 40 | stop(deparse(substitute(x)), " must be an sf POINT object") 41 | if(is.na(sf::st_crs(x))) 42 | stop(deparse(substitute(x)), " must have a defined projection") 43 | if(!sf::st_is_longlat(x)) 44 | stop("Data appears to be projected and not Latitude/Longitude") 45 | b <- sf::st_buffer(sf::st_transform(x, prj), dist=r, ...) 46 | b <- sf::st_transform(b, sf::st_crs(4326)) 47 | return( b ) 48 | } 49 | -------------------------------------------------------------------------------- /R/hexagons.R: -------------------------------------------------------------------------------- 1 | #' @title Hexagons 2 | #' @description Create hexagon polygons 3 | #' 4 | #' @param x sf class object indicating extent 5 | #' @param res Area of resulting hexagons 6 | #' 7 | #' @details 8 | #' Based on extent of x, creates a hexagon mesh with size of hexagons defined by res argumnet 9 | #' 10 | #' @return sf POLYGONS object 11 | #' 12 | #' @examples 13 | #' library(sf) 14 | #' if(require(sp, quietly = TRUE)) { 15 | #' data(meuse, package = "sp") 16 | #' meuse <- st_as_sf(meuse, coords = c("x", "y"), crs = 28992, 17 | #' agr = "constant") 18 | #' 19 | #' hex <- hexagons(meuse, res=300) 20 | #' plot(st_geometry(hex)) 21 | #' plot(st_geometry(meuse),pch=20,add=TRUE) 22 | #' 23 | #' # subset hexagons to intersection with points 24 | #' idx <- which(apply(st_intersects(hex, meuse, sparse=FALSE), 1, any)) 25 | #' hex.sub <- hex[idx,] 26 | #' plot(st_geometry(hex.sub)) 27 | #' plot(st_geometry(meuse),pch=20,add=TRUE) 28 | #' 29 | #' } else { 30 | #' cat("Please install sp package to run example", "\n") 31 | #' } 32 | #' 33 | #' @export 34 | hexagons <- function(x, res = 100) { 35 | if(!inherits(x, "sf")) 36 | stop(deparse(substitute(x)), " must be an sf object") 37 | if(sf::st_is_longlat(x)) 38 | stop("Data appears to be in Latitude/Longitude 39 | and needs to be projected") 40 | e <- sf::st_as_sfc(sf::st_bbox(x)) 41 | res <- sf::st_as_sf(sf::st_make_grid(e, cellsize = res, 42 | square = FALSE)) 43 | sf::st_geometry(res) <- "geometry" 44 | sf::st_crs(res) <- sf::st_crs(x) 45 | return(res) 46 | } 47 | -------------------------------------------------------------------------------- /R/impute.loess.R: -------------------------------------------------------------------------------- 1 | #' @title Impute loess 2 | #' @description Imputes missing data or smooths using Loess regression 3 | #' 4 | #' @param y A vector to impute 5 | #' @param s Smoothing parameter () 6 | #' @param smooth (FALSE/TRUE) Smooth data, else only replace NA's 7 | #' 8 | #' @details 9 | #' Performs a local polynomial regression to smooth data or to 10 | #' impute NA values. The minimal number of non-NA observations to reliably 11 | #' impute/smooth values is 6. There is not a reliably way to impute NA's 12 | #' on the tails of the distributions so if the missing data is in the 13 | #' first or last position of the vector it will remain NA. Please note 14 | #' that smooth needs to be TRUE to return a smoothed vector, else only 15 | #' NA's will be imputed. 16 | #' 17 | #' @return 18 | #' A vector the same length as x with NA values filled or the data smoothed (or both). 19 | #' 20 | #' @author Jeffrey S. Evans tnc.org> 21 | #' 22 | #' @examples 23 | #' data(cor.data) 24 | #' d <- cor.data[[1]][,2] 25 | #' plot(d, type="l") 26 | #' lines(impute.loess(d, s=0.3, smooth=TRUE), lwd=2, col="red") 27 | #' 28 | #' # add some NA's 29 | #' d <- d[1:100] 30 | #' d[sample(30:70, 5)] <- NA 31 | #' d 32 | #' 33 | #' impute.loess(d, s=0.2) 34 | #' 35 | #' @export impute.loess 36 | impute.loess <- function(y, s = 0.2, smooth = FALSE) { 37 | x.length = length(y) 38 | if(length(y[!is.na(y)]) < 6) { 39 | warning("Fewer than 6 real-value observations, assigning NA") 40 | y <- rep(NA, x.length) 41 | } else { 42 | x <- 1:x.length 43 | p <- suppressWarnings(stats::loess(y ~ x, span = s, 44 | data.frame(x = x, y = y))) 45 | if (smooth == TRUE) { 46 | y <- stats::predict(p, x) 47 | } else { 48 | na.idx <- which(is.na(y)) 49 | if(length(na.idx) > 1) { 50 | y[na.idx] <- stats::predict(p, data.frame(x = na.idx)) 51 | } 52 | } 53 | } 54 | return(y) 55 | } 56 | -------------------------------------------------------------------------------- /R/insert.values.R: -------------------------------------------------------------------------------- 1 | #' @title Insert Values 2 | #' @description Inserts new values into a vector at 3 | #' specified positions 4 | #' 5 | #' @param x A vector to insert values 6 | #' @param value Values to insert into x 7 | #' @param index Index position(s) to insert y values into x 8 | #' 9 | #' @details 10 | #' This function inserts new values at specified positions in a vector. It 11 | #' does not replace existing values. If a single value is provided for y 12 | #' and l represents multiple positions y will be replicated for the length 13 | #' of l. In this way you can insert the same value at multiple locations. 14 | #' 15 | #' @return 16 | #' A vector with values of y inserted into x and the position(s) 17 | #' defined by the index 18 | #' 19 | #' @author Jeffrey S. Evans 20 | #' 21 | #' @examples 22 | #' (x=1:10) 23 | #' 24 | #' # Insert single value in one location 25 | #' insert.values(x, 100, 2) 26 | #' 27 | #' # Insert multiple values in multiple locations 28 | #' insert.values(x, c(100,200), c(2,8)) 29 | #' 30 | #' # Insert single value in multiple locations 31 | #' insert.values(x, NA, c(2,8)) 32 | #' 33 | #' @export 34 | insert.values <- function(x, value, index) { 35 | if(length(value) == 1) value = rep(value, length(index) ) 36 | if(length(value) < length(index) ) 37 | stop("length of replacement does not match index") 38 | z <- numeric(length(x) + length(index)) 39 | z[index] <- value 40 | z[-index] <- x 41 | return(z) 42 | } 43 | -------------------------------------------------------------------------------- /R/is.empty.R: -------------------------------------------------------------------------------- 1 | #' @title is.empty 2 | #' @description evaluates empty elements in a vector 3 | #' 4 | #' @param x A vector to evaluate elements 5 | #' @param all.na (FALSE / TRUE) Return a TRUE if all elements are NA 6 | #' @param na.empty (TRUE / FALSE) Return TRUE if element is NA 7 | #' @param trim (TRUE / FALSE) Trim empty strings 8 | #' 9 | #' @details 10 | #' This function evaluates if an element in a vector is empty the na.empty argument 11 | #' allows for evaluating NA values (TRUE if NA) and all.na returns a TRUE if all elements 12 | #' are NA. The trim argument trims a character string to account for the fact that c(" ") 13 | #' is not empty but, a vector with c("") is empty. Using trim = TRUE will force both 14 | #' to return TRUE 15 | #' 16 | #' @return A Boolean indicating empty elements in a vector, if all.na = FALSE 17 | #' a TRUE/FALSE value will be returned for each element in the vector 18 | #' 19 | #' @author Jeffrey S. Evans 20 | #' 21 | #' @examples 22 | #' is.empty( c("") ) 23 | #' is.empty( c(" ") ) 24 | #' is.empty( c(" "), trim=FALSE ) 25 | #' 26 | #' is.empty( c("",NA,1) ) 27 | #' is.empty( c("",NA,1), na.empty=FALSE) 28 | #' 29 | #' is.empty( c(NA,NA,NA) ) 30 | #' is.empty( c(NA,NA,NA), all.na=TRUE ) 31 | #' is.empty( c(NA,2,NA), all.na=TRUE ) 32 | #' 33 | #' any( is.empty( c("",2,3) ) ) 34 | #' any( is.empty( c(1,2,3) ) ) 35 | #' 36 | #' @export is.empty 37 | is.empty <- function (x, all.na = FALSE, 38 | na.empty = TRUE, 39 | trim = TRUE) { 40 | if(trim) x <- gsub("^\\s+|\\s+$", "", x) 41 | if (!is.null(x)) { 42 | if(length(x) == 0) { 43 | z <- TRUE 44 | } else { 45 | if (is.character(x)) { 46 | z <- nchar(x) == 0 47 | } 48 | } 49 | } 50 | if(na.empty) z[is.na(z)] <- TRUE 51 | if(all.na){ 52 | if(all(is.na(x))){ 53 | z <- TRUE 54 | } else { 55 | z <- FALSE 56 | } 57 | } 58 | return(unname(z)) 59 | } -------------------------------------------------------------------------------- /R/max_extent.R: -------------------------------------------------------------------------------- 1 | #' @title Maximum extent of multiple rasters 2 | #' @description returns a extent polygon representing maximum extent of 3 | #' input rasters 4 | #' 5 | #' @param x terra SpatRaster class object 6 | #' @param ... additional SpatRaster class objects in same projection 7 | #' 8 | #' @details 9 | #' Creates a maximum extent polygon of all specified rasters 10 | #' 11 | #' @return An sf POLYGON class object representing maximum extents 12 | #' 13 | #' @author Jeffrey S. Evans 14 | #' 15 | #' @examples 16 | #' library(terra) 17 | #' 18 | #' r1 <- rast(ext(61.87125, 76.64458, 23.90153, 37.27042)) 19 | #' r2 <- rast(ext(67.66625, 81.56847, 20.38458, 35.67347)) 20 | #' r3 <- rast(ext(72.64792,84.38125,5.91125,28.13347 )) 21 | #' 22 | #' ( e <- max_extent(r1, r2, r3) ) 23 | #' plot(e, border=NA) 24 | #' plot(ext(r1), border="red", add=TRUE) 25 | #' plot(ext(r2), border="green", add=TRUE) 26 | #' plot(ext(r3), border="blue", add=TRUE) 27 | #' plot(e, border="black", add=TRUE) 28 | #' 29 | #' sf::st_bbox(e) # full extent 30 | #' 31 | #' @export max_extent 32 | max_extent <- function(x, ...) { 33 | if(length(list(...))){ 34 | dots <- list(...) 35 | dots[[length(dots)+1]] <- x 36 | } else { 37 | dots <- list() 38 | dots[[1]] <- x 39 | } 40 | for(i in dots) { 41 | if(!inherits(i, "SpatRaster")) 42 | stop("One of the rasters is not a terra SpatRaster object") 43 | } 44 | e <- lapply(dots, function(i) { 45 | as.vector(terra::ext(i))[c(1,3,2,4)] 46 | }) 47 | if(length(dots) > 1) { 48 | e <- do.call("rbind", lapply(e, function(b) { 49 | sf::st_as_sf(sf::st_as_sfc(sf::st_bbox(c(b[1], 50 | b[2], b[3], b[4])))) 51 | })) 52 | } else { 53 | e <- e[[1]] 54 | e <- sf::st_as_sf(sf::st_as_sfc(sf::st_bbox(c(e[1], 55 | e[2], e[3], e[4])))) 56 | } 57 | return( 58 | sf::st_as_sf(sf::st_as_sfc(sf::st_bbox(e))) 59 | ) 60 | } 61 | -------------------------------------------------------------------------------- /R/nth.values.R: -------------------------------------------------------------------------------- 1 | #' @title Nth values 2 | #' @description Returns the Nth highest or lowest values in a vector 3 | #' 4 | #' @param x Numeric vector 5 | #' @param N Number of (Nth) values returned 6 | #' @param smallest (FALSE/TRUE) Return the highest, else smallest values 7 | #' 8 | #' @details 9 | #' This function returns n lowest or highest elements in a vector 10 | #' 11 | #' @return Numeric vector of Nth values 12 | #' 13 | #' @author Jeffrey S. Evans 14 | #' 15 | #' @examples 16 | #' nth.values(1:20, N=3, smallest = TRUE) 17 | #' nth.values(1:20, N=3) 18 | #' 19 | #' @export nth.values 20 | nth.values <- function(x, N=2, smallest = FALSE) { 21 | if(!is.numeric(x)) 22 | stop("x must be a numeric vector") 23 | if(N >= length(x)) 24 | stop("N cannot be larger than length-1 of the vector") 25 | if(smallest) { 26 | x[order(x)[1:N]] 27 | } else { 28 | sort(x[order(x, decreasing = T)[1:N]]) 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /R/oli.aws.R: -------------------------------------------------------------------------------- 1 | #' @title Query AWS-OLI 2 | #' @description Query of Amazon AWS OLI-Landsat 8 cloud service 3 | #' 4 | #' @param ... not used 5 | #' 6 | #' @details 7 | #' Given the changes to AWS Registry of Open Data, using the data 8 | #' digest is no longer reliable. Plese use the AWS Data Exchange 9 | #' or a STAC API for data acccess 10 | #' 11 | #' @export oli.aws 12 | oli.aws <- function(...) { 13 | .Deprecated("oli.aws", package="spatialEco", 14 | msg="Given the changes to AWS Registry of Open Data, using the data 15 | digest is no longer reliable") 16 | message("Plese use the AWS Data Exchange or a STAC API for data acccess") 17 | } 18 | -------------------------------------------------------------------------------- /R/outliers.R: -------------------------------------------------------------------------------- 1 | #' @title Outliers 2 | #' @description Identify outliers using modified Z-score 3 | #' 4 | #' @param x A numeric vector 5 | #' @param s Scaling factor for mad statistic 6 | #' 7 | #' @return value for the modified Z-score 8 | #' 9 | #' @author Jeffrey S. Evans 10 | #' 11 | #' @references 12 | #' Iglewicz, B. & D.C. Hoaglin (1993) How to Detect and Handle Outliers, 13 | #' American Society for Quality Control, Milwaukee, WI. 14 | #' 15 | #' @examples 16 | #' # Create data with 3 outliers 17 | #' x <- seq(0.1, 5, length=100) 18 | #' x[98:100] <- c(100, 55, 250) 19 | #' 20 | #' # Calculate Z score 21 | #' Z <- outliers(x) 22 | #' 23 | #' # Show number of extreme outliers using Z-score 24 | #' length(Z[Z > 9.9]) 25 | #' 26 | #' # Remove extreme outliers 27 | #' x <- x[-which(Z > 9.9)] 28 | #' 29 | #' @export 30 | outliers <- function(x, s = 1.4826) { 31 | e <- (length(x) - 1) / sqrt(length(x)) 32 | mad <- function (x, center=stats::median(x), constant=s, 33 | low=FALSE, high=FALSE) { 34 | n <- length(x) 35 | constant * if ((low || high) && n%%2 == 0) { 36 | if (low && high) 37 | stop("'low' and 'high' cannot be both TRUE") 38 | n2 <- n%/%2 + as.integer(high) 39 | sort(abs(x - center), partial = n2)[n2] 40 | } 41 | else stats::median(abs(x - center)) 42 | } 43 | return( ( (0.6745 * (x - stats::median(x))) / mad(x) ) ) 44 | } 45 | -------------------------------------------------------------------------------- /R/parea.sample.R: -------------------------------------------------------------------------------- 1 | #' @title Percent area sample 2 | #' @description Creates a point sample of polygons where n is based 3 | #' on percent area 4 | #' 5 | #' @param x An sf POLYGON object 6 | #' @param pct Percent of area sampled 7 | #' @param join {FALSE/TRUE} Join polygon attributed to point sample 8 | #' @param sf Scaling factor (default is meters to acres conversion factor) 9 | #' @param stype Sampling type ('random', 'regular', 'nonaligned', 'hexagonal') 10 | #' @param ... Additional arguments passed to spsample 11 | #' 12 | #' @details 13 | #' This function results in an adaptive sample based on the area of 14 | #' each polygon. The default scaling factor (sf) converts meters to 15 | #' acres. You can set sf=1 to stay in the native projection units 16 | #' 17 | #' @return An sf POINT object 18 | #' 19 | #' @author Jeffrey S. Evans 20 | #' 21 | #' @examples 22 | #' library(sf) 23 | #' nc <- st_read(system.file("shape/nc.shp", package="sf")) 24 | #' nc <- suppressWarnings(st_cast(nc[c(10,100),], "POLYGON")) 25 | #' 26 | #' ( ars <- parea.sample(nc, pct=0.001, join = TRUE, stype='random') ) 27 | #' plot(st_geometry(nc)) 28 | #' plot(st_geometry(ars), pch=19, add=TRUE) 29 | #' 30 | #' @export 31 | parea.sample <- function(x, pct = 0.1, join = FALSE, sf = 4046.86, 32 | stype = "random", ...) { 33 | if (!inherits(x, "sf")) 34 | stop(deparse(substitute(x)), " must be an sf POLYGON object") 35 | if(!unique(as.character(sf::st_geometry_type(x))) %in% c("POLYGON", "MULTIPOLYGON")) 36 | stop(deparse(substitute(x)), " must be an sf POLYGON object") 37 | ns <- unlist(lapply(1:nrow(x), function(i) { 38 | round( (units::drop_units(sf::st_area(x[i,])) / sf) * pct, 0) 39 | })) 40 | s <- sf::st_as_sf(sf::st_sample(x, size=ns, type=stype, 41 | by_polygon=TRUE, ...)) 42 | if(join == TRUE) { 43 | s <- suppressWarnings(sf::st_intersection(s, x)) 44 | } 45 | return(s) 46 | } 47 | -------------------------------------------------------------------------------- /R/plot.effect.size.R: -------------------------------------------------------------------------------- 1 | #' @title Plot effect size 2 | #' @description Plot function for effect.size object 3 | #' 4 | #' @param x A effect.size object 5 | #' @param ... Additional arguments passed to plot 6 | #' 7 | #' @return Plot of effect size object with group effect sizes and 95% confidence 8 | #' 9 | #' @author Jeffrey S. Evans 10 | #' 11 | #' @method plot effect.size 12 | #' @export 13 | plot.effect.size <- function(x, ...) { 14 | dots <- as.list(match.call(expand.dots = TRUE)[-1]) 15 | dots[["x"]] <- as.numeric(as.factor(rownames(x$effect.size))) 16 | dots[["y"]] <- x$effect.size[,1] 17 | dots[["xaxt"]] <- "n" 18 | dots[["ylim"]] <- c(min(x$effect.size), max(x$effect.size)) 19 | if (is.null(dots[["pch"]]) & "pch" %in% names(dots) == FALSE) dots[["pch"]] <- 20 20 | if (is.null(dots[["cex"]]) & "cex" %in% names(dots) == FALSE) dots[["cex"]] <- 1 21 | if (is.null(dots[["xlab"]]) & "xlab" %in% names(dots) == FALSE) dots[["xlab"]] <- "class" 22 | if (is.null(dots[["ylab"]]) & "ylab" %in% names(dots) == FALSE) dots[["ylab"]] <- "effect size" 23 | if (is.null(dots[["main"]]) & "main" %in% names(dots) == FALSE) dots[["main"]] <- paste("Effect size with", x$CI, "CI",sep=" ") 24 | do.call("plot", dots) 25 | graphics::axis(side=1, at = as.numeric(as.factor(rownames(x$effect.size))), 26 | labels = rownames(x$effect.size)) 27 | for(i in 1:nrow(x$effect.size)) { 28 | graphics::arrows(i, x$effect.size[,2][i], i, 29 | x$effect.size[,3][i], 30 | length = 0.05, angle = 90, 31 | code = 3) 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /R/plot.loess.boot.R: -------------------------------------------------------------------------------- 1 | #' @title Plot Loess Bootstrap 2 | #' @description Plot function for loess.boot object 3 | #' 4 | #' @param x A loess.boot object 5 | #' @param ... Additional arguments passed to plot 6 | #' 7 | #' @return plot of lowess bootstrap 8 | #' 9 | #' @author Jeffrey S. Evans 10 | #' 11 | #' @examples 12 | #' n=1000 13 | #' x <- seq(0, 4, length.out=n) 14 | #' y <- sin(2*x)+ 0.5*x + rnorm(n, sd=0.5) 15 | #' sb <- loess.boot(x, y, nreps = 99, confidence = 0.90, span = 0.40) 16 | #' plot(sb) 17 | #' 18 | #' @method plot loess.boot 19 | #' @export 20 | plot.loess.boot <- function(x, ...) { 21 | oops <- options() 22 | on.exit(options(oops)) 23 | dots <- as.list(match.call(expand.dots = TRUE)[-1]) 24 | dots[["x"]] <- x$data$x 25 | dots[["y"]] <- x$data$y 26 | if (is.null(dots[["pch"]]) & "pch" %in% names(dots) == FALSE) dots[["pch"]] <- 20 27 | if (is.null(dots[["cex"]]) & "cex" %in% names(dots) == FALSE) dots[["cex"]] <- 0.55 28 | if (is.null(dots[["xlab"]]) & "xlab" %in% names(dots) == FALSE) dots[["xlab"]] <- "x" 29 | if (is.null(dots[["ylab"]]) & "ylab" %in% names(dots) == FALSE) dots[["ylab"]] <- "loess fit" 30 | if (is.null(dots[["main"]]) & "main" %in% names(dots) == FALSE) dots[["main"]] <- paste0("Loess bootstrap n = ", x$nreps) 31 | if (is.null(dots[["sub"]]) & "sub" %in% names(dots) == FALSE) dots[["sub"]] <- paste0("Confidence region - ", x$confidence) 32 | do.call("plot", dots) 33 | graphics::polygon(c(x$fit$x, rev(x$fit$x)), c(x$fit$up.lim, rev(x$fit$low.lim)), 34 | col=grDevices::rgb(0.75, 0.75, 0.75, 0.5)) 35 | graphics::lines(stats::spline(x$fit$x, x$fit$y.fit), lwd=0.75, lty=2) 36 | } 37 | -------------------------------------------------------------------------------- /R/polyPerimeter.R: -------------------------------------------------------------------------------- 1 | #' @title Polygon perimeter 2 | #' @description Calculates the perimeter length(s) for a polygon object 3 | #' 4 | #' @param x sf POLYGON class object 5 | #' 6 | #' @return A vector of polygon perimeters in projection units 7 | #' 8 | #' @author Jeffrey S. Evans 9 | #' 10 | #' @examples 11 | #' library(sf) 12 | #' polys <- st_read(system.file("shape/nc.shp", package="sf")) 13 | #' polys <- suppressWarnings(st_cast(polys[c(10,100),], "POLYGON")) 14 | #' 15 | #' polyPerimeter(polys) 16 | #' 17 | #' @export 18 | polyPerimeter <- function(x) { 19 | if (!inherits(x, "sf")) 20 | stop(deparse(substitute(x)), " must be an sf POLYGON object") 21 | if(!unique(as.character(sf::st_geometry_type(x))) %in% c("POLYGON", "MULTIPOLYGON")) 22 | stop(deparse(substitute(x)), " must be an sf POLYGON object") 23 | if(unique(as.character(sf::st_geometry_type(x))) %in% "MULTIPOLYGON") 24 | stop("Function does not support multi-part MLTIPOLYGON objects") 25 | p <- suppressWarnings(sf::st_length(sf::st_cast(x, "LINESTRING"))) 26 | return( units::drop_units(p) ) 27 | } 28 | -------------------------------------------------------------------------------- /R/print.effect.size.R: -------------------------------------------------------------------------------- 1 | #' @title Print effect size 2 | #' @description print method for class "effect.size" 3 | #' 4 | #' @param x Object of class effect.size 5 | #' @param ... Ignored 6 | #' 7 | #' @return 8 | #' Prints the output data.frame contaning; effect size with upper and lower confidence 9 | #' and, mean and sd by group 10 | #' 11 | #' @method print effect.size 12 | #' @export 13 | print.effect.size <- function(x, ...) { 14 | for(i in 1:nrow(x$effect.size)) { 15 | print(paste( paste0("Effect size for: ", rownames(x$effect.size)[i]), 16 | round(x$effect.size[,1][i],4), sep=" = ") ) 17 | cat(paste0(paste(rep(" ", 4), collapse = ""), 18 | paste0( "Lower CI: ", round(x$effect.size[,2][i],4)))) 19 | cat(paste0(paste(rep(" ", 4), collapse = ""), 20 | paste0( "Upper CI: ", round(x$effect.size[,3][i],3)))) 21 | cat("", "\n") 22 | cat("", "\n") 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /R/print.loess.boot.R: -------------------------------------------------------------------------------- 1 | #' @title Print Loess bootstrap model 2 | #' @description print method for class "loess.boot" 3 | #' 4 | #' @param x Object of class loess.boot 5 | #' @param ... Ignored 6 | #' 7 | #' @return same as summary lowess.boot of data.frame including; 8 | #' * nreps Number of bootstrap replicates 9 | #' * confidence Confidence interval (region) 10 | #' * span alpha (span) parameter used loess fit 11 | #' * degree polynomial degree used in loess fit 12 | #' * normalize Normalized data (TRUE/FALSE) 13 | #' * family Family of statistic used in fit 14 | #' * parametric Parametric approximation (TRUE/FALSE) 15 | #' * surface Surface fit, see loess.control 16 | #' * data data.frame of x,y used in model 17 | #' * fit data.frame including: 18 | #' 1) x - Equally-spaced x index 19 | #' 2) y.fit - loess fit 20 | #' 3) up.lim - Upper confidence interval 21 | #' 4) low.lim - Lower confidence interval 22 | #' 5) stddev - Standard deviation of loess fit at each x value 23 | #' @md 24 | #' 25 | #' @method print loess.boot 26 | #' @export 27 | print.loess.boot <- function(x, ...) { 28 | cat("Number of permutations: ", x$nreps, "\n", sep="") 29 | cat("Loess alpha (span) parameter: ", x$span, "\n", sep="") 30 | cat("Polynomial degree: ", x$degree, "\n", sep="") 31 | cat("Data normalized: ", x$normalize, "\n", sep="") 32 | cat("Model distribution: ", x$family, "\n", sep="") 33 | cat("parametric model: ", x$parametric, "\n", sep="") 34 | } 35 | -------------------------------------------------------------------------------- /R/print.poly.trend.R: -------------------------------------------------------------------------------- 1 | #' @title Print poly_trend 2 | #' @description print method for class "poly.trend" 3 | #' 4 | #' @param x Object of class poly.trend 5 | #' @param ... Ignored 6 | #' 7 | #' @return Prints trend model summary, order and trend confidence intervals 8 | #' 9 | #' @method print poly.trend 10 | #' @export 11 | print.poly.trend <- function(x, ...) { 12 | cat("Polynomial trend model fit using a", x$order, 13 | "order polynomial", "\n") 14 | print(summary(x$model)) 15 | cat("", "\n") 16 | cat("Summary of trend confidence intervals", "\n") 17 | print(summary(x$trend[,2:3])) 18 | } -------------------------------------------------------------------------------- /R/raster.Zscore.R: -------------------------------------------------------------------------------- 1 | #' @title Modified z-score for a raster 2 | #' @description 3 | #' Calculates the modified z-score for raster values 4 | #' 5 | #' @param x A raster class object 6 | #' @param p.value Return p-value rather than z-score 7 | #' raster (FALSE/TRUE) 8 | #' @param file.name Name of raster written to disk 9 | #' @param ... Additional arguments passed to writeRaster 10 | #' 11 | #' @note 12 | #' Since this functions needs to operate on all of the raster values, 13 | #' it is not memory safe 14 | #' 15 | #' @return raster class object or raster written to disk 16 | #' 17 | #' @author Jeffrey S. Evans 18 | #' 19 | #' @examples 20 | #' \donttest{ 21 | #' library(terra) 22 | #' r <- rast(nrows=500, ncols=500) 23 | #' r[] <- runif(ncell(r), 0, 1) 24 | #' 25 | #' # Modified z-score 26 | #' ( z <- raster.Zscore(r) ) 27 | #' 28 | #' # P-value 29 | #' ( p <- raster.Zscore(r, p.value = TRUE) ) 30 | #' } 31 | #' 32 | #' @export raster.Zscore 33 | raster.Zscore <- function(x, p.value = FALSE, file.name = NULL, ...) { 34 | if (!inherits(x, "SpatRaster")) 35 | stop(deparse(substitute(x)), " must be a terra SpatRaster object") 36 | r.vals <- x[][,1] 37 | na.idx <- which(!is.na(r.vals)) 38 | if( p.value == TRUE ) { 39 | x[na.idx] <- stats::pnorm( outliers( stats::na.omit(r.vals) ) ) 40 | } else { 41 | x[na.idx] <- outliers( stats::na.omit(r.vals) ) 42 | } 43 | if(!is.null(file.name)) { 44 | terra::writeRaster(x, ...) 45 | } else { 46 | return( x ) 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /R/raster.invert.R: -------------------------------------------------------------------------------- 1 | #' @title Invert raster 2 | #' @description Inverts (flip) the values of a raster 3 | #' 4 | #' @param x A terra SpatRaster object 5 | #' 6 | #' @details 7 | #' Inverts raster values using the formula: (((x - max(x)) * -1) + min(x) 8 | #' 9 | #' @return 10 | #' A terra SpatRaster object with inverted (flipped) raster values 11 | #' 12 | #' @author Jeffrey S. Evans 13 | #' 14 | #' @examples 15 | #' library(terra) 16 | #' r <- rast(nrows=500, ncols=500, xmin=571823, xmax=616763, 17 | #' ymin=4423540, ymax=4453690) 18 | #' crs(r) <- "epsg:9001" 19 | #' r[] <- runif(ncell(r), 1000, 2500) 20 | #' r <- focal(r, focalMat(r, 150, "Gauss") ) 21 | #' 22 | #' r.inv <- raster.invert(r) 23 | #' 24 | #' opar <- par(no.readonly=TRUE) 25 | #' par(mfrow=c(1,2)) 26 | #' plot(r, main="original raster") 27 | #' plot(r.inv, main="inverted raster") 28 | #' par(opar) 29 | #' 30 | #' @export raster.invert 31 | raster.invert <- function(x) { 32 | if (!inherits(x, "SpatRaster")) 33 | stop(deparse(substitute(x)), " must be a terra SpatRaster object") 34 | rmax <- terra::global(x, "max", na.rm = TRUE)[,1] 35 | rmin <- terra::global(x, "min", na.rm = TRUE)[,1] 36 | return( ((x - rmax) * -1) + rmin ) 37 | } 38 | -------------------------------------------------------------------------------- /R/raster.moments.R: -------------------------------------------------------------------------------- 1 | #' @title Raster moments 2 | #' @description Calculates focal statistical moments of a raster 3 | #' 4 | #' @param x A terra SpatRaster object 5 | #' @param type The global statistic to represent the local deviation 6 | #' options are: "min", "min", "mean", "median", "var, "sd", 7 | #' "mad", "kurt", "skew", "quantile" 8 | #' @param s Size of matrix (focal window), can be single value or two 9 | #' values defining the [x,y] dimensions of the focal matrix 10 | #' @param p if type="quantile", the returned percentile. 11 | #' @param ... Additional arguments passed to terra::focal 12 | #' 13 | #' @details 14 | #' This is a simple wrapper for the terra focal function, returning local statistical moments 15 | #' 16 | #' @return A terra SpatRaster object representing the local distributional moment 17 | #' 18 | #' @author Jeffrey S. Evans 19 | #' 20 | #' @examples 21 | #' \donttest{ 22 | #' library(terra) 23 | #' r <- rast(nrows=500, ncols=500, xmin=571823, xmax=616763, 24 | #' ymin=4423540, ymax=4453690) 25 | #' crs(r) <- "epsg:9001" 26 | #' r[] <- runif(ncell(r), 1000, 2500) 27 | #' 28 | #' # Calculate 10th percentile for 3x3 window 29 | #' r.p10 <- raster.moments(r, type="quantile", p=0.10) 30 | #' } 31 | #' 32 | #' @export raster.moments 33 | raster.moments <- function(x, type = "mean", s = 3, p = 0.75, ...) { 34 | if (!inherits(x, "SpatRaster")) 35 | stop(deparse(substitute(x)), " must be a terra SpatRaster object") 36 | if( length(s) == 1) s = c(s[1],s[1]) 37 | m <- matrix(1, nrow=s, ncol=s) 38 | if(type == "quantile") { 39 | pct <- function(x, q = p) { stats::quantile(x, probs=q, na.rm=TRUE) } 40 | return( terra::focal(x, w = m, fun = pct, ...) ) 41 | } else { 42 | return( terra::focal(x, w = m, fun = match.fun(type), na.rm = TRUE, ...) ) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /R/rm.ext.R: -------------------------------------------------------------------------------- 1 | #' @title Remove extension 2 | #' @description Removes file extension (and path) from string 3 | #' 4 | #' @param x A character vector representing a file with extension 5 | #' 6 | #' @return 7 | #' The file name with extension and file path stripped off 8 | #' 9 | #' @examples 10 | #' rm.ext("C:/path/file.txt") 11 | #' 12 | #' @export rm.ext 13 | rm.ext <- function(x) { 14 | sub("([^.]+)\\.[[:alnum:]]+$", "\\1", basename(x)) 15 | } 16 | -------------------------------------------------------------------------------- /R/sar.R: -------------------------------------------------------------------------------- 1 | #' @title Surface Area Ratio 2 | #' @description Calculates the Berry (2002) Surface Area Ratio based on slope 3 | #' 4 | #' @param x A terra SpatRaster object 5 | #' @param s cell resolution (default is NULL and not needed if projection 6 | #' is in planar units) 7 | #' @param scale (TRUE/FALSE) Scale (row standardize) results 8 | #' 9 | #' @details 10 | #' SAR is calculated as: resolution^2 * cos( (degrees(slope) * (pi / 180)) ) 11 | #' 12 | #' @return A terra SpatRaster class object of the Surface Area Ratio 13 | #' 14 | #' @author Jeffrey S. Evans 15 | #' 16 | #' @references 17 | #' Berry, J.K. (2002). Use surface area for realistic calculations. Geoworld 15(9):20-1. 18 | #' 19 | #' @examples 20 | #' library(terra) 21 | #' elev <- rast(system.file("extdata/elev.tif", package="spatialEco")) 22 | #' ( surface.ratio <- sar(elev) ) 23 | #' plot(surface.ratio) 24 | #' 25 | #' @export 26 | sar <- function(x, s = NULL, scale = TRUE) { 27 | if (!inherits(x, "SpatRaster")) 28 | stop(deparse(substitute(x)), " must be a terra SpatRaster object") 29 | if (length(grep("longlat", terra::crs(x))) > 0 && is.null(s)) 30 | stop("Projection is geographic, must define cell size argument in planar units") 31 | if( is.null(s) ) { 32 | s = terra::res(x)[1] ^2 33 | } else { 34 | if(!is.numeric(s)) 35 | stop("s must be numeric") 36 | } 37 | saf <- function(x, cs = s) { cs * cos(x) } 38 | slp <- terra::terrain(x, v='slope', unit='degrees') * (pi / 180) 39 | s <- terra::app(slp, fun=saf) 40 | if(!scale) { 41 | return( s ) 42 | } else { 43 | return( s / terra::global(s, "max", na.rm=TRUE)[,1] ) 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /R/shift.R: -------------------------------------------------------------------------------- 1 | #' @title shift 2 | #' @description Shift a vector by specified positive or negative lag 3 | #' 4 | #' @param x A vector 5 | #' @param lag Number of lagged offsets, default is 1 6 | #' @param pad Value to fill the lagged offset with, default is NA 7 | #' 8 | #' @return 9 | #' A vector, length equal to x, with offset length filled with pad values 10 | #' 11 | #' @author Jeffrey S. Evans 12 | #' 13 | #' @examples 14 | #' x <- 1:10 15 | #' 16 | #' shift(x, 1) # shift positive (from beginning of vector) by 1 17 | #' shift(x, -1) # shift negative (from end of vector) by 1 18 | #' shift(x, 5, 0) # Shift by 5 and fill (pad) with 0 19 | #' 20 | #' @export shift 21 | shift <- function(x, lag=1, pad = NA) { 22 | if(!is.na(pad)) 23 | message(paste0("Padding shifted values with - ", pad)) 24 | n <- length(x) 25 | y <- rep(pad, length(x)) 26 | if (lag < 0) { 27 | message(paste0("Shifting ", abs(lag), " positions from end of vector")) 28 | y[1:(n-abs(lag))] <- x[(abs(lag)+1):n] 29 | } else if (lag > 0) { 30 | message(paste0("Shifting ", lag, " positions from beginning of vector")) 31 | y[(lag+1):length(x)] <- x[1:(length(x)-lag)] 32 | } 33 | return(y) 34 | } 35 | -------------------------------------------------------------------------------- /R/sieve.R: -------------------------------------------------------------------------------- 1 | #' @title Sieve raster data 2 | #' @description Removes contiguous cells < specified query area 3 | #' 4 | #' @param x An integer terra SpatRaster 5 | #' @param a Query area to remove 6 | #' @param unit The unit to use for area query options are c("m", "km", "ha") 7 | #' 8 | #' @details 9 | #' A sieve can be used to establish a minimal mapping unit where 10 | #' contiguous cells < specified query area are set to NA. These NA 11 | #' values can then be filled using focal (majority, median, mean) 12 | #' 13 | #' @return 14 | #' A terra SpatRaster with cells < a set to NA 15 | #' 16 | #' @author Jeffrey S. Evans 17 | #' 18 | #' @examples 19 | #' \donttest{ 20 | #' library(terra) 21 | #' elev <- rast(system.file("extdata/elev.tif", package="spatialEco")) 22 | #' m <- matrix(c(100,200,1,200,300,2,300,400,3,400, 23 | #' 500,4, 500,600,5), ncol=3, byrow=TRUE) 24 | #' x <- classify(elev, m) 25 | #' 26 | #' # Sieve to a MMU of 60km 27 | #' sv <- spatialEco::sieve(x, a = 60, unit = "km") 28 | #' plot(c(x, sv)) 29 | #' } 30 | #' @export 31 | sieve <- function(x, a, unit = c("m", "km", "ha")) { 32 | if(missing(a)) 33 | stop("Must define query area (a)") 34 | if (!inherits(x, "SpatRaster")) 35 | stop(deparse(substitute(x)), " must be a terra SpatRaster object") 36 | message("Sieve applied for a MMU < ", a, unit) 37 | rs <- terra::zonal(terra::cellSize(x, unit = unit[1]), 38 | x, sum, as.raster = TRUE) 39 | rs <- terra::ifel(rs < a, NA, x) 40 | return( rs ) 41 | } 42 | -------------------------------------------------------------------------------- /R/spatialEcoNews.R: -------------------------------------------------------------------------------- 1 | #' @title spatialEco news 2 | #' @description Displays release notes 3 | #' @param ... not used 4 | #' @return Shows package NEWS file 5 | #' @export 6 | spatialEcoNews <- function(...) { 7 | newsfile <- file.path(system.file(package="spatialEco"), "NEWS") 8 | file.show(newsfile) 9 | } 10 | -------------------------------------------------------------------------------- /R/squareBuffer.R: -------------------------------------------------------------------------------- 1 | #' @title Square buffer 2 | #' @description Creates a square buffer of a feature class 3 | #' 4 | #' @param x An sf object 5 | #' @param a Numeric single or vector indicating buffer distance(s) 6 | #' @param ... Additional arguments passed to st_buffer 7 | #' 8 | #' @details Function creates a square buffer of feature class. 9 | #' 10 | #' @return A single feature sf class polygon object 11 | #' 12 | #' @author Jeffrey S. Evans 13 | #' 14 | #' @examples 15 | #' library(sf) 16 | #' xy <- st_as_sf(data.frame(x = c(1,3,6,7), 17 | #' y = c(3,2,7,8), z = c(38,23,12,12), 18 | #' area = c(32,23,45,67)), 19 | #' coords = c("x", "y"), 20 | #' agr = "constant") 21 | #' 22 | #' # With fixed buffer 23 | #' sb <- squareBuffer(xy, 32) 24 | #' plot(st_geometry(sb)) 25 | #' plot(st_geometry(xy), pch=20, add=TRUE) 26 | #' 27 | #' # With variable buffer 28 | #' sb.var <- squareBuffer(xy, xy$area) 29 | #' plot(st_geometry(sb.var)) 30 | #' plot(st_geometry(xy), pch=20, add=TRUE) 31 | #' 32 | #' @export 33 | squareBuffer <- function(x, a, ...) { 34 | if(!inherits(x, c("sf", "sfc"))) 35 | stop(deparse(substitute(x)), " must be an sf class object") 36 | if(missing(a)) 37 | stop("buffer distance argument is missing") 38 | a <- sqrt(a)/2 39 | dots <- as.list(match.call(expand.dots = TRUE)[-1]) 40 | if(any(names(dots) == "a")) 41 | dots <- dots[-which(names(dots) %in% "a")] 42 | dots$x <- x 43 | dots$dist <- a 44 | dots$nQuadSegs <- 1 45 | dots$endCapStyle <- "SQUARE" 46 | return(do.call(sf::st_buffer, dots)) 47 | } 48 | -------------------------------------------------------------------------------- /R/srr.R: -------------------------------------------------------------------------------- 1 | #' @title Surface Relief Ratio 2 | #' @description Calculates the Pike (1971) Surface Relief Ratio 3 | #' 4 | #' @param x A terra SpatRaster object 5 | #' @param s Focal window size 6 | #' @param ... Additional arguments passed to terra::lapp 7 | #' 8 | #' @details 9 | #' Describes rugosity in continuous raster surface within a specified window. 10 | #' The implementation of SRR can be shown as: (mean(x) - min(x)) / (max(x) - min(x)) 11 | #' 12 | #' @return A terra SpatRaster object of Pike's (1971) Surface Relief Ratio 13 | #' 14 | #' @author Jeffrey S. Evans 15 | #' 16 | #' @examples 17 | #' \donttest{ 18 | #' library(terra) 19 | #' elev <- rast(system.file("extdata/elev.tif", package="spatialEco")) 20 | #' r.srr <- srr(elev, s=5) 21 | #' plot(r.srr, main="Surface Relief Ratio") 22 | #' } 23 | #' @export srr 24 | srr <- function(x, s = 5, ...) { 25 | if (!inherits(x, "SpatRaster")) 26 | stop(deparse(substitute(x)), " must be a terra SpatRaster object") 27 | m <- matrix(1, nrow=s, ncol=s) 28 | rmin <- terra::focal(x, w=m, fun=min) 29 | rmax <- terra::focal(x, w=m, fun=max) 30 | rmean <- terra::focal(x, w=m, fun=mean) 31 | return( terra::lapp(c(rmean,rmin,rmax), 32 | fun=function(x,y,z) { (x - y ) / ( z - y ) }, ... ) ) 33 | } 34 | -------------------------------------------------------------------------------- /R/summary.effect.size.R: -------------------------------------------------------------------------------- 1 | #' @title Summarizing effect size 2 | #' @description Summary method for class "effect.size". 3 | #' 4 | #' @param object Object of class effect.size 5 | #' @param ... Ignored 6 | #' 7 | #' @return Prints the output data.frame contaning; effect size with upper and lower confidence 8 | #' and, mean and sd by group 9 | #' 10 | #' @method summary effect.size 11 | #' @export 12 | summary.effect.size <- function(object, ...) { 13 | cat("Mean by groups in y: ", "\n") 14 | print( tapply(object$x, object$y, mean) ) 15 | cat("", "\n") 16 | cat("Standard deviation by groups in y: ", "\n") 17 | print( tapply(object$x, object$y, stats::sd) ) 18 | cat("", "\n") 19 | for(i in 1:nrow(object$effect.size)) { 20 | print(paste( paste0("Effect size for: ", rownames(object$effect.size)[i]), 21 | round(object$effect.size[,1][i],4), sep=" = ") ) 22 | cat(paste0(paste(rep(" ", 4), collapse = ""), 23 | paste0( "Lower CI: ", round(object$effect.size[,2][i],4)))) 24 | cat(paste0(paste(rep(" ", 4), collapse = ""), 25 | paste0( "Upper CI: ", round(object$effect.size[,3][i],3)))) 26 | cat("", "\n") 27 | cat("", "\n") 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /R/summary.loess.boot.R: -------------------------------------------------------------------------------- 1 | #' @title Summarizing Loess bootstrap models 2 | #' @description Summary method for class "loess.boot". 3 | #' 4 | #' @param object Object of class loess.boot 5 | #' @param ... Ignored 6 | #' 7 | #' 8 | #' @return same as print lowess.boot data.frame including; 9 | #' * nreps Number of bootstrap replicates 10 | #' * confidence Confidence interval (region) 11 | #' * span alpha (span) parameter used loess fit 12 | #' * degree polynomial degree used in loess fit 13 | #' * normalize Normalized data (TRUE/FALSE) 14 | #' * family Family of statistic used in fit 15 | #' * parametric Parametric approximation (TRUE/FALSE) 16 | #' * surface Surface fit, see loess.control 17 | #' * data data.frame of x,y used in model 18 | #' * fit data.frame including: 19 | #' 1) x - Equally-spaced x index (see NOTES) 20 | #' 2) y.fit - loess fit 21 | #' 3) up.lim - Upper confidence interval 22 | #' 4) low.lim - Lower confidence interval 23 | #' 5) stddev - Standard deviation of loess fit at each x value 24 | #' @md 25 | #' 26 | #' @method summary loess.boot 27 | #' @export 28 | summary.loess.boot <- function(object, ...) { 29 | cat("Number of permutations: ", object$nreps, "\n", sep="") 30 | cat("Loess alpha (span) parameter: ", object$span, "\n", sep="") 31 | cat("Polynomial degree: ", object$degree, "\n", sep="") 32 | cat("Data normalized: ", object$normalize, "\n", sep="") 33 | cat("Model distribution: ", object$family, "\n", sep="") 34 | cat("parametric model: ", object$parametric, "\n", sep="") 35 | cat("","\n", sep="") 36 | cat("summary of fit: ","\n", sep="") 37 | summary(object$fit[,"y.fit"]) 38 | cat("","\n", sep="") 39 | cat("summary of lower confidence limits: ","\n", sep="") 40 | summary(object$fit[,"low.lim"]) 41 | cat("","\n", sep="") 42 | cat("summary of fit: ","\n", sep="") 43 | summary(object$fit[,"up.lim"]) 44 | } 45 | -------------------------------------------------------------------------------- /R/trasp.R: -------------------------------------------------------------------------------- 1 | #' @title Solar-radiation Aspect Index 2 | #' @description 3 | #' Calculates the Roberts and Cooper (1989) Solar-radiation Aspect Index 4 | #' 5 | #' @param x A terra SpatRaster object 6 | #' @param ... Additional arguments passed to terra::app 7 | #' 8 | #' @details 9 | #' Roberts and Cooper (1989) rotates (transforms) the circular aspect to assign a 10 | #' value of zero to land oriented in a north-northeast direction, (typically the 11 | #' coolest and wettest orientation), and a value of one on the hotter, dryer 12 | #' south-southwesterly slopes. The result is a continuous variable between 0 - 1. 13 | #' The metric is defined as: trasp = ( 1 - cos((pi/180)(a-30) ) / 2 14 | #' where; a = aspect in degrees 15 | #' 16 | #' @return 17 | #' A terra SpatRaster object of Roberts and Cooper (1989) Solar-radiation Aspect Index 18 | #' 19 | #' @author Jeffrey S. Evans 20 | #' 21 | #' @references 22 | #' Roberts. D.W., and Cooper, S.V. (1989). Concepts and techniques of vegetation mapping. 23 | #' In Land Classifications Based on Vegetation: Applications for Resource Management. 24 | #' USDA Forest Service GTR INT-257, Ogden, UT, pp 90-96 25 | #' 26 | #' @examples 27 | #' library(terra) 28 | #' elev <- rast(system.file("extdata/elev.tif", package="spatialEco")) 29 | #' s <- trasp(elev) 30 | #' plot(s) 31 | #' 32 | #' @export trasp 33 | trasp <- function(x, ...) { 34 | if (!inherits(x, "SpatRaster")) 35 | stop(deparse(substitute(x)), " must be a terra SpatRaster object") 36 | asp <- terra::terrain(x, v='aspect', unit='degrees') 37 | return( terra::app(asp, fun=function(x) { (1 - cos( (3.142/180) *(x - 30)) ) / 2 }, ... ) ) 38 | } 39 | -------------------------------------------------------------------------------- /_pkgdown.yml: -------------------------------------------------------------------------------- 1 | url: ~ 2 | template: 3 | bootstrap: 5 4 | 5 | -------------------------------------------------------------------------------- /data/ants.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/data/ants.rda -------------------------------------------------------------------------------- /data/chen.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/data/chen.rda -------------------------------------------------------------------------------- /data/cor.data.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/data/cor.data.rda -------------------------------------------------------------------------------- /data/pu.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/data/pu.rda -------------------------------------------------------------------------------- /docs/_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-cayman -------------------------------------------------------------------------------- /docs/link.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 12 | 13 | -------------------------------------------------------------------------------- /docs/pkgdown.yml: -------------------------------------------------------------------------------- 1 | pandoc: 1.19.2.1 2 | pkgdown: 1.6.1 3 | pkgdown_sha: ~ 4 | articles: {} 5 | last_built: 2021-05-28T22:02Z 6 | 7 | -------------------------------------------------------------------------------- /docs/reference/Rplot001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/Rplot001.png -------------------------------------------------------------------------------- /docs/reference/Rplot002.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/Rplot002.png -------------------------------------------------------------------------------- /docs/reference/Rplot003.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/Rplot003.png -------------------------------------------------------------------------------- /docs/reference/Rplot004.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/Rplot004.png -------------------------------------------------------------------------------- /docs/reference/background-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/background-1.png -------------------------------------------------------------------------------- /docs/reference/background-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/background-2.png -------------------------------------------------------------------------------- /docs/reference/background-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/background-3.png -------------------------------------------------------------------------------- /docs/reference/background-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/background-4.png -------------------------------------------------------------------------------- /docs/reference/breeding.density-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/breeding.density-1.png -------------------------------------------------------------------------------- /docs/reference/chae-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/chae-1.png -------------------------------------------------------------------------------- /docs/reference/class.comparison-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/class.comparison-1.png -------------------------------------------------------------------------------- /docs/reference/class.comparison-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/class.comparison-2.png -------------------------------------------------------------------------------- /docs/reference/class.comparison-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/class.comparison-3.png -------------------------------------------------------------------------------- /docs/reference/classBreaks-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/classBreaks-1.png -------------------------------------------------------------------------------- /docs/reference/collinear-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/collinear-1.png -------------------------------------------------------------------------------- /docs/reference/collinear-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/collinear-2.png -------------------------------------------------------------------------------- /docs/reference/conf.interval-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/conf.interval-1.png -------------------------------------------------------------------------------- /docs/reference/correlogram-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/correlogram-1.png -------------------------------------------------------------------------------- /docs/reference/crossCorrelation-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/crossCorrelation-1.png -------------------------------------------------------------------------------- /docs/reference/curvature-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/curvature-1.png -------------------------------------------------------------------------------- /docs/reference/dahi-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/dahi-1.png -------------------------------------------------------------------------------- /docs/reference/dispersion-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/dispersion-1.png -------------------------------------------------------------------------------- /docs/reference/dissection-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/dissection-1.png -------------------------------------------------------------------------------- /docs/reference/effect.size-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/effect.size-1.png -------------------------------------------------------------------------------- /docs/reference/erase.point-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/erase.point-1.png -------------------------------------------------------------------------------- /docs/reference/extract.vertices-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/extract.vertices-1.png -------------------------------------------------------------------------------- /docs/reference/extract.vertices-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/extract.vertices-2.png -------------------------------------------------------------------------------- /docs/reference/gaussian.kernel-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/gaussian.kernel-1.png -------------------------------------------------------------------------------- /docs/reference/geo.buffer-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/geo.buffer-1.png -------------------------------------------------------------------------------- /docs/reference/group.pdf-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/group.pdf-1.png -------------------------------------------------------------------------------- /docs/reference/hexagons-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/hexagons-1.png -------------------------------------------------------------------------------- /docs/reference/hli-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/hli-1.png -------------------------------------------------------------------------------- /docs/reference/hsp-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/hsp-1.png -------------------------------------------------------------------------------- /docs/reference/hybrid.kmeans-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/hybrid.kmeans-1.png -------------------------------------------------------------------------------- /docs/reference/idw.smoothing-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/idw.smoothing-1.png -------------------------------------------------------------------------------- /docs/reference/impute.loess-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/impute.loess-1.png -------------------------------------------------------------------------------- /docs/reference/kl.divergence-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/kl.divergence-1.png -------------------------------------------------------------------------------- /docs/reference/knn-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/knn-1.png -------------------------------------------------------------------------------- /docs/reference/local.min.max-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/local.min.max-1.png -------------------------------------------------------------------------------- /docs/reference/local.min.max-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/local.min.max-2.png -------------------------------------------------------------------------------- /docs/reference/loess.boot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/loess.boot-1.png -------------------------------------------------------------------------------- /docs/reference/loess.ci-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/loess.ci-1.png -------------------------------------------------------------------------------- /docs/reference/max_extent-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/max_extent-1.png -------------------------------------------------------------------------------- /docs/reference/moments-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/moments-1.png -------------------------------------------------------------------------------- /docs/reference/morans.plot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/morans.plot-1.png -------------------------------------------------------------------------------- /docs/reference/morans.plot-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/morans.plot-2.png -------------------------------------------------------------------------------- /docs/reference/o.ring-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/o.ring-1.png -------------------------------------------------------------------------------- /docs/reference/optimal.k-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/optimal.k-1.png -------------------------------------------------------------------------------- /docs/reference/optimal.k-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/optimal.k-2.png -------------------------------------------------------------------------------- /docs/reference/optimal.k-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/optimal.k-3.png -------------------------------------------------------------------------------- /docs/reference/optimized.sample.variance-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/optimized.sample.variance-1.png -------------------------------------------------------------------------------- /docs/reference/optimized.sample.variance-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/optimized.sample.variance-2.png -------------------------------------------------------------------------------- /docs/reference/parea.sample-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/parea.sample-1.png -------------------------------------------------------------------------------- /docs/reference/plot.loess.boot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/plot.loess.boot-1.png -------------------------------------------------------------------------------- /docs/reference/point.in.poly-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/point.in.poly-1.png -------------------------------------------------------------------------------- /docs/reference/poly.regression-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/poly.regression-1.png -------------------------------------------------------------------------------- /docs/reference/poly.regression-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/poly.regression-2.png -------------------------------------------------------------------------------- /docs/reference/polygon_extract-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/polygon_extract-1.png -------------------------------------------------------------------------------- /docs/reference/polygon_extract-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/polygon_extract-2.png -------------------------------------------------------------------------------- /docs/reference/pp.subsample-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/pp.subsample-1.png -------------------------------------------------------------------------------- /docs/reference/proximity.index-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/proximity.index-1.png -------------------------------------------------------------------------------- /docs/reference/proximity.index-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/proximity.index-2.png -------------------------------------------------------------------------------- /docs/reference/proximity.index-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/proximity.index-3.png -------------------------------------------------------------------------------- /docs/reference/pseudo.absence-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/pseudo.absence-1.png -------------------------------------------------------------------------------- /docs/reference/pseudo.absence-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/pseudo.absence-2.png -------------------------------------------------------------------------------- /docs/reference/raster.change-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/raster.change-1.png -------------------------------------------------------------------------------- /docs/reference/raster.deviation-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/raster.deviation-1.png -------------------------------------------------------------------------------- /docs/reference/raster.entropy-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/raster.entropy-1.png -------------------------------------------------------------------------------- /docs/reference/raster.gaussian.smooth-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/raster.gaussian.smooth-1.png -------------------------------------------------------------------------------- /docs/reference/raster.invert-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/raster.invert-1.png -------------------------------------------------------------------------------- /docs/reference/raster.mds-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/raster.mds-1.png -------------------------------------------------------------------------------- /docs/reference/raster.vol-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/raster.vol-1.png -------------------------------------------------------------------------------- /docs/reference/rasterCorrelation-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/rasterCorrelation-1.png -------------------------------------------------------------------------------- /docs/reference/remove.holes-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/remove.holes-1.png -------------------------------------------------------------------------------- /docs/reference/rotate.polygon-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/rotate.polygon-1.png -------------------------------------------------------------------------------- /docs/reference/sample.annulus-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/sample.annulus-1.png -------------------------------------------------------------------------------- /docs/reference/sample.line-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/sample.line-1.png -------------------------------------------------------------------------------- /docs/reference/sample.poly-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/sample.poly-1.png -------------------------------------------------------------------------------- /docs/reference/sampleTransect-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/sampleTransect-1.png -------------------------------------------------------------------------------- /docs/reference/sar-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/sar-1.png -------------------------------------------------------------------------------- /docs/reference/separability-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/separability-1.png -------------------------------------------------------------------------------- /docs/reference/sg.smooth-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/sg.smooth-1.png -------------------------------------------------------------------------------- /docs/reference/similarity-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/similarity-1.png -------------------------------------------------------------------------------- /docs/reference/sobal-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/sobal-1.png -------------------------------------------------------------------------------- /docs/reference/sp.kde-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/sp.kde-1.png -------------------------------------------------------------------------------- /docs/reference/sp.kde-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/sp.kde-2.png -------------------------------------------------------------------------------- /docs/reference/sp.kde-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/sp.kde-3.png -------------------------------------------------------------------------------- /docs/reference/sp.kde-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/sp.kde-4.png -------------------------------------------------------------------------------- /docs/reference/sp.na.omit-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/sp.na.omit-1.png -------------------------------------------------------------------------------- /docs/reference/spatial.select-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/spatial.select-1.png -------------------------------------------------------------------------------- /docs/reference/spatial.select-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/spatial.select-2.png -------------------------------------------------------------------------------- /docs/reference/spherical.sd-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/spherical.sd-1.png -------------------------------------------------------------------------------- /docs/reference/srr-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/srr-1.png -------------------------------------------------------------------------------- /docs/reference/stratified.random-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/stratified.random-1.png -------------------------------------------------------------------------------- /docs/reference/subsample.distance-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/subsample.distance-1.png -------------------------------------------------------------------------------- /docs/reference/subsample.distance-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/subsample.distance-2.png -------------------------------------------------------------------------------- /docs/reference/topo.distance-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/topo.distance-1.png -------------------------------------------------------------------------------- /docs/reference/tpi-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/tpi-1.png -------------------------------------------------------------------------------- /docs/reference/trasp-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/trasp-1.png -------------------------------------------------------------------------------- /docs/reference/trend.line-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/trend.line-1.png -------------------------------------------------------------------------------- /docs/reference/tri-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/tri-1.png -------------------------------------------------------------------------------- /docs/reference/vrm-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/vrm-1.png -------------------------------------------------------------------------------- /docs/reference/winsorize-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/winsorize-1.png -------------------------------------------------------------------------------- /docs/reference/wt.centroid-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/wt.centroid-1.png -------------------------------------------------------------------------------- /docs/reference/zonal.stats-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/docs/reference/zonal.stats-1.png -------------------------------------------------------------------------------- /inst/CITATION: -------------------------------------------------------------------------------- 1 | citHeader("To cite spatialEco in publications use:") 2 | 3 | spatialEco.ref <- c( 4 | bibentry( 5 | bibtype = "Manual", 6 | title = "spatialEco", 7 | author = c( 8 | person(c("Jeffrey", "S."), "Evans", role = c("aut", "cre")), 9 | person(c("Melanie", "A."), "Murphy", role = c("aut")) 10 | ), 11 | year = "2023", 12 | note = "R package version 2.0-2", 13 | url = "https://github.com/jeffreyevans/spatialEco", 14 | keywords = "spatialEco-package" 15 | ) 16 | ) 17 | -------------------------------------------------------------------------------- /inst/extdata/Landsat_TM5.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/inst/extdata/Landsat_TM5.tif -------------------------------------------------------------------------------- /inst/extdata/elev.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/inst/extdata/elev.tif -------------------------------------------------------------------------------- /man/TM5.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/TM5-data.R 3 | \docType{data} 4 | \name{TM5} 5 | \alias{TM5} 6 | \title{Landsat 5 TM Scene} 7 | \format{ 8 | A tif (inst/extdata/Landsat_TM5.tif) with 30m 6 bands: 9 | \describe{ 10 | \item{Blue}{0.45 - 0.52 µm} 11 | \item{Green}{0.52 - 0.60 µm} 12 | \item{Red}{0.63 - 0.69 µm} 13 | \item{NIR Near-Infrared}{0.76 - 0.90 µm} 14 | \item{SWIR1 Near-Infrared}{1.55 - 1.75 µm} 15 | \item{SWIR2 Mid-Infrared}{2.08 - 2.35 µm} 16 | } 17 | } 18 | \description{ 19 | Subset of Landsat 5 TM Scene: LT52240631988227CUB02 Contains six bands of surface reflectance 20 | path 224/row 63 acquisition date: 1988-08-14 13:00:47 GMT, EPSG:32622 21 | } 22 | -------------------------------------------------------------------------------- /man/all_pairwise.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/all_pairwise.R 3 | \name{all_pairwise} 4 | \alias{all_pairwise} 5 | \title{All pairwise combinations} 6 | \usage{ 7 | all_pairwise(x) 8 | } 9 | \arguments{ 10 | \item{x}{A numeric or character vector} 11 | } 12 | \value{ 13 | A list object with increasing all combination objects, 14 | the first list element are the pairwise comparisons 15 | } 16 | \description{ 17 | Creates all pairwise combinations list for iteration 18 | } 19 | \details{ 20 | This returns a list of vector combinations starting with 21 | pairwise, as the first nested list element, then in groups of 22 | threes, fours, to length of the vector. 23 | } 24 | \examples{ 25 | classes <- paste0("class", 1:10) 26 | 27 | all_pairwise(classes)[[1]] 28 | 29 | #### How to use as an iterator 30 | # dataframe with 4 cols, 100 rows 31 | d <- as.data.frame(matrix(runif(100*4), 100, 4)) 32 | names(d) <- paste0("class", 1:4) 33 | 34 | ( idx <- all_pairwise(colnames(d))[[1]] ) 35 | 36 | opar <- par(no.readonly=TRUE) 37 | par(mfrow=c(2,3)) 38 | lapply(idx, function(i) { 39 | plot(d[,i[1]], d[,i[2]], main=paste0(i[1], " vs ", i[2]) ) 40 | }) 41 | par(opar) 42 | 43 | } 44 | \author{ 45 | Jeffrey S. Evans tnc.org> 46 | } 47 | -------------------------------------------------------------------------------- /man/annulus.matrix.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/annulus.matrix.R 3 | \name{annulus.matrix} 4 | \alias{annulus.matrix} 5 | \title{Annulus matrix} 6 | \usage{ 7 | annulus.matrix(scale = 3, inner.scale = 0, outer.scale = 0, null.value = 0) 8 | } 9 | \arguments{ 10 | \item{scale}{Number of rings (defines dimensions of matrix)} 11 | 12 | \item{inner.scale}{Number of inner rings to set to null.value} 13 | 14 | \item{outer.scale}{Number of outer rings to set to null.value} 15 | 16 | \item{null.value}{Value to set inner and outer scale(s) to} 17 | } 18 | \value{ 19 | A matrix object with defined null.value and 1, representing retained rings 20 | } 21 | \description{ 22 | Creates a square matrix representing annulus position values of 1 23 | and defined null 24 | } 25 | \details{ 26 | This function will return a matrix of 1 and defined null.value based on a specification 27 | of the scale, inner scale and outer scale. The scale defines how many rings will be 28 | represented in the matrix based on (2 * scale - 1). So, a scale of 3 will result in a 29 | 5x5 matrix. The inner.scale and outer.scale arguments represent the > and < rings that 30 | will be set to the defined null.value (see examples). The resulting matrix can be used 31 | as the specified window in a focal function. 32 | } 33 | \examples{ 34 | annulus.matrix(5) # 5 concentric rings 35 | annulus.matrix(5, 3) # 5 concentric rings with the 3 inner set to 0 36 | annulus.matrix(5, 3, null.value=NA) # 5 concentric rings with the 3 inner set to NA 37 | annulus.matrix(5, 3, 5) # 5 rings with 3 inner and 5 outer set to 0 38 | annulus.matrix(9, 3, 7) # 9 rings with 3 inner and 7 outer set to 0 39 | 40 | } 41 | \author{ 42 | Jeffrey S. Evans 43 | } 44 | -------------------------------------------------------------------------------- /man/ants.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/ants-data.R 3 | \docType{data} 4 | \name{ants} 5 | \alias{ants} 6 | \title{Ant Biodiversity Data} 7 | \format{ 8 | A data.frame with 82 rows (species) and 5 columns (covertypes): 9 | \describe{ 10 | \item{species}{Ant species (family)} 11 | \item{Primary.Forest}{Primary forest type} 12 | \item{Abandoned.cacao.plantations}{Abandoned cacao plantations type} 13 | \item{Productive.cacao.plantations}{Active cacao plantations type} 14 | \item{Banana.plantations}{Active banana plantations type} 15 | } 16 | } 17 | \description{ 18 | Roth et al., (1994) Costa Rican ant diversity data 19 | } 20 | \references{ 21 | Roth, D. S., I. Perfecto, and B. Rathcke (1994) The effects of management systems on 22 | ground-foraging ant diversity in Costa Rica. Ecological Applications 4(3):423-436. 23 | } 24 | -------------------------------------------------------------------------------- /man/bbox_poly.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/bbox_poly.R 3 | \name{bbox_poly} 4 | \alias{bbox_poly} 5 | \title{Bounding box polygon} 6 | \usage{ 7 | bbox_poly(x) 8 | } 9 | \arguments{ 10 | \item{x}{An sf or terra object or vector of bounding coordinates} 11 | } 12 | \value{ 13 | A single feature sf class polygon object 14 | } 15 | \description{ 16 | Creates a polygon from a vector or raster extent 17 | } 18 | \details{ 19 | If not a spatial object, expected order of input for x is: xmin, ymin, 20 | xmax, ymax. Where; xmin, ymin and the coordinates of top left corner of the 21 | bounding box and xmax, ymax represent the bottom right corner. The maximum 22 | value of xmax is width of the extent while maximum value of ymax is the height 23 | of the extent. 24 | } 25 | \examples{ 26 | if(require(sp, quietly = TRUE)) { 27 | library(terra) 28 | library(sf) 29 | data(meuse, package = "sp") 30 | meuse <- st_as_sf(meuse, coords = c("x", "y"), crs = 28992, 31 | agr = "constant") 32 | 33 | # raster (terra) 34 | r <- rast(ext(meuse)) 35 | r[] <- runif(ncell(r)) 36 | crs(r) <- "epsg:28992" 37 | e <- bbox_poly(r) 38 | 39 | plot(r) 40 | plot(st_geometry(e), border="red", add=TRUE) 41 | 42 | # extent vector 43 | e <- bbox_poly(c(178605, 329714, 181390, 333611)) 44 | plot(e) 45 | 46 | # vector bounding box 47 | e <- bbox_poly(meuse) 48 | 49 | plot(st_geometry(meuse), pch=20) 50 | plot(st_geometry(e), add=TRUE) 51 | 52 | } else { 53 | cat("Please install sp package to run this example", "\n") 54 | } 55 | 56 | } 57 | \author{ 58 | Jeffrey S. Evans 59 | } 60 | -------------------------------------------------------------------------------- /man/bearing.distance.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/bearing.distance.R 3 | \name{bearing.distance} 4 | \alias{bearing.distance} 5 | \title{Bearing and Distance} 6 | \usage{ 7 | bearing.distance(x, y, distance, azimuth, EastOfNorth = TRUE) 8 | } 9 | \arguments{ 10 | \item{x}{x coordinate} 11 | 12 | \item{y}{y coordinate} 13 | 14 | \item{distance}{Distance to new point (in same units as x,y)} 15 | 16 | \item{azimuth}{Azimuth to new point} 17 | 18 | \item{EastOfNorth}{Specified surveying convention} 19 | } 20 | \value{ 21 | a new point representing location of baring and distance 22 | } 23 | \description{ 24 | Calculates a new point [X,Y] based on defined 25 | bearing and distance 26 | } 27 | \details{ 28 | East of north is a surveying convention and defaults to true. 29 | } 30 | \examples{ 31 | pt <- cbind( x=480933, y=4479433) 32 | bearing.distance(pt[1], pt[2], 1000, 40) 33 | 34 | } 35 | \author{ 36 | Jeffrey S. Evans 37 | } 38 | -------------------------------------------------------------------------------- /man/cgls_urls.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/cgls_urls.R 3 | \name{cgls_urls} 4 | \alias{cgls_urls} 5 | \title{Provide URL's for Copernicus Global Land Service datasets} 6 | \usage{ 7 | cgls_urls(...) 8 | } 9 | \arguments{ 10 | \item{...}{not used} 11 | } 12 | \description{ 13 | Returns URL's of a product/version/resolution 14 | } 15 | \details{ 16 | Given the changes to ESA-Copenricus data distribution, using digests is 17 | no longer reliable. Plese use the Sentinel Hub or a STAC API for data 18 | acccess 19 | } 20 | -------------------------------------------------------------------------------- /man/chae.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/chae.R 3 | \name{chae} 4 | \alias{chae} 5 | \title{Canine-Human Age Equivalent} 6 | \usage{ 7 | chae(x) 8 | } 9 | \arguments{ 10 | \item{x}{numeric vector, dog age} 11 | } 12 | \value{ 13 | numeric vector, equivalent human age 14 | } 15 | \description{ 16 | Calculates canines equivalent human age (for fun) 17 | } 18 | \examples{ 19 | dat <- data.frame(DogAge = seq(0,18,0.25), 20 | HumanAge=chae(seq(0,18,0.25)))[-1,] 21 | 22 | plot(dat$DogAge, dat$HumanAge, "l", 23 | main="Canine-Human Age Equivalence", 24 | ylab="Human Age", xlab="Dog Age") 25 | points( 15, chae(15), col="red", pch=19, cex=1.5) 26 | points( 10, chae(10), col="blue", pch=19, cex=1.5) 27 | points( 3, chae(3), col="black", pch=19, cex=1.5) 28 | legend("bottomright", legend=c("Camas (15-YO)", "Kele (10-YO)", "Aster (3-YO)"), 29 | pch=c(19,19,19), cex=c(1.5,1.5,1.5), 30 | col=c("red","blue","black")) 31 | 32 | } 33 | \references{ 34 | Wang, T., J. M, A.N. Hogan, S. Fong, K. Licon et al. (2020) quantitative 35 | translation of dog-to-human aging by conserved remodeling of epigenetic 36 | networks. Cell Systems 11(2)176-185 37 | } 38 | \author{ 39 | Jeffrey S. Evans 40 | } 41 | -------------------------------------------------------------------------------- /man/chen.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/chen-data.R 3 | \docType{data} 4 | \name{chen} 5 | \alias{chen} 6 | \title{Cross-correlation data from Chen (2015)} 7 | \format{ 8 | A list object with 3 elements: 9 | \describe{ 10 | \item{X}{per capita GRP(yuan)} 11 | \item{Y}{Level of urbanization percent} 12 | \item{M}{Railway Distance (km) matrix of 29 Chinese regions} 13 | } 14 | } 15 | \source{ 16 | \url{https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0126158} 17 | } 18 | \description{ 19 | Urbanization and economic development data from Chen (2015) 20 | compiled from, National Bureau of Statistics of China 21 | } 22 | \references{ 23 | Chen, Y.G. (2012) On the four types of weight functions for spatial contiguity 24 | matrix. Letters in Spatial and Resource Sciences 5(2):65-72 25 | 26 | Chen, Y.G. (2013) New approaches for calculating Moran’s index of spatial 27 | autocorrelation. PLoS ONE 8(7):e68336 28 | 29 | Chen, Y.G. (2015) A New Methodology of Spatial Cross-Correlation Analysis. 30 | PLoS One 10(5):e0126158. doi:10.1371/journal.pone.0126158 31 | } 32 | -------------------------------------------------------------------------------- /man/classBreaks.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/classBreaks.R 3 | \name{classBreaks} 4 | \alias{classBreaks} 5 | \title{Class breaks} 6 | \usage{ 7 | classBreaks(x, n, type = c("equal", "quantile", "std", "geometric")) 8 | } 9 | \arguments{ 10 | \item{x}{A vector to find breaks for} 11 | 12 | \item{n}{Number of breaks} 13 | 14 | \item{type}{Statistic used to find breaks c("equal", "quantile", "std", "geometric")} 15 | } 16 | \value{ 17 | A vector containing class break values the length is n+1 to allow for 18 | specification of ranges 19 | } 20 | \description{ 21 | Finds class breaks in a distribution 22 | } 23 | \details{ 24 | The robust std method uses sqrt(sum(x^2)/(n-1)) to center the data before deriving "pretty" breaks. 25 | } 26 | \examples{ 27 | y <- rnbinom(100, 10, 0.5) 28 | classBreaks(y, 10) 29 | classBreaks(y, 10, type="quantile") 30 | 31 | opar <- par(no.readonly=TRUE) 32 | par(mfrow=c(2,2)) 33 | d <- density(y) 34 | plot(d, type="n", main="Equal Area breaks") 35 | polygon(d, col="cyan") 36 | abline(v=classBreaks(y, 10)) 37 | plot(d, type="n", main="Quantile breaks") 38 | polygon(d, col="cyan") 39 | abline(v=classBreaks(y, 10, type="quantile")) 40 | plot(d, type="n", main="Robust Standard Deviation breaks") 41 | polygon(d, col="cyan") 42 | abline(v=classBreaks(y, 10, type="std")) 43 | plot(d, type="n", main="Geometric interval breaks") 44 | polygon(d, col="cyan") 45 | abline(v=classBreaks(y, 10, type="geometric")) 46 | par(opar) 47 | 48 | ( y.breaks <- classBreaks(y, 10) ) 49 | cut(y, y.breaks, include.lowest = TRUE, labels = 1:10) 50 | 51 | } 52 | \author{ 53 | Jeffrey S. Evans 54 | } 55 | -------------------------------------------------------------------------------- /man/combine.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/combine.R 3 | \name{combine} 4 | \alias{combine} 5 | \title{raster combine} 6 | \usage{ 7 | combine(x) 8 | } 9 | \arguments{ 10 | \item{x}{raster stack/brick or SpatialPixelsDataFrame object} 11 | } 12 | \value{ 13 | A ratified (factor) terra SpatRaster representing unique combinations. 14 | } 15 | \description{ 16 | Combines rasters into all unique combinations of inputs 17 | } 18 | \details{ 19 | A single ratified raster object is returned with the summary table 20 | as the raster attribute table, this is most similar to the ESRI 21 | format resulting from their combine function. 22 | 23 | Please note that this is not a memory safe function that utilizes 24 | out of memory in the manner that the terra package does. 25 | } 26 | \examples{ 27 | library(terra) 28 | 29 | # Create example data (with a few NA's introduced) 30 | r1 <- rast(nrows=100, ncol=100) 31 | names(r1) <- "LC1" 32 | r1[] <- round(runif(ncell(r1), 1,4),0) 33 | r1[c(8,10,50,100)] <- NA 34 | r2 <- rast(nrows=100, ncol=100) 35 | names(r2) <- "LC2" 36 | r2[] <- round(runif(ncell(r2), 2,6),0) 37 | r2[c(10,50,100)] <- NA 38 | r3 <- rast(nrows=100, ncol=100) 39 | names(r3) <- "LC3" 40 | r3[] <- round(runif(ncell(r3), 2,6),0) 41 | r3[c(10,50,100)] <- NA 42 | r <- c(r1,r2,r3) 43 | names(r) <- c("LC1","LC2","LC3") 44 | 45 | # Combine rasters with a multilayer stack 46 | cr <- combine(r) 47 | head(cr$summary) 48 | plot(cr$combine) 49 | 50 | # or, from separate layers 51 | cr <- combine(c(r1,r3)) 52 | 53 | } 54 | \author{ 55 | Jeffrey S. Evans 56 | } 57 | -------------------------------------------------------------------------------- /man/conf.interval.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/conf.interval.R 3 | \name{conf.interval} 4 | \alias{conf.interval} 5 | \title{Confidence interval for mean or median} 6 | \usage{ 7 | conf.interval(x, cl = 0.95, stat = "mean", std.error = TRUE) 8 | } 9 | \arguments{ 10 | \item{x}{Vector to calculate confidence interval for} 11 | 12 | \item{cl}{Percent confidence level (default = 0.95)} 13 | 14 | \item{stat}{Statistic (mean or median)} 15 | 16 | \item{std.error}{Return standard error (TRUE/FALSE)} 17 | } 18 | \value{ 19 | data.frame contaning: 20 | \itemize{ 21 | \item lci - Lower confidence interval value 22 | \item uci - Upper confidence interval value 23 | \item mean - If stat = "mean", mean value of distribution 24 | \item mean - Value of the mean or median 25 | \item conf.level - Confidence level used for confidence interval 26 | \item std.error - If std.error = TRUE standard error of distribution 27 | } 28 | } 29 | \description{ 30 | Calculates confidence interval for the mean or median of a distribution with 31 | unknown population variance 32 | } 33 | \examples{ 34 | x <- runif(100) 35 | cr <- conf.interval(x, cl = 0.97) 36 | print(cr) 37 | 38 | d <- density(x) 39 | plot(d, type="n", main = "PDF with mean and 0.97 confidence interval") 40 | polygon(d, col="cyan3") 41 | abline(v=mean(x, na.rm = TRUE), lty = 2) 42 | segments( x0=cr[["lci"]], y0=mean(d$y), x1=cr[["uci"]], 43 | y1=mean(d$y), lwd = 2.5, 44 | col = "black") 45 | legend("topright", legend = c("mean", "CI"), 46 | lty = c(2,1), lwd = c(1,2.5)) 47 | 48 | } 49 | \author{ 50 | Jeffrey S. Evans \href{mailto:jeffrey_evans@tnc.org}{jeffrey_evans@tnc.org} 51 | } 52 | -------------------------------------------------------------------------------- /man/cor.data.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/cor.data.R 3 | \docType{data} 4 | \name{cor.data} 5 | \alias{cor.data} 6 | \title{Various correlation structures} 7 | \format{ 8 | A list object with 4 elements containing data.frames: 9 | \describe{ 10 | \item{example 1}{two columns with nonlinear wave function relationship} 11 | \item{example 2}{two columns with simple nonlinear relationship} 12 | \item{example 3}{two columns with nonlinear multi-level wave function relationship} 13 | \item{example 4}{4 columns with first two having linear relationship} 14 | } 15 | } 16 | \description{ 17 | linear and nonlinear correlated data examples 18 | 19 | A list object with various linear and nonlinear correlation structures 20 | } 21 | -------------------------------------------------------------------------------- /man/correlogram.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/correlogram.R 3 | \name{correlogram} 4 | \alias{correlogram} 5 | \title{Correlogram} 6 | \usage{ 7 | correlogram(x, v, dist = 5000, ns = 99, ...) 8 | } 9 | \arguments{ 10 | \item{x}{A sf POINT object} 11 | 12 | \item{v}{Test variable in x} 13 | 14 | \item{dist}{Distance of correlation lags, if latlong=TRUE units are 15 | great circle in kilometers} 16 | 17 | \item{ns}{Number of simulations to derive simulation envelope} 18 | 19 | \item{...}{Arguments passed to cor ('pearson', 'kendall' or 'spearman')} 20 | } 21 | \value{ 22 | Plot of correlogram and a list object containing: 23 | \itemize{ 24 | \item autocorrelation is a data.frame object with the following components 25 | \item autocorrelation - Autocorrelation value for each distance lag 26 | \item dist - Value of distance lag 27 | \item lci - Lower confidence interval (p=0.025) 28 | \item uci - Upper confidence interval (p=0.975) 29 | \item CorrPlot recordedplot object to recall plot 30 | } 31 | } 32 | \description{ 33 | Calculates and plots a correlogram 34 | } 35 | \examples{ 36 | library(sf) 37 | if(require(sp, quietly = TRUE)) { 38 | data(meuse, package = "sp") 39 | meuse <- st_as_sf(meuse, coords = c("x", "y"), crs = 28992, 40 | agr = "constant") 41 | } 42 | 43 | zinc.cg <- correlogram(x = meuse, v = meuse$zinc, dist = 250, ns = 9) 44 | 45 | } 46 | \author{ 47 | Jeffrey S. Evans \href{mailto:jeffrey_evans@tnc.org}{jeffrey_evans@tnc.org} 48 | } 49 | -------------------------------------------------------------------------------- /man/dahi.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/dahi.R 3 | \name{dahi} 4 | \alias{dahi} 5 | \title{Diurnal Anisotropic Heat Index} 6 | \usage{ 7 | dahi(x, amax = 202.5) 8 | } 9 | \arguments{ 10 | \item{x}{An elevation raster of class terra SpatRaster} 11 | 12 | \item{amax}{The Alpha Max (amax) parameter in degrees defined 13 | as: minimum = 0, maximum = 360 with the default = 202.500} 14 | } 15 | \value{ 16 | terra SpatRaster class object Diurnal Anisotropic Heat Index 17 | } 18 | \description{ 19 | Simple approximation of the anisotropic diurnal heat (Ha) distribution 20 | } 21 | \details{ 22 | The Diurnal Anisotropic Heat Index is based on this equation. 23 | Ha = cos(amax - a) * arctan(b) 24 | Where; amax defines the aspect with the maximum total heat 25 | surplus, a is the aspect and b is the slope angle. Please 26 | note that all parameters are converted to radians. 27 | } 28 | \examples{ 29 | library(terra) 30 | elev <- rast(system.file("extdata/elev.tif", package="spatialEco")) 31 | Ha <- dahi(elev) 32 | plot(Ha, col=grey(0:100/100), smooth=TRUE) 33 | 34 | } 35 | \references{ 36 | Boehner, J., and Antonic, O. (2009) Land-surface parameters specific to 37 | topo-climatology. In: Hengl, T., & Reuter, H. (Eds.), Geomorphometry - 38 | Concepts, Software, Applications. Developments in Soil Science, 39 | 33:195-226 40 | } 41 | \author{ 42 | Jeffrey S. Evans 43 | } 44 | -------------------------------------------------------------------------------- /man/date_seq.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/date_seq.R 3 | \name{date_seq} 4 | \alias{date_seq} 5 | \title{date sequence} 6 | \usage{ 7 | date_seq( 8 | start, 9 | end, 10 | step = c("day", "week", "month", "quarter", "year", "minute"), 11 | rm.leap = FALSE 12 | ) 13 | } 14 | \arguments{ 15 | \item{start}{Start date in "yyyy/mm/dd" character format} 16 | 17 | \item{end}{End date in "yyyy/mm/dd" character format} 18 | 19 | \item{step}{Time step, options are c("day", "week", "month", "quarter", 20 | "year", "minute")} 21 | 22 | \item{rm.leap}{Remove extra days in leap years} 23 | } 24 | \value{ 25 | A date vector of class POSIXct for minute and Date for other options 26 | } 27 | \description{ 28 | creates date sequence given start and stop dates 29 | } 30 | \examples{ 31 | # monthly steps 1990/01/01 - 2019/12/31 32 | d <- date_seq("1990/01/01", "2019/12/31", step="month") 33 | 34 | # daily steps 1990/01/01 - 2019/12/31 35 | d <- date_seq("1990/01/01", "2019/12/31", step="day") 36 | 37 | # daily steps 1990/01/01 - 2019/12/31 with leap days removed 38 | d <- date_seq("1990/01/01", "2019/12/31", step="day", rm.leap=TRUE) 39 | 40 | # daily step 2008/12/29 - 2008/12/31, 2008 is leap year 41 | d <- date_seq("2008/12/29", "2008/12/31") 42 | 43 | # minutes step 2008/12/29 - 2008/12/31, 2008 is leap year 44 | d <- date_seq("2008/12/29", "2008/12/31", step="minute") 45 | 46 | } 47 | \author{ 48 | Jeffrey S. Evans 49 | } 50 | -------------------------------------------------------------------------------- /man/daymet.point.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/daymet.point.R 3 | \name{daymet.point} 4 | \alias{daymet.point} 5 | \title{DAYMET point values} 6 | \usage{ 7 | daymet.point( 8 | lat, 9 | long, 10 | start.year, 11 | end.year, 12 | site = NULL, 13 | files = FALSE, 14 | echo = FALSE 15 | ) 16 | } 17 | \arguments{ 18 | \item{lat}{latitude of point (decimal degrees WGS84)} 19 | 20 | \item{long}{longitude pf point (decimal degrees WGS84)} 21 | 22 | \item{start.year}{First year of data} 23 | 24 | \item{end.year}{Last year of data} 25 | 26 | \item{site}{Unique identification value that is appended to data} 27 | 28 | \item{files}{(TRUE/FALSE) Write file to disk} 29 | 30 | \item{echo}{(TRUE/FALSE) Echo progress} 31 | } 32 | \value{ 33 | A data.frame with geographic coordinate point-level climate results 34 | } 35 | \description{ 36 | Downloads DAYMET climate variables for specified point and time-period 37 | } 38 | \details{ 39 | data is available for Long -131.0 W and -53.0 W; lat 52.0 N and 14.5 N 40 | Function uses the Single Pixel Extraction tool and returns year, yday, 41 | dayl(s), prcp (mm/day), srad (W/m^2), swe (kg/m^2), tmax (deg c), 42 | tmin (deg c), vp (Pa) 43 | Metadata for DAYMET single pixel extraction: 44 | \url{ https://daymet.ornl.gov/files/UserGuides/current/readme_singlepointextraction.pdf } 45 | } 46 | \examples{ 47 | \donttest{ 48 | ( d <- daymet.point(lat = 36.0133, long = -84.2625, start.year = 2013, 49 | end.year=2014, site = "1", files = FALSE, echo = FALSE) ) 50 | } 51 | 52 | } 53 | \author{ 54 | Jeffrey S. Evans 55 | } 56 | -------------------------------------------------------------------------------- /man/daymet.tiles.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/daymet.tiles.R 3 | \name{daymet.tiles} 4 | \alias{daymet.tiles} 5 | \title{DAYMET Tile ID's} 6 | \usage{ 7 | daymet.tiles(...) 8 | } 9 | \arguments{ 10 | \item{...}{ignored} 11 | } 12 | \value{ 13 | Vector of DAYMET tile IDS or if sp = TRUE a sp class SpatialPolygonsDataFrame 14 | } 15 | \description{ 16 | Returns a vector of DAYMET tile id's within a specified extent 17 | } 18 | \note{ 19 | Function accepts sp, raster or extent class object or bounding coordinates. 20 | All input must be in the same projection as the tile index SpatialPolygonsDataFrame. 21 | The library includes the DAYMAT tile index "DAYMET_tiles" which can be add using 22 | data(), see examples. 23 | } 24 | \author{ 25 | Jeffrey S. Evans 26 | } 27 | -------------------------------------------------------------------------------- /man/dispersion.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/dispersion.R 3 | \name{dispersion} 4 | \alias{dispersion} 5 | \title{Dispersion (H-prime)} 6 | \usage{ 7 | dispersion(x) 8 | } 9 | \arguments{ 10 | \item{x}{data.frame object of target values} 11 | } 12 | \value{ 13 | data.frame with columns H values for each target, H , sH, sHmax 14 | } 15 | \description{ 16 | Calculates the dispersion ("rarity") of targets associated 17 | with planning units 18 | } 19 | \details{ 20 | The dispersion index (H-prime) is calculated H = sum( sqrt(p) / sqrt(a) ) 21 | where; P = (sum of target in planning unit / sum of target across all 22 | planning units) and a = (count of planning units containing 23 | target / number of planning units) 24 | } 25 | \examples{ 26 | \donttest{ 27 | library(sf) 28 | data(pu) 29 | 30 | d <- dispersion(st_drop_geometry(pu[,2:ncol(pu)])) 31 | p <- d[,"H"] 32 | clr <- c("#3288BD", "#99D594", "#E6F598", "#FEE08B", 33 | "#FC8D59", "#D53E4F") 34 | clrs <- ifelse(p < 0.5524462, clr[1], 35 | ifelse(p >= 0.5524462 & p < 1.223523, clr[2], 36 | ifelse(p >= 1.223523 & p < 2.465613, clr[3], 37 | ifelse(p >= 2.465613 & p < 4.76429, clr[4], 38 | ifelse(p >= 4.76429 & p < 8.817699, clr[5], 39 | ifelse(p >= 8.817699, clr[6], NA)))))) 40 | plot(st_geometry(pu), col=clrs, border=NA) 41 | legend("bottomleft", legend=rev(c("Very Rare","Rare","Moderately Rare", 42 | "Somewhat Common","Common","Over Dispersed")), 43 | fill=clr, cex=0.6, bty="n") 44 | box() 45 | } 46 | 47 | } 48 | \references{ 49 | Evans, J.S., S.R. Schill, G.T. Raber (2015) A Systematic Framework for Spatial 50 | Conservation Planning and Ecological Priority Design in St. Lucia, Eastern Caribbean. 51 | Chapter 26 in Central American Biodiversity : Conservation, Ecology and a Sustainable 52 | Future. F. Huettman (eds). Springer, NY. 53 | } 54 | \author{ 55 | Jeffrey S. Evans 56 | } 57 | -------------------------------------------------------------------------------- /man/dissection.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/dissection.R 3 | \name{dissection} 4 | \alias{dissection} 5 | \title{Dissection} 6 | \usage{ 7 | dissection(x, s = 5, ...) 8 | } 9 | \arguments{ 10 | \item{x}{A terra SpatRaster class object} 11 | 12 | \item{s}{Focal window size} 13 | 14 | \item{...}{Additional arguments passed to terra::lapp} 15 | } 16 | \value{ 17 | A SpatRaster class object of Martonne's modified dissection 18 | } 19 | \description{ 20 | Calculates the Evans (1972) Martonne's modified 21 | dissection 22 | } 23 | \details{ 24 | Dissection is calculated as: 25 | ( z(s) - min(z(s)) ) / ( max(z(s)) - min(z(s)) ) 26 | } 27 | \examples{ 28 | \donttest{ 29 | library(terra) 30 | elev <- rast(system.file("extdata/elev.tif", package="spatialEco")) 31 | d <- dissection(elev, s=3) 32 | plot(d, main="dissection") 33 | } 34 | 35 | } 36 | \author{ 37 | Jeffrey S. Evans 38 | } 39 | -------------------------------------------------------------------------------- /man/divergence.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/divergence.R 3 | \name{divergence} 4 | \alias{divergence} 5 | \title{divergence} 6 | \usage{ 7 | divergence(x, y, type = c("Kullback-Leibler", "cross-entropy")) 8 | } 9 | \arguments{ 10 | \item{x}{a vector of integer values, defining observed} 11 | 12 | \item{y}{a vector of integer values, defining estimates} 13 | 14 | \item{type}{Type of divergence statistic c("Kullback-Leibler", 15 | "cross-entropy")} 16 | } 17 | \value{ 18 | single value vector with divergence statistic 19 | } 20 | \description{ 21 | Kullback-Leibler Divergence (Cross-entropy) 22 | } 23 | \examples{ 24 | x <- round(runif(10,1,4),0) 25 | y <- round(runif(10,1,4),0) 26 | 27 | divergence(x, y) 28 | divergence(x, y, type = "cross-entropy") 29 | 30 | } 31 | \author{ 32 | Jeffrey S. Evans 33 | } 34 | -------------------------------------------------------------------------------- /man/effect.size.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/effect.size.R 3 | \name{effect.size} 4 | \alias{effect.size} 5 | \title{Cohen's-d effect size} 6 | \usage{ 7 | effect.size(y, x, pooled = TRUE, conf.level = 0.95) 8 | } 9 | \arguments{ 10 | \item{y}{A character or factor vector} 11 | 12 | \item{x}{A numeric vector, same length as y} 13 | 14 | \item{pooled}{Pooled or population standard deviation (TRUE/FALSE)} 15 | 16 | \item{conf.level}{Specified confidence interval. Default is 0.95} 17 | } 18 | \value{ 19 | An effect.size class object with x, y and a data.frame with columns for effect 20 | size, lower confidence interval, lower confidence interval. The row names of 21 | the data frame represent the levels in y 22 | } 23 | \description{ 24 | Cohen's-d effect size with pooled sd for a control and experimental group 25 | } 26 | \note{ 27 | This implementation will iterate through each class in y and treating a given class 28 | as the experimental group and all other classes as a control case. Each class had d 29 | and the confidence interval derived. A negative d indicate directionality with same 30 | magnitude. The expected range for d is 0 - 3 31 | d is derived; ( mean(experimental group) - mean(control group) ) / sigma(p) 32 | pooled standard deviation is derived; 33 | sqrt( ( (Ne - 1) * sigma(e)^2 + (Nc - 1) * sigma(c)^2 ) / (Ne + Nc - 2) ) 34 | where; Ne, Nc = n of experimental and control groups. 35 | } 36 | \examples{ 37 | ( es <- effect.size(iris$Species, iris$Sepal.Length) ) 38 | plot(es) 39 | 40 | } 41 | \references{ 42 | Cohen, J., (1988) Statistical Power Analysis for the Behavioral Sciences 43 | (second ed.). Lawrence Erlbaum Associates. 44 | 45 | Cohen, J (1992) A power primer. Psychological Bulletin 112(1):155-159 46 | } 47 | \author{ 48 | Jeffrey S. Evans 49 | } 50 | -------------------------------------------------------------------------------- /man/elev.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/elev-data.R 3 | \docType{data} 4 | \name{elev} 5 | \alias{elev} 6 | \title{Elevation raster} 7 | \format{ 8 | A raster RasterLayer class object: 9 | \describe{ 10 | \item{resoultion}{5 arc-minute 0.00833 (10000m)} 11 | \item{nrow}{264} 12 | \item{ncol}{564} 13 | \item{ncell}{148896} 14 | \item{xmin}{5.9} 15 | \item{xmax}{10.6} 16 | \item{ymin}{45.7} 17 | \item{ymax}{47.9} 18 | \item{proj4string}{+proj=longlat +ellps=WGS84} 19 | } 20 | } 21 | \source{ 22 | \url{http://www.diva-gis.org/Data} 23 | } 24 | \description{ 25 | elevation raster of Switzerland 26 | } 27 | -------------------------------------------------------------------------------- /man/erase.point.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/erase.points.R 3 | \name{erase.point} 4 | \alias{erase.point} 5 | \title{Erase points} 6 | \usage{ 7 | erase.point(y, x, inside = TRUE) 8 | } 9 | \arguments{ 10 | \item{y}{A sf POINT object} 11 | 12 | \item{x}{A sf POLYGON object} 13 | 14 | \item{inside}{(TRUE/FALSE) Remove points inside polygon, else outside polygon} 15 | } 16 | \value{ 17 | An sf POINT object 18 | } 19 | \description{ 20 | Removes points intersecting a polygon feature class 21 | } 22 | \details{ 23 | Used to erase points that intersect polygon(s). The default of inside=TRUE 24 | erases points inside the polygons however, if inside=FALSE then 25 | the function results in an intersection where points that 26 | intersect the polygon are retained. 27 | } 28 | \examples{ 29 | 30 | library(sf) 31 | 32 | if (require(sp, quietly = TRUE)) { 33 | data(meuse, package = "sp") 34 | meuse <- st_as_sf(meuse, coords = c("x", "y"), crs = 28992, agr = "constant") 35 | 36 | s <- st_as_sf(st_sample(st_as_sfc(st_bbox(meuse)), size=1000, 37 | type = "regular")) 38 | s$id <- 1:nrow(s) 39 | b <- st_buffer(s[sample(1:nrow(s),5),], dist=300) 40 | b$id <- 1:nrow(b) 41 | 42 | # Erase points based on polygons 43 | in.erase <- erase.point(s, b) 44 | out.erase <- erase.point(s, b, inside = FALSE) 45 | 46 | opar <- par(no.readonly=TRUE) 47 | par(mfrow=c(2,2)) 48 | plot(st_geometry(s), pch=20, main="original data") 49 | plot(st_geometry(b),add=TRUE) 50 | plot(st_geometry(in.erase), pch=20, main="erased data") 51 | plot(st_geometry(b),add=TRUE) 52 | plot(st_geometry(out.erase), pch=20, 53 | main="erased data using inside=FALSE") 54 | plot(st_geometry(b),add=TRUE) 55 | par(opar) 56 | 57 | } else { 58 | cat("Please install sp package to run example", "\n") 59 | } 60 | 61 | } 62 | \author{ 63 | Jeffrey S. Evans tnc.org> 64 | } 65 | -------------------------------------------------------------------------------- /man/extract.vertices.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/extract_vertices.R 3 | \name{extract.vertices} 4 | \alias{extract.vertices} 5 | \title{Extract vertices for polygons or lines} 6 | \usage{ 7 | extract.vertices(x, join = TRUE) 8 | } 9 | \arguments{ 10 | \item{x}{An sf line or polygon class object} 11 | 12 | \item{join}{(TRUE/FALSE) Joint attributes from original object} 13 | } 14 | \value{ 15 | An sf POINT object of extrated line or polygon vertices 16 | } 17 | \description{ 18 | Extracts [x,y] vertices from an sf line or polygon object 19 | } 20 | \details{ 21 | This function returns the vertices of a line or polygon object, as opposed 22 | to the polygon centroids or line start/stop coordinates 23 | } 24 | \examples{ 25 | 26 | library(sf) 27 | nc <- sf::st_read(system.file("shape/nc.shp", package="sf")) 28 | nc <- suppressWarnings(sf::st_cast(nc, "POLYGON")) 29 | nc <- nc[c(10,50),] 30 | 31 | ( v <- extract.vertices(nc) ) 32 | plot(st_geometry(nc)) 33 | plot(st_geometry(v), pch=20, cex=2, col="red", add=TRUE) 34 | 35 | } 36 | \author{ 37 | Jeffrey S. Evans 38 | } 39 | -------------------------------------------------------------------------------- /man/figures/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreyevans/spatialEco/b1c83b82699f5931e0072437883459dfde1dc1bf/man/figures/logo.png -------------------------------------------------------------------------------- /man/fuzzySum.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/fuzzySum.R 3 | \name{fuzzySum} 4 | \alias{fuzzySum} 5 | \title{Fuzzy Sum} 6 | \usage{ 7 | fuzzySum(x) 8 | } 9 | \arguments{ 10 | \item{x}{Vector of values to apply fuzzy sum} 11 | } 12 | \value{ 13 | Value of fuzzy sum 14 | } 15 | \description{ 16 | Calculates the fuzzy sum of a vector 17 | } 18 | \details{ 19 | The fuzzy sum is an increasing linear combination of values. 20 | This can be used to sum probabilities or results of multiple 21 | density functions. 22 | } 23 | \examples{ 24 | p = c(0.8,0.76,0.87) 25 | fuzzySum(p) 26 | sum(p) 27 | 28 | p = c(0.3,0.2,0.1) 29 | fuzzySum(p) 30 | sum(p) 31 | 32 | } 33 | \author{ 34 | Jeffrey S. Evans 35 | } 36 | -------------------------------------------------------------------------------- /man/gaussian.kernel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/gaussian.kernel.R 3 | \name{gaussian.kernel} 4 | \alias{gaussian.kernel} 5 | \title{Gaussian Kernel} 6 | \usage{ 7 | gaussian.kernel(sigma = 2, s = 5) 8 | } 9 | \arguments{ 10 | \item{sigma}{sigma (standard deviation) of kernel (defaults 2)} 11 | 12 | \item{s}{scale defining the number of rows and columns for kernel (default 5)} 13 | } 14 | \value{ 15 | Symmetrical (NxN) matrix of a Gaussian distribution 16 | } 17 | \description{ 18 | Creates a Gaussian Kernel of specified size and sigma 19 | } 20 | \examples{ 21 | opar <- par() 22 | par(mfrow=c(2,2)) 23 | persp(gaussian.kernel(sigma=1, s=27), theta = 135, 24 | phi = 30, col = "grey", ltheta = -120, shade = 0.6, 25 | border=NA ) 26 | persp(gaussian.kernel(sigma=2, s=27), theta = 135, phi = 30, 27 | col = "grey", ltheta = -120, shade = 0.6, border=NA ) 28 | persp(gaussian.kernel(sigma=3, s=27), theta = 135, phi = 30, 29 | col = "grey", ltheta = -120, shade = 0.6, border=NA ) 30 | persp(gaussian.kernel(sigma=4, s=27), theta = 135, phi = 30, 31 | col = "grey", ltheta = -120, shade = 0.6, border=NA ) 32 | par(opar) 33 | } 34 | \author{ 35 | Jeffrey S. Evans 36 | } 37 | -------------------------------------------------------------------------------- /man/geo.buffer.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/geo.buffer.R 3 | \name{geo.buffer} 4 | \alias{geo.buffer} 5 | \title{Buffer geographic data} 6 | \usage{ 7 | geo.buffer(x, r, ...) 8 | } 9 | \arguments{ 10 | \item{x}{A sf or sp vector class object} 11 | 12 | \item{r}{Buffer radius in meters} 13 | 14 | \item{...}{Additional arguments passed to sf::st_buffer} 15 | } 16 | \value{ 17 | an sp or sf polygon class object representing buffer for each feature 18 | } 19 | \description{ 20 | Buffers data in geographic (Latitude/Longitude) projection 21 | } 22 | \details{ 23 | Projects (Latitude/Longitude) data in decimal-degree geographic projection 24 | using an on-the-fly azimuthal equidistant projection in meters centered on 25 | } 26 | \examples{ 27 | library(sf) 28 | e <- c(61.87125, 23.90153, 76.64458, 37.27042) 29 | names(e) <- c("xmin", "ymin", "xmax", "ymax") 30 | s <- st_as_sf(st_sample(st_as_sfc(st_bbox(e)), size=100, 31 | type = "regular")) 32 | st_crs(s) <- st_crs(4326) 33 | s$id <- 1:nrow(s) 34 | 35 | b <- geo.buffer(x=s, r=1000) 36 | plot(st_geometry(b[1,])) 37 | plot(st_geometry(s[1,]), pch=20,cex=2, add=TRUE) 38 | 39 | } 40 | \seealso{ 41 | \code{\link[sf]{st_buffer}} for st_buffer ... arguments 42 | } 43 | \author{ 44 | Jeffrey S. Evans 45 | } 46 | -------------------------------------------------------------------------------- /man/group.pdf.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/group.pdf.R 3 | \name{group.pdf} 4 | \alias{group.pdf} 5 | \title{Probability density plot by group} 6 | \usage{ 7 | group.pdf( 8 | x, 9 | y, 10 | col = NULL, 11 | lty = NULL, 12 | lwd = NULL, 13 | lx = "topleft", 14 | ly = NULL, 15 | ... 16 | ) 17 | } 18 | \arguments{ 19 | \item{x}{Numeric, character or factorial vector of grouping 20 | variable (must be same length as y)} 21 | 22 | \item{y}{Numeric vector (density variable)} 23 | 24 | \item{col}{Optional line colors (see par, col)} 25 | 26 | \item{lty}{Optional line types (see par, lty)} 27 | 28 | \item{lwd}{Optional line widths (see par, lwd)} 29 | 30 | \item{lx}{Position of legend (x coordinate or 'topright', 'topleft', 31 | 'bottomright', 'bottomleft')} 32 | 33 | \item{ly}{Position of legend (y coordinate)} 34 | 35 | \item{...}{Additional arguments passed to plot} 36 | } 37 | \value{ 38 | Plot of grouped PDF's 39 | } 40 | \description{ 41 | Creates a probability density plot of y for 42 | each group of x 43 | } 44 | \examples{ 45 | y=dnorm(runif(100)) 46 | x=rep(c(1,2,3), length.out=length(y)) 47 | group.pdf(x=as.factor(x), y=y, main='Probability Density of y by group(x)', 48 | ylab='PDF', xlab='Y', lty=c(1,2,3)) 49 | 50 | } 51 | \references{ 52 | Simonoff, J. S. (1996). Smoothing Methods in Statistics. Springer-Verlag, New York. 53 | } 54 | \author{ 55 | Jeffrey S. Evans tnc.org> 56 | } 57 | -------------------------------------------------------------------------------- /man/hexagons.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/hexagons.R 3 | \name{hexagons} 4 | \alias{hexagons} 5 | \title{Hexagons} 6 | \usage{ 7 | hexagons(x, res = 100) 8 | } 9 | \arguments{ 10 | \item{x}{sf class object indicating extent} 11 | 12 | \item{res}{Area of resulting hexagons} 13 | } 14 | \value{ 15 | sf POLYGONS object 16 | } 17 | \description{ 18 | Create hexagon polygons 19 | } 20 | \details{ 21 | Based on extent of x, creates a hexagon mesh with size of hexagons defined by res argumnet 22 | } 23 | \examples{ 24 | library(sf) 25 | if(require(sp, quietly = TRUE)) { 26 | data(meuse, package = "sp") 27 | meuse <- st_as_sf(meuse, coords = c("x", "y"), crs = 28992, 28 | agr = "constant") 29 | 30 | hex <- hexagons(meuse, res=300) 31 | plot(st_geometry(hex)) 32 | plot(st_geometry(meuse),pch=20,add=TRUE) 33 | 34 | # subset hexagons to intersection with points 35 | idx <- which(apply(st_intersects(hex, meuse, sparse=FALSE), 1, any)) 36 | hex.sub <- hex[idx,] 37 | plot(st_geometry(hex.sub)) 38 | plot(st_geometry(meuse),pch=20,add=TRUE) 39 | 40 | } else { 41 | cat("Please install sp package to run example", "\n") 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /man/hsp.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/hsp.R 3 | \name{hsp} 4 | \alias{hsp} 5 | \title{Hierarchical Slope Position} 6 | \usage{ 7 | hsp( 8 | x, 9 | min.scale = 3, 10 | max.scale = 27, 11 | inc = 4, 12 | win = "rectangle", 13 | normalize = FALSE 14 | ) 15 | } 16 | \arguments{ 17 | \item{x}{A terra SpatRaster class object} 18 | 19 | \item{min.scale}{Minimum scale (window size)} 20 | 21 | \item{max.scale}{Maximum scale (window size)} 22 | 23 | \item{inc}{Increment to increase scales} 24 | 25 | \item{win}{Window type, options are "rectangle" or "circle"} 26 | 27 | \item{normalize}{Normalize results to 0-1 scale (FALSE | TRUE)} 28 | } 29 | \value{ 30 | terra SpatRaster class object of slope position 31 | } 32 | \description{ 33 | Calculates a hierarchical scale decomposition of topographic 34 | position index 35 | } 36 | \details{ 37 | if win = "circle" units are distance, if win = "rectangle" units 38 | are number of cells 39 | } 40 | \examples{ 41 | \donttest{ 42 | library(terra) 43 | elev <- rast(system.file("extdata/elev.tif", package="spatialEco")) 44 | hsp27 <- hsp(elev, 3, 27, 4, normalize = TRUE) 45 | plot(hsp27) 46 | } 47 | 48 | } 49 | \references{ 50 | Murphy M.A., J.S. Evans, and A.S. Storfer (2010) Quantify Bufo boreas 51 | connectivity in Yellowstone National Park with landscape genetics. 52 | Ecology 91:252-261 53 | } 54 | \author{ 55 | Jeffrey S. Evans 56 | } 57 | -------------------------------------------------------------------------------- /man/idw.smoothing.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/idw.smoothing.R 3 | \name{idw.smoothing} 4 | \alias{idw.smoothing} 5 | \title{Inverse Distance Weighted smoothing} 6 | \usage{ 7 | idw.smoothing(x, y, d, k) 8 | } 9 | \arguments{ 10 | \item{x}{An sf POINT class object} 11 | 12 | \item{y}{Numeric data column in x to be smoothed} 13 | 14 | \item{d}{Distance constraint} 15 | 16 | \item{k}{Maximum number of k-nearest neighbors within d} 17 | } 18 | \value{ 19 | A vector, same length as nrow(x), of smoothed y values 20 | } 21 | \description{ 22 | Distance weighted smoothing of a variable in a 23 | spatial point object 24 | } 25 | \details{ 26 | Smoothing is conducted with a weighted-mean where; weights represent inverse 27 | standardized distance lags Distance-based or neighbour-based smoothing can be 28 | specified by setting the desired neighbour smoothing method to a specified value 29 | then the other parameter to the potential maximum. For example; a constraint 30 | distance, including all neighbors within 1000 (d=1000) would require k to equal 31 | all of the potential neighbors (n-1 or k=nrow(x)-1). 32 | } 33 | \examples{ 34 | 35 | library(sf) 36 | if(require(sp, quietly = TRUE)) { 37 | data(meuse, package = "sp") 38 | meuse <- st_as_sf(meuse, coords = c("x", "y"), crs = 28992, 39 | agr = "constant") 40 | 41 | # Calculate distance weighted mean on cadmium variable in meuse data 42 | cadmium.idw <- idw.smoothing(meuse, 'cadmium', k=nrow(meuse), d = 1000) 43 | meuse$cadmium.wm <- cadmium.idw 44 | 45 | opar <- par(no.readonly=TRUE) 46 | par(mfrow=c(2,1)) 47 | plot(density(meuse$cadmium), main='Cadmium') 48 | plot(density(meuse$cadmium.wm), main='IDW Cadmium') 49 | par(opar) 50 | 51 | plot(meuse[c("cadmium","cadmium.wm")], pch=20) 52 | 53 | } else { 54 | cat("Please install sp package to run example", "\n") 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /man/impute.loess.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/impute.loess.R 3 | \name{impute.loess} 4 | \alias{impute.loess} 5 | \title{Impute loess} 6 | \usage{ 7 | impute.loess(y, s = 0.2, smooth = FALSE) 8 | } 9 | \arguments{ 10 | \item{y}{A vector to impute} 11 | 12 | \item{s}{Smoothing parameter ()} 13 | 14 | \item{smooth}{(FALSE/TRUE) Smooth data, else only replace NA's} 15 | } 16 | \value{ 17 | A vector the same length as x with NA values filled or the data smoothed (or both). 18 | } 19 | \description{ 20 | Imputes missing data or smooths using Loess regression 21 | } 22 | \details{ 23 | Performs a local polynomial regression to smooth data or to 24 | impute NA values. The minimal number of non-NA observations to reliably 25 | impute/smooth values is 6. There is not a reliably way to impute NA's 26 | on the tails of the distributions so if the missing data is in the 27 | first or last position of the vector it will remain NA. Please note 28 | that smooth needs to be TRUE to return a smoothed vector, else only 29 | NA's will be imputed. 30 | } 31 | \examples{ 32 | data(cor.data) 33 | d <- cor.data[[1]][,2] 34 | plot(d, type="l") 35 | lines(impute.loess(d, s=0.3, smooth=TRUE), lwd=2, col="red") 36 | 37 | # add some NA's 38 | d <- d[1:100] 39 | d[sample(30:70, 5)] <- NA 40 | d 41 | 42 | impute.loess(d, s=0.2) 43 | 44 | } 45 | \author{ 46 | Jeffrey S. Evans tnc.org> 47 | } 48 | -------------------------------------------------------------------------------- /man/insert.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/insert.R 3 | \name{insert} 4 | \alias{insert} 5 | \title{Insert a row or column into a data.frame} 6 | \usage{ 7 | insert(x, MARGIN = 1, value = NULL, idx, name = NULL) 8 | } 9 | \arguments{ 10 | \item{x}{Existing data.frame} 11 | 12 | \item{MARGIN}{Insert a 1 = row or 2 = column} 13 | 14 | \item{value}{A vector of values equal to the length of MARGIN, 15 | if nothing specified values with be NA} 16 | 17 | \item{idx}{Index position to insert row or column} 18 | 19 | \item{name}{Name of new column (not used for rows, MARGIN=1)} 20 | } 21 | \value{ 22 | A data.frame with the new row or column inserted 23 | } 24 | \description{ 25 | Inserts a new row or column into a data.frame at a specified location 26 | } 27 | \details{ 28 | Where there are methods to easily add a row/column to the end or beginning of a data.frame, 29 | it is not straight forward to insert data at a specific location within the data.frame. 30 | This function allows for inserting a vector at a specific location eg., between columns or 31 | rows 1 and 2 where row/column 2 is moved to the 3rd position and a new vector of values is 32 | inserted into the 2nd position. 33 | } 34 | \examples{ 35 | d <- data.frame(ID=1:10, y=runif(10)) 36 | 37 | # insert row 38 | insert(d, idx=2) 39 | insert(d, value=c(20,0), idx=2) 40 | 41 | # insert column 42 | insert(d, MARGIN=2, idx=2) 43 | insert(d, MARGIN = 2, value = rep(0,10), idx=2, name="x") 44 | 45 | } 46 | \author{ 47 | Jeffrey S. Evans 48 | } 49 | -------------------------------------------------------------------------------- /man/insert.values.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/insert.values.R 3 | \name{insert.values} 4 | \alias{insert.values} 5 | \title{Insert Values} 6 | \usage{ 7 | insert.values(x, value, index) 8 | } 9 | \arguments{ 10 | \item{x}{A vector to insert values} 11 | 12 | \item{value}{Values to insert into x} 13 | 14 | \item{index}{Index position(s) to insert y values into x} 15 | } 16 | \value{ 17 | A vector with values of y inserted into x and the position(s) 18 | defined by the index 19 | } 20 | \description{ 21 | Inserts new values into a vector at 22 | specified positions 23 | } 24 | \details{ 25 | This function inserts new values at specified positions in a vector. It 26 | does not replace existing values. If a single value is provided for y 27 | and l represents multiple positions y will be replicated for the length 28 | of l. In this way you can insert the same value at multiple locations. 29 | } 30 | \examples{ 31 | (x=1:10) 32 | 33 | # Insert single value in one location 34 | insert.values(x, 100, 2) 35 | 36 | # Insert multiple values in multiple locations 37 | insert.values(x, c(100,200), c(2,8)) 38 | 39 | # Insert single value in multiple locations 40 | insert.values(x, NA, c(2,8)) 41 | 42 | } 43 | \author{ 44 | Jeffrey S. Evans 45 | } 46 | -------------------------------------------------------------------------------- /man/is.empty.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/is.empty.R 3 | \name{is.empty} 4 | \alias{is.empty} 5 | \title{is.empty} 6 | \usage{ 7 | is.empty(x, all.na = FALSE, na.empty = TRUE, trim = TRUE) 8 | } 9 | \arguments{ 10 | \item{x}{A vector to evaluate elements} 11 | 12 | \item{all.na}{(FALSE / TRUE) Return a TRUE if all elements are NA} 13 | 14 | \item{na.empty}{(TRUE / FALSE) Return TRUE if element is NA} 15 | 16 | \item{trim}{(TRUE / FALSE) Trim empty strings} 17 | } 18 | \value{ 19 | A Boolean indicating empty elements in a vector, if all.na = FALSE 20 | a TRUE/FALSE value will be returned for each element in the vector 21 | } 22 | \description{ 23 | evaluates empty elements in a vector 24 | } 25 | \details{ 26 | This function evaluates if an element in a vector is empty the na.empty argument 27 | allows for evaluating NA values (TRUE if NA) and all.na returns a TRUE if all elements 28 | are NA. The trim argument trims a character string to account for the fact that c(" ") 29 | is not empty but, a vector with c("") is empty. Using trim = TRUE will force both 30 | to return TRUE 31 | } 32 | \examples{ 33 | is.empty( c("") ) 34 | is.empty( c(" ") ) 35 | is.empty( c(" "), trim=FALSE ) 36 | 37 | is.empty( c("",NA,1) ) 38 | is.empty( c("",NA,1), na.empty=FALSE) 39 | 40 | is.empty( c(NA,NA,NA) ) 41 | is.empty( c(NA,NA,NA), all.na=TRUE ) 42 | is.empty( c(NA,2,NA), all.na=TRUE ) 43 | 44 | any( is.empty( c("",2,3) ) ) 45 | any( is.empty( c(1,2,3) ) ) 46 | 47 | } 48 | \author{ 49 | Jeffrey S. Evans 50 | } 51 | -------------------------------------------------------------------------------- /man/kl.divergence.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/kl.divergence.R 3 | \name{kl.divergence} 4 | \alias{kl.divergence} 5 | \title{Kullback-Leibler divergence (relative entropy)} 6 | \usage{ 7 | kl.divergence(object, eps = 10^-4, overlap = TRUE) 8 | } 9 | \arguments{ 10 | \item{object}{Matrix or dataframe object with >=2 columns} 11 | 12 | \item{eps}{Probabilities below this threshold are replaced by this 13 | threshold for numerical stability.} 14 | 15 | \item{overlap}{Logical, do not determine the KL divergence for those 16 | pairs where for each point at least one of the densities 17 | has a value smaller than eps.} 18 | } 19 | \value{ 20 | pairwise Kullback-Leibler divergence index (matrix) 21 | } 22 | \description{ 23 | Calculates the Kullback-Leibler divergence (relative entropy) 24 | } 25 | \details{ 26 | Calculates the Kullback-Leibler divergence (relative entropy) between 27 | unweighted theoretical component distributions. Divergence is calculated 28 | as: int [f(x) (log f(x) - log g(x)) dx] for distributions with densities 29 | f() and g(). 30 | } 31 | \examples{ 32 | x <- seq(-3, 3, length=200) 33 | y <- cbind(n=dnorm(x), t=dt(x, df=10)) 34 | matplot(x, y, type='l') 35 | kl.divergence(y) 36 | 37 | # extract value for last column 38 | kl.divergence(y[,1:2])[3:3] 39 | 40 | } 41 | \references{ 42 | Kullback S., and R. A. Leibler (1951) On information and sufficiency. 43 | The Annals of Mathematical Statistics 22(1):79-86 44 | } 45 | \author{ 46 | Jeffrey S. Evans 47 | } 48 | -------------------------------------------------------------------------------- /man/local.min.max.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/local.min.max.R 3 | \name{local.min.max} 4 | \alias{local.min.max} 5 | \title{Local minimum and maximum} 6 | \usage{ 7 | local.min.max(x, dev = mean, plot = TRUE, add.points = FALSE, ...) 8 | } 9 | \arguments{ 10 | \item{x}{A numeric vector} 11 | 12 | \item{dev}{Deviation statistic (mean or median)} 13 | 14 | \item{plot}{plot the minimum and maximum values with the 15 | distribution (TRUE/FALSE)} 16 | 17 | \item{add.points}{Should all points of x be added to 18 | plot (TRUE/FALSE)} 19 | 20 | \item{...}{Arguments passed to plot} 21 | } 22 | \value{ 23 | A list object with: 24 | \itemize{ 25 | \item minima - minimum local values of x 26 | \item maxima - maximum local values of x 27 | \item mindev - Absolute deviation of minimum from specified deviation 28 | statistic (dev argument) 29 | \item maxdev - Absolute deviation of maximum from specified deviation 30 | statistic (dev argument) 31 | } 32 | } 33 | \description{ 34 | Calculates the local minimums and maximums in a numeric vector, 35 | indicating inflection points in the distribution. 36 | } 37 | \details{ 38 | Useful function for identifying inflection or enveloping points in 39 | a distribution 40 | } 41 | \examples{ 42 | 43 | x <- rnorm(100,mean=1500,sd=800) 44 | ( lmm <- local.min.max(x, dev=mean, add.points=TRUE, 45 | main="Local Minima and Maxima") ) 46 | 47 | # return only local minimum values 48 | local.min.max(x)$minima 49 | 50 | } 51 | \author{ 52 | Jeffrey S. Evans \href{mailto:jeffrey_evans@tnc.org}{jeffrey_evans@tnc.org} 53 | } 54 | -------------------------------------------------------------------------------- /man/loess.ci.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/loess.ci.R 3 | \name{loess.ci} 4 | \alias{loess.ci} 5 | \title{Loess with confidence intervals} 6 | \usage{ 7 | loess.ci(y, x, p = 0.95, plot = FALSE, ...) 8 | } 9 | \arguments{ 10 | \item{y}{Dependent variable, vector} 11 | 12 | \item{x}{Independent variable, vector} 13 | 14 | \item{p}{Percent confidence intervals (default is 0.95)} 15 | 16 | \item{plot}{Plot the fit and confidence intervals} 17 | 18 | \item{...}{Arguments passed to loess} 19 | } 20 | \value{ 21 | A list object with: 22 | \itemize{ 23 | \item loess Predicted values 24 | \item se Estimated standard error for each predicted value 25 | \item lci Lower confidence interval 26 | \item uci Upper confidence interval 27 | \item df Estimated degrees of freedom 28 | \item rs Residual scale of residuals used in computing the 29 | standard errors 30 | } 31 | } 32 | \description{ 33 | Calculates a local polynomial regression fit 34 | with associated confidence intervals 35 | } 36 | \examples{ 37 | x <- seq(-20, 20, 0.1) 38 | y <- sin(x)/x + rnorm(length(x), sd=0.03) 39 | p <- which(y == "NaN") 40 | y <- y[-p] 41 | x <- x[-p] 42 | 43 | opar <- par(no.readonly=TRUE) 44 | par(mfrow=c(2,2)) 45 | lci <- loess.ci(y, x, plot=TRUE, span=0.10) 46 | lci <- loess.ci(y, x, plot=TRUE, span=0.30) 47 | lci <- loess.ci(y, x, plot=TRUE, span=0.50) 48 | lci <- loess.ci(y, x, plot=TRUE, span=0.80) 49 | par(opar) 50 | 51 | } 52 | \references{ 53 | W. S. Cleveland, E. Grosse and W. M. Shyu (1992) Local regression models. 54 | Chapter 8 of Statistical Models in S eds J.M. Chambers and T.J. Hastie, 55 | Wadsworth & Brooks/Cole. 56 | } 57 | \author{ 58 | Jeffrey S. Evans \href{mailto:jeffrey_evans@tnc.org}{jeffrey_evans@tnc.org} 59 | } 60 | -------------------------------------------------------------------------------- /man/max_extent.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/max_extent.R 3 | \name{max_extent} 4 | \alias{max_extent} 5 | \title{Maximum extent of multiple rasters} 6 | \usage{ 7 | max_extent(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{terra SpatRaster class object} 11 | 12 | \item{...}{additional SpatRaster class objects in same projection} 13 | } 14 | \value{ 15 | An sf POLYGON class object representing maximum extents 16 | } 17 | \description{ 18 | returns a extent polygon representing maximum extent of 19 | input rasters 20 | } 21 | \details{ 22 | Creates a maximum extent polygon of all specified rasters 23 | } 24 | \examples{ 25 | library(terra) 26 | 27 | r1 <- rast(ext(61.87125, 76.64458, 23.90153, 37.27042)) 28 | r2 <- rast(ext(67.66625, 81.56847, 20.38458, 35.67347)) 29 | r3 <- rast(ext(72.64792,84.38125,5.91125,28.13347 )) 30 | 31 | ( e <- max_extent(r1, r2, r3) ) 32 | plot(e, border=NA) 33 | plot(ext(r1), border="red", add=TRUE) 34 | plot(ext(r2), border="green", add=TRUE) 35 | plot(ext(r3), border="blue", add=TRUE) 36 | plot(e, border="black", add=TRUE) 37 | 38 | sf::st_bbox(e) # full extent 39 | 40 | } 41 | \author{ 42 | Jeffrey S. Evans 43 | } 44 | -------------------------------------------------------------------------------- /man/mean_angle.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/mean_angle.R 3 | \name{mean_angle} 4 | \alias{mean_angle} 5 | \title{Mean Angle} 6 | \usage{ 7 | mean_angle(a, angle = c("degree", "radians")) 8 | } 9 | \arguments{ 10 | \item{a}{vector of angle values} 11 | 12 | \item{angle}{("degree", "radians") to define angle in degrees or radians} 13 | } 14 | \value{ 15 | A vector of mean angle 16 | } 17 | \description{ 18 | Calculates the mean angle of a vector 19 | } 20 | \details{ 21 | The arithmetic mean is not correct for calculating the central tendency of 22 | angles. This function is intended to return the mean angle for slope or aspect, 23 | which could be used in a focal or zonal function. 24 | } 25 | \examples{ 26 | library(terra) 27 | mean_angle(c(180, 10)) 28 | mean(c(180, 10)) 29 | mean_angle(c(90, 180, 70, 60)) 30 | mean(c(90, 180, 70, 60)) 31 | mean_angle(c(90, 180, 270, 360)) 32 | mean(c(90, 180, 270, 360)) 33 | 34 | elev <- rast(system.file("extdata/elev.tif", package="spatialEco")) 35 | asp <- terrain(elev, v="aspect") 36 | s <- buffer(spatSample(asp, 20, as.points=TRUE, 37 | na.rm=TRUE, values=FALSE), 5000) 38 | 39 | plot(asp) 40 | plot(s, add=TRUE) 41 | 42 | d <- extract(asp, s) 43 | cat("Mean angles of aspect", "\n") 44 | tapply(d[,2], d[,1], mean_angle) 45 | cat("arithmetic means of aspect", "\n") 46 | tapply(d[,2], d[,1], mean, na.rm=TRUE) 47 | 48 | } 49 | \author{ 50 | Jeffrey S. Evans 51 | } 52 | -------------------------------------------------------------------------------- /man/moments.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/moments.R 3 | \name{moments} 4 | \alias{moments} 5 | \title{moments} 6 | \usage{ 7 | moments(x, plot = FALSE) 8 | } 9 | \arguments{ 10 | \item{x}{numeric vector} 11 | 12 | \item{plot}{plot of distribution (TRUE/FALSE)} 13 | } 14 | \value{ 15 | A vector with the following values: 16 | \itemize{ 17 | \item min Minimum 18 | \item 25th 25th percentile 19 | \item mean Arithmetic mean 20 | \item gmean Geometric mean 21 | \item hmean Harmonic mean 22 | \item median 50th percentile 23 | \item 7th5 75th percentile 24 | \item max Maximum 25 | \item stdv Standard deviation 26 | \item var Variance 27 | \item cv Coefficient of variation (percent) 28 | \item mad Median absolute deviation 29 | \item skew Skewness 30 | \item kurt Kurtosis 31 | \item nmodes Number of modes 32 | \item mode Mode (dominate) 33 | } 34 | } 35 | \description{ 36 | Calculate statistical moments of a distribution 37 | } 38 | \examples{ 39 | x <- runif(1000,0,100) 40 | ( d <- moments(x, plot=TRUE) ) 41 | ( mode.x <- moments(x, plot=FALSE)[16] ) 42 | 43 | } 44 | \author{ 45 | Jeffrey S. Evans \href{mailto:jeffrey_evans@tnc.org}{jeffrey_evans@tnc.org} 46 | } 47 | -------------------------------------------------------------------------------- /man/nth.values.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/nth.values.R 3 | \name{nth.values} 4 | \alias{nth.values} 5 | \title{Nth values} 6 | \usage{ 7 | nth.values(x, N = 2, smallest = FALSE) 8 | } 9 | \arguments{ 10 | \item{x}{Numeric vector} 11 | 12 | \item{N}{Number of (Nth) values returned} 13 | 14 | \item{smallest}{(FALSE/TRUE) Return the highest, else smallest values} 15 | } 16 | \value{ 17 | Numeric vector of Nth values 18 | } 19 | \description{ 20 | Returns the Nth highest or lowest values in a vector 21 | } 22 | \details{ 23 | This function returns n lowest or highest elements in a vector 24 | } 25 | \examples{ 26 | nth.values(1:20, N=3, smallest = TRUE) 27 | nth.values(1:20, N=3) 28 | 29 | } 30 | \author{ 31 | Jeffrey S. Evans 32 | } 33 | -------------------------------------------------------------------------------- /man/oli.aws.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/oli.aws.R 3 | \name{oli.aws} 4 | \alias{oli.aws} 5 | \title{Query AWS-OLI} 6 | \usage{ 7 | oli.aws(...) 8 | } 9 | \arguments{ 10 | \item{...}{not used} 11 | } 12 | \description{ 13 | Query of Amazon AWS OLI-Landsat 8 cloud service 14 | } 15 | \details{ 16 | Given the changes to AWS Registry of Open Data, using the data 17 | digest is no longer reliable. Plese use the AWS Data Exchange 18 | or a STAC API for data acccess 19 | } 20 | -------------------------------------------------------------------------------- /man/optimal.k.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/optimal.k.R 3 | \name{optimal.k} 4 | \alias{optimal.k} 5 | \title{optimalK} 6 | \usage{ 7 | optimal.k(x, nk = 10, plot = TRUE, cluster = TRUE, clara = FALSE, ...) 8 | } 9 | \arguments{ 10 | \item{x}{Numeric dataframe, matrix or vector} 11 | 12 | \item{nk}{Number of clusters to test (2:nk)} 13 | 14 | \item{plot}{(TRUE / FALSE) Plot cluster silhouettes(TRUE/FALSE)} 15 | 16 | \item{cluster}{(TRUE / FALSE) Create cluster object with optimal k} 17 | 18 | \item{clara}{(FALSE / TRUE) Use clara model for large data} 19 | 20 | \item{...}{Additional arguments passed to clara} 21 | } 22 | \value{ 23 | Object of class clust "pam" or "clara" with tested silhouette values 24 | } 25 | \description{ 26 | Find optimal k of k-Medoid partitions using 27 | silhouette widths 28 | } 29 | \examples{ 30 | if (require(cluster, quietly = TRUE)) { 31 | x <- rbind(cbind(rnorm(10,0,0.5), rnorm(10,0,0.5)), 32 | cbind(rnorm(15,5,0.5), rnorm(15,5,0.5))) 33 | 34 | clust <- optimal.k(x, 20, plot=TRUE, cluster=TRUE) 35 | plot(silhouette(clust$model), col = c('red', 'green')) 36 | plot(clust$model, which.plots=1, main='K-Medoid fit') 37 | 38 | # Extract multivariate and univariate mediods (class centers) 39 | clust$model$medoids 40 | pam(x[,1], 1)$medoids 41 | 42 | # join clusters to data 43 | x <- data.frame(x, k=clust$model$clustering) 44 | 45 | } else { 46 | cat("Please install cluster package to run example", "\n") 47 | } 48 | 49 | } 50 | \references{ 51 | Theodoridis, S. & K. Koutroumbas(2006) Pattern Recognition 3rd ed. 52 | } 53 | \seealso{ 54 | \code{\link[cluster]{pam}} for details on Partitioning Around Medoids (PAM) 55 | 56 | \code{\link[cluster]{clara}} for details on Clustering Large Applications (clara) 57 | } 58 | \author{ 59 | Jeffrey S. Evans tnc.org> 60 | } 61 | -------------------------------------------------------------------------------- /man/optimized.sample.variance.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/optimized.sample.variance.R 3 | \name{optimized.sample.variance} 4 | \alias{optimized.sample.variance} 5 | \title{Optimized sample variance} 6 | \usage{ 7 | optimized.sample.variance(x, n, type = "maximized") 8 | } 9 | \arguments{ 10 | \item{x}{A vector to draw a sample from} 11 | 12 | \item{n}{Number of samples to draw} 13 | 14 | \item{type}{Type of sample variance optimization 15 | c("maximized", "minimized")} 16 | } 17 | \value{ 18 | A data.frame with "idx" representing the index of the original vector 19 | and "y" is the value of the sampled data 20 | } 21 | \description{ 22 | Draws an optimal sample that minimizes or maximizes the sample variance 23 | } 24 | \examples{ 25 | library(sf) 26 | if (require(sp, quietly = TRUE)) { 27 | data(meuse, package = "sp") 28 | meuse <- st_as_sf(meuse, coords = c("x", "y"), crs = 28992, agr = "constant") 29 | 30 | n = 15 31 | # Draw n samples that maximize the variance of y 32 | ( max.sv <- optimized.sample.variance(meuse$zinc, 15) ) 33 | 34 | # Draw n samples that minimize the variance of y 35 | ( min.sv <- optimized.sample.variance(meuse$zinc, 15, 36 | type="minimized") ) 37 | 38 | # Plot results 39 | plot(st_geometry(meuse), pch=19, col="grey") 40 | plot(st_geometry(meuse[max.sv$idx,]), col="red", add=TRUE, pch=19) 41 | plot(st_geometry(meuse[min.sv$idx,]), col="blue", add=TRUE, pch=19) 42 | box() 43 | legend("topleft", legend=c("population","maximized variance", 44 | "minimized variance"), col=c("grey","red","blue"), 45 | pch=c(19,19,19)) 46 | 47 | } else { 48 | cat("Please install sp package to run example", "\n") 49 | } 50 | } 51 | \author{ 52 | Jeffrey S. Evans 53 | } 54 | -------------------------------------------------------------------------------- /man/outliers.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/outliers.R 3 | \name{outliers} 4 | \alias{outliers} 5 | \title{Outliers} 6 | \usage{ 7 | outliers(x, s = 1.4826) 8 | } 9 | \arguments{ 10 | \item{x}{A numeric vector} 11 | 12 | \item{s}{Scaling factor for mad statistic} 13 | } 14 | \value{ 15 | value for the modified Z-score 16 | } 17 | \description{ 18 | Identify outliers using modified Z-score 19 | } 20 | \examples{ 21 | # Create data with 3 outliers 22 | x <- seq(0.1, 5, length=100) 23 | x[98:100] <- c(100, 55, 250) 24 | 25 | # Calculate Z score 26 | Z <- outliers(x) 27 | 28 | # Show number of extreme outliers using Z-score 29 | length(Z[Z > 9.9]) 30 | 31 | # Remove extreme outliers 32 | x <- x[-which(Z > 9.9)] 33 | 34 | } 35 | \references{ 36 | Iglewicz, B. & D.C. Hoaglin (1993) How to Detect and Handle Outliers, 37 | American Society for Quality Control, Milwaukee, WI. 38 | } 39 | \author{ 40 | Jeffrey S. Evans 41 | } 42 | -------------------------------------------------------------------------------- /man/overlap.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/overlap.R 3 | \name{overlap} 4 | \alias{overlap} 5 | \title{Niche overlap (Warren's-I)} 6 | \usage{ 7 | overlap(x, y) 8 | } 9 | \arguments{ 10 | \item{x}{A matrix or SpatRaster raster class object} 11 | 12 | \item{y}{A matrix or SpatRaster raster class object 13 | with the same dimensions of x} 14 | } 15 | \value{ 16 | A vector (single value) representing the I similarity statistic 17 | } 18 | \description{ 19 | Similarity Statistic for Quantifying Niche Overlap using Warren's-I 20 | } 21 | \details{ 22 | The overlap function computes the I similarity statistic (Warren et al. 2008) 23 | of two overlapping niche estimates. Similarity is based on the Hellenger distance. 24 | It is assumed that the input data share the same extent and cellsize and all values 25 | are positive. 26 | 27 | The I similarity statistic sums the pair-wise differences between two 28 | predictions to create a single value representing the similarity of the two 29 | distributions. The I similarity statistic ranges from a value of 0, where 30 | two distributions have no overlap, to 1 where two distributions are 31 | identical (Warren et al., 2008). The function is based on code 32 | from Jeremy VanDerWal 33 | } 34 | \examples{ 35 | 36 | # add degree of separation in two matrices 37 | p1 <- abs(matrix(1:50,nr=50,nc=50) + 38 | runif(n = 2500, min = -1, max = 1)) 39 | p2 <- abs(matrix(1:50,nr=50,nc=50) + 40 | rnorm(n = 2500, mean = 1, sd = 1)) 41 | 42 | # High overlap/similarity 43 | ( I <- overlap(p1,p2) ) 44 | 45 | } 46 | \references{ 47 | Warren, D. L., R. E. Glor, M. Turelli, and D. Funk. (2008). 48 | Environmental Niche Equivalency versus Conservatism: Quantitative 49 | Approaches to Niche Evolution. Evolution 62:2868-2883. 50 | } 51 | \author{ 52 | Jeffrey Evans and Jeremy VanDerWal 53 | } 54 | -------------------------------------------------------------------------------- /man/parea.sample.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/parea.sample.R 3 | \name{parea.sample} 4 | \alias{parea.sample} 5 | \title{Percent area sample} 6 | \usage{ 7 | parea.sample(x, pct = 0.1, join = FALSE, sf = 4046.86, stype = "random", ...) 8 | } 9 | \arguments{ 10 | \item{x}{An sf POLYGON object} 11 | 12 | \item{pct}{Percent of area sampled} 13 | 14 | \item{join}{{FALSE/TRUE} Join polygon attributed to point sample} 15 | 16 | \item{sf}{Scaling factor (default is meters to acres conversion factor)} 17 | 18 | \item{stype}{Sampling type ('random', 'regular', 'nonaligned', 'hexagonal')} 19 | 20 | \item{...}{Additional arguments passed to spsample} 21 | } 22 | \value{ 23 | An sf POINT object 24 | } 25 | \description{ 26 | Creates a point sample of polygons where n is based 27 | on percent area 28 | } 29 | \details{ 30 | This function results in an adaptive sample based on the area of 31 | each polygon. The default scaling factor (sf) converts meters to 32 | acres. You can set sf=1 to stay in the native projection units 33 | } 34 | \examples{ 35 | library(sf) 36 | nc <- st_read(system.file("shape/nc.shp", package="sf")) 37 | nc <- suppressWarnings(st_cast(nc[c(10,100),], "POLYGON")) 38 | 39 | ( ars <- parea.sample(nc, pct=0.001, join = TRUE, stype='random') ) 40 | plot(st_geometry(nc)) 41 | plot(st_geometry(ars), pch=19, add=TRUE) 42 | 43 | } 44 | \author{ 45 | Jeffrey S. Evans 46 | } 47 | -------------------------------------------------------------------------------- /man/plot.effect.size.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plot.effect.size.R 3 | \name{plot.effect.size} 4 | \alias{plot.effect.size} 5 | \title{Plot effect size} 6 | \usage{ 7 | \method{plot}{effect.size}(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{A effect.size object} 11 | 12 | \item{...}{Additional arguments passed to plot} 13 | } 14 | \value{ 15 | Plot of effect size object with group effect sizes and 95% confidence 16 | } 17 | \description{ 18 | Plot function for effect.size object 19 | } 20 | \author{ 21 | Jeffrey S. Evans 22 | } 23 | -------------------------------------------------------------------------------- /man/plot.loess.boot.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plot.loess.boot.R 3 | \name{plot.loess.boot} 4 | \alias{plot.loess.boot} 5 | \title{Plot Loess Bootstrap} 6 | \usage{ 7 | \method{plot}{loess.boot}(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{A loess.boot object} 11 | 12 | \item{...}{Additional arguments passed to plot} 13 | } 14 | \value{ 15 | plot of lowess bootstrap 16 | } 17 | \description{ 18 | Plot function for loess.boot object 19 | } 20 | \examples{ 21 | n=1000 22 | x <- seq(0, 4, length.out=n) 23 | y <- sin(2*x)+ 0.5*x + rnorm(n, sd=0.5) 24 | sb <- loess.boot(x, y, nreps = 99, confidence = 0.90, span = 0.40) 25 | plot(sb) 26 | 27 | } 28 | \author{ 29 | Jeffrey S. Evans 30 | } 31 | -------------------------------------------------------------------------------- /man/polyPerimeter.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/polyPerimeter.R 3 | \name{polyPerimeter} 4 | \alias{polyPerimeter} 5 | \title{Polygon perimeter} 6 | \usage{ 7 | polyPerimeter(x) 8 | } 9 | \arguments{ 10 | \item{x}{sf POLYGON class object} 11 | } 12 | \value{ 13 | A vector of polygon perimeters in projection units 14 | } 15 | \description{ 16 | Calculates the perimeter length(s) for a polygon object 17 | } 18 | \examples{ 19 | library(sf) 20 | polys <- st_read(system.file("shape/nc.shp", package="sf")) 21 | polys <- suppressWarnings(st_cast(polys[c(10,100),], "POLYGON")) 22 | 23 | polyPerimeter(polys) 24 | 25 | } 26 | \author{ 27 | Jeffrey S. Evans 28 | } 29 | -------------------------------------------------------------------------------- /man/poly_trend.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/poly_trend.R 3 | \name{poly_trend} 4 | \alias{poly_trend} 5 | \title{Polynomial trend} 6 | \usage{ 7 | poly_trend(x, y, degree, ci = 0.95, plot = TRUE, ...) 8 | } 9 | \arguments{ 10 | \item{x}{Vector of x} 11 | 12 | \item{y}{Vector of y} 13 | 14 | \item{degree}{Polynomial order (default 3)} 15 | 16 | \item{ci}{+/- confidence interval (default 0.95)} 17 | 18 | \item{plot}{Plot results (TRUE/FALSE)} 19 | 20 | \item{...}{Additional arguments passed to plot} 21 | } 22 | \value{ 23 | A poly.trend class (list) containing 24 | \itemize{ 25 | \item trend data.frame of fit polynomial and upper/lower confidence intervals 26 | \item model Class lm model object fit with poly term 27 | \item prameterCI Intercept confidence intervals of Nth order polynomials 28 | \item order Specified polynomial order 29 | } 30 | } 31 | \description{ 32 | Fits a polynomial trend using specified order 33 | } 34 | \details{ 35 | A fit using a lm(y ~ x + I(X^2) + I(X^3)) form will be correlated which, 36 | can cause problems. The function avoids undue correlation using orthogonal 37 | polynomials 38 | } 39 | \examples{ 40 | set.seed(42) 41 | x <- seq(from=0, to=20, by=0.1) 42 | y <- (500 + 0.4 * (x-10)^3) 43 | noise <- y + rnorm(length(x), mean=10, sd=80) 44 | 45 | p <- poly_trend(x, noise, degree = 3, ci = 0.95, 46 | main="3rd degree polynomial") 47 | 48 | dev.new(height=6, width=12) 49 | layout(matrix(c(1,2), 1, 2, byrow = TRUE)) 50 | p <- poly_trend(x, noise, degree = 3, 51 | main="3rd degree polynomial") 52 | p <- poly_trend(x, noise, degree = 6, 53 | main="6th degree polynomial") 54 | 55 | cat("Confidence intervals for", "1 -", p$order, "polynomials", "\n") 56 | p$prameterCI 57 | 58 | } 59 | \author{ 60 | Jeffrey S. Evans \href{mailto:jeffrey_evans@tnc.org}{jeffrey_evans@tnc.org} 61 | } 62 | -------------------------------------------------------------------------------- /man/print.cross.cor.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/print.cross.cor.R 3 | \name{print.cross.cor} 4 | \alias{print.cross.cor} 5 | \title{Print spatial cross correlation} 6 | \usage{ 7 | \method{print}{cross.cor}(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{Object of class cross.cor} 11 | 12 | \item{...}{Ignored} 13 | } 14 | \value{ 15 | When not simulated k=0, prints functions list object containing: 16 | \itemize{ 17 | \item I - Global autocorrelation statistic 18 | \item SCI - - A data.frame with two columns representing the xy and yx autocorrelation 19 | \item nsim - value of NULL to represent p values were derived from observed data (k=0) 20 | \item p - Probability based observations above/below confidence interval 21 | \item t.test - Probability based on t-test 22 | } 23 | 24 | When simulated (k>0), prints functions list object containing: 25 | \itemize{ 26 | \item I - Global autocorrelation statistic 27 | \item SCI - A data.frame with two columns representing the xy and yx autocorrelation 28 | \item nsim - value representing number of simulations 29 | \item global.p - p-value of global autocorrelation statistic 30 | \item local.p - Probability based simulated data using successful rejection of t-test 31 | \item range.p - Probability based on range of probabilities resulting from paired t-test 32 | } 33 | } 34 | \description{ 35 | print method for class "cross.cor" 36 | } 37 | -------------------------------------------------------------------------------- /man/print.effect.size.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/print.effect.size.R 3 | \name{print.effect.size} 4 | \alias{print.effect.size} 5 | \title{Print effect size} 6 | \usage{ 7 | \method{print}{effect.size}(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{Object of class effect.size} 11 | 12 | \item{...}{Ignored} 13 | } 14 | \value{ 15 | Prints the output data.frame contaning; effect size with upper and lower confidence 16 | and, mean and sd by group 17 | } 18 | \description{ 19 | print method for class "effect.size" 20 | } 21 | -------------------------------------------------------------------------------- /man/print.loess.boot.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/print.loess.boot.R 3 | \name{print.loess.boot} 4 | \alias{print.loess.boot} 5 | \title{Print Loess bootstrap model} 6 | \usage{ 7 | \method{print}{loess.boot}(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{Object of class loess.boot} 11 | 12 | \item{...}{Ignored} 13 | } 14 | \value{ 15 | same as summary lowess.boot of data.frame including; 16 | \itemize{ 17 | \item nreps Number of bootstrap replicates 18 | \item confidence Confidence interval (region) 19 | \item span alpha (span) parameter used loess fit 20 | \item degree polynomial degree used in loess fit 21 | \item normalize Normalized data (TRUE/FALSE) 22 | \item family Family of statistic used in fit 23 | \item parametric Parametric approximation (TRUE/FALSE) 24 | \item surface Surface fit, see loess.control 25 | \item data data.frame of x,y used in model 26 | \item fit data.frame including: 27 | \enumerate{ 28 | \item x - Equally-spaced x index 29 | \item y.fit - loess fit 30 | \item up.lim - Upper confidence interval 31 | \item low.lim - Lower confidence interval 32 | \item stddev - Standard deviation of loess fit at each x value 33 | } 34 | } 35 | } 36 | \description{ 37 | print method for class "loess.boot" 38 | } 39 | -------------------------------------------------------------------------------- /man/print.poly.trend.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/print.poly.trend.R 3 | \name{print.poly.trend} 4 | \alias{print.poly.trend} 5 | \title{Print poly_trend} 6 | \usage{ 7 | \method{print}{poly.trend}(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{Object of class poly.trend} 11 | 12 | \item{...}{Ignored} 13 | } 14 | \value{ 15 | Prints trend model summary, order and trend confidence intervals 16 | } 17 | \description{ 18 | print method for class "poly.trend" 19 | } 20 | -------------------------------------------------------------------------------- /man/quadrats.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/quadrats.R 3 | \name{quadrats} 4 | \alias{quadrats} 5 | \title{Quadrats} 6 | \usage{ 7 | quadrats(x, s = 250, n = 100, r = NULL, sp = FALSE) 8 | } 9 | \arguments{ 10 | \item{x}{An sf POLYGONS object defining extent} 11 | 12 | \item{s}{Radius defining single or range of sizes of quadrats} 13 | 14 | \item{n}{Number of quadrats} 15 | 16 | \item{r}{A rotation factor for random rotation, default is NULL} 17 | 18 | \item{sp}{(FALSE | TRUE) Output sp class object} 19 | } 20 | \value{ 21 | an sf POLYGONS object with rotated polygon(s) 22 | } 23 | \description{ 24 | Creates quadrat polygons for sampling or analysis 25 | } 26 | \details{ 27 | The radius (s) parameter can be a single value or a range of values, 28 | representing a randomization range of resulting quadrat sizes. The 29 | rotation (r) parameter can also be used to defined a fixed rotation or 30 | random range of quadrat rotations. You can specify each of these parameters 31 | using an explicit vector that will be sampled eg., seq(100,300,0.5) 32 | } 33 | \examples{ 34 | library(sf) 35 | library(terra) 36 | 37 | # read meuse data and create convex hull 38 | if (require(sp, quietly = TRUE)) { 39 | data(meuse, package = "sp") 40 | meuse <- st_as_sf(meuse, coords = c("x", "y"), crs = 28992, agr = "constant") 41 | e <- st_convex_hull(st_union(meuse)) 42 | 43 | # Fixed size 250 and no rotation 44 | s <- quadrats(e, s = 250, n = 10) 45 | plot(st_geometry(s)) 46 | 47 | \donttest{ 48 | # Variable sizes 100-300 and rotation of 0-45 degrees 49 | s <- quadrats(e, s = c(100,300), n = 10, r = c(0,45)) 50 | plot(st_geometry(s)) 51 | 52 | # Variable sizes 100-300 and no rotation 53 | s <- quadrats(e, s = c(100,300), n = 10) 54 | plot(st_geometry(s)) 55 | } 56 | 57 | } else { 58 | cat("Please install sp package to run example", "\n") 59 | } 60 | 61 | } 62 | \author{ 63 | Jeffrey S. Evans 64 | } 65 | -------------------------------------------------------------------------------- /man/raster.Zscore.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/raster.Zscore.R 3 | \name{raster.Zscore} 4 | \alias{raster.Zscore} 5 | \title{Modified z-score for a raster} 6 | \usage{ 7 | raster.Zscore(x, p.value = FALSE, file.name = NULL, ...) 8 | } 9 | \arguments{ 10 | \item{x}{A raster class object} 11 | 12 | \item{p.value}{Return p-value rather than z-score 13 | raster (FALSE/TRUE)} 14 | 15 | \item{file.name}{Name of raster written to disk} 16 | 17 | \item{...}{Additional arguments passed to writeRaster} 18 | } 19 | \value{ 20 | raster class object or raster written to disk 21 | } 22 | \description{ 23 | Calculates the modified z-score for raster values 24 | } 25 | \note{ 26 | Since this functions needs to operate on all of the raster values, 27 | it is not memory safe 28 | } 29 | \examples{ 30 | \donttest{ 31 | library(terra) 32 | r <- rast(nrows=500, ncols=500) 33 | r[] <- runif(ncell(r), 0, 1) 34 | 35 | # Modified z-score 36 | ( z <- raster.Zscore(r) ) 37 | 38 | # P-value 39 | ( p <- raster.Zscore(r, p.value = TRUE) ) 40 | } 41 | 42 | } 43 | \author{ 44 | Jeffrey S. Evans 45 | } 46 | -------------------------------------------------------------------------------- /man/raster.entropy.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/raster.entropy.R 3 | \name{raster.entropy} 4 | \alias{raster.entropy} 5 | \title{Raster Entropy} 6 | \usage{ 7 | raster.entropy(x, d = 5, categorical = FALSE, global = FALSE, ...) 8 | } 9 | \arguments{ 10 | \item{x}{A terra SpatRaster object (requires integer raster)} 11 | 12 | \item{d}{Size of matrix (window)} 13 | 14 | \item{categorical}{Is the data categorical or continuous (FALSE/TRUE)} 15 | 16 | \item{global}{Should the model use a global or local n to calculate 17 | entropy (FALSE/TRUE)} 18 | 19 | \item{...}{Optional arguments passed terra focal function} 20 | } 21 | \value{ 22 | terra SpatRaster class object 23 | } 24 | \description{ 25 | Calculates entropy on integer raster (i.e., 8 bit 0-255) 26 | } 27 | \details{ 28 | Entropy calculated as: H = -sum(Pi*ln(Pi)) where; Pi, Proportion of one value 29 | to total values Pi=n(p)/m and m, Number of unique values. Expected range: 30 | 0 to log(m) H=0 if window contains the same value in all cells. 31 | H increases with the number of different values in the window. The ellipsis 32 | arguments can be used to write to disk using the filename argument. 33 | } 34 | \examples{ 35 | library(terra) 36 | r <- rast(ncols=100, nrows=100) 37 | r[] <- round(runif(ncell(r), 1,8), digits=0) 38 | 39 | rEnt <- raster.entropy(r, d=5, categorical = TRUE, global = TRUE) 40 | opar <- par(no.readonly=TRUE) 41 | par(mfcol=c(2,1)) 42 | plot(r) 43 | plot(rEnt) 44 | par(opar) 45 | 46 | # Maximum entropy is reached when all values are different, same as log(m) 47 | # for example; log( length( unique(x) ) ) 48 | 49 | } 50 | \references{ 51 | Fuchs M., R. Hoffmann, F. Schwonke (2008) Change Detection with GRASS 52 | GIS - Comparison of images taken by different sensor. 53 | } 54 | \author{ 55 | Jeffrey S. Evans 56 | } 57 | -------------------------------------------------------------------------------- /man/raster.gaussian.smooth.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/raster.gaussian.smooth.R 3 | \name{raster.gaussian.smooth} 4 | \alias{raster.gaussian.smooth} 5 | \title{Gaussian smoothing of raster} 6 | \usage{ 7 | raster.gaussian.smooth( 8 | x, 9 | s = 2, 10 | n = 5, 11 | scale = FALSE, 12 | type = c("mean", "median", "sd", "convolution"), 13 | ... 14 | ) 15 | } 16 | \arguments{ 17 | \item{x}{A terra SpatRaster raster object} 18 | 19 | \item{s}{Standard deviation (sigma) of kernel (default is 2)} 20 | 21 | \item{n}{Size of the focal matrix, single value (default is 22 | 5 for 5x5 window)} 23 | 24 | \item{scale}{(FALSE/TRUE) Scale sigma to the resolution of the raster} 25 | 26 | \item{type}{The statistic to use in the smoothing operator; 27 | "mean", "median", "sd", "convolution"} 28 | 29 | \item{...}{Additional arguments passed to terra::focal} 30 | } 31 | \value{ 32 | A terra SpatRaster class object of the local distributional moment 33 | } 34 | \description{ 35 | Applies a Gaussian smoothing kernel to smooth raster. 36 | } 37 | \details{ 38 | This applies a Gaussian Kernel smoother. The convolution option performs 39 | a Gaussian decomposition whereas the other options use the kernel 40 | as weights for the given statistic. 41 | } 42 | \examples{ 43 | library(terra) 44 | elev <- rast(system.file("extdata/elev.tif", package="spatialEco")) 45 | 46 | # Calculate Gaussian smoothing with sigma = 2 and 7x7 window 47 | g1 <- raster.gaussian.smooth(elev, s=2, n=7) 48 | plot(c(elev,g1)) 49 | 50 | } 51 | \author{ 52 | Jeffrey S. Evans 53 | } 54 | -------------------------------------------------------------------------------- /man/raster.invert.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/raster.invert.R 3 | \name{raster.invert} 4 | \alias{raster.invert} 5 | \title{Invert raster} 6 | \usage{ 7 | raster.invert(x) 8 | } 9 | \arguments{ 10 | \item{x}{A terra SpatRaster object} 11 | } 12 | \value{ 13 | A terra SpatRaster object with inverted (flipped) raster values 14 | } 15 | \description{ 16 | Inverts (flip) the values of a raster 17 | } 18 | \details{ 19 | Inverts raster values using the formula: (((x - max(x)) * -1) + min(x) 20 | } 21 | \examples{ 22 | library(terra) 23 | r <- rast(nrows=500, ncols=500, xmin=571823, xmax=616763, 24 | ymin=4423540, ymax=4453690) 25 | crs(r) <- "epsg:9001" 26 | r[] <- runif(ncell(r), 1000, 2500) 27 | r <- focal(r, focalMat(r, 150, "Gauss") ) 28 | 29 | r.inv <- raster.invert(r) 30 | 31 | opar <- par(no.readonly=TRUE) 32 | par(mfrow=c(1,2)) 33 | plot(r, main="original raster") 34 | plot(r.inv, main="inverted raster") 35 | par(opar) 36 | 37 | } 38 | \author{ 39 | Jeffrey S. Evans 40 | } 41 | -------------------------------------------------------------------------------- /man/raster.mds.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/raster.mds.R 3 | \name{raster.mds} 4 | \alias{raster.mds} 5 | \title{Raster multidimensional scaling (MDS)} 6 | \usage{ 7 | raster.mds(r, s = 5, window.median = FALSE, ...) 8 | } 9 | \arguments{ 10 | \item{r}{A terra SpatRaster class object} 11 | 12 | \item{s}{Window size (may be a vector of 1 or 2) of 13 | n x n dimension.} 14 | 15 | \item{window.median}{(FALSE/TRUE) Return the median of the MDS 16 | matrix values.} 17 | 18 | \item{...}{Additional arguments passed to terra::focal} 19 | } 20 | \value{ 21 | A terra SpatRaster class object 22 | } 23 | \description{ 24 | Multidimensional scaling of raster values within an N x N focal window 25 | } 26 | \details{ 27 | An MDS focal function. If only one value provided for s, then a square matrix 28 | (window) will be used. If window.median = FALSE then the center value of the 29 | matrix is returned and not the median of the matrix 30 | } 31 | \examples{ 32 | \donttest{ 33 | library(terra) 34 | r <- rast(system.file("ex/elev.tif", package="terra")) 35 | r <- r[[1]] / max(global(r, "max", na.rm=TRUE)[,1]) 36 | 37 | diss <- raster.mds(r) 38 | diss.med <- raster.mds(r, window.median = TRUE) 39 | 40 | opar <- par(no.readonly=TRUE) 41 | par(mfrow=c(2,2)) 42 | plot(r) 43 | title("Elevation") 44 | plot( focal(r, w = matrix(1, nrow=5, ncol=5), fun = var) ) 45 | title("Variance") 46 | plot(diss) 47 | title("MDS") 48 | plot(diss.med) 49 | title("Median MDS") 50 | par(opar) 51 | } 52 | 53 | } 54 | \references{ 55 | Quinn, G.P., & M.J. Keough (2002) Experimental design and data analysis 56 | for biologists. Cambridge University Press. Ch. 18. Multidimensional 57 | scaling and cluster analysis. 58 | } 59 | \author{ 60 | Jeffrey S. Evans 61 | } 62 | -------------------------------------------------------------------------------- /man/raster.moments.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/raster.moments.R 3 | \name{raster.moments} 4 | \alias{raster.moments} 5 | \title{Raster moments} 6 | \usage{ 7 | raster.moments(x, type = "mean", s = 3, p = 0.75, ...) 8 | } 9 | \arguments{ 10 | \item{x}{A terra SpatRaster object} 11 | 12 | \item{type}{The global statistic to represent the local deviation 13 | options are: "min", "min", "mean", "median", "var, "sd", 14 | "mad", "kurt", "skew", "quantile"} 15 | 16 | \item{s}{Size of matrix (focal window), can be single value or two 17 | values defining the [x,y] dimensions of the focal matrix} 18 | 19 | \item{p}{if type="quantile", the returned percentile.} 20 | 21 | \item{...}{Additional arguments passed to terra::focal} 22 | } 23 | \value{ 24 | A terra SpatRaster object representing the local distributional moment 25 | } 26 | \description{ 27 | Calculates focal statistical moments of a raster 28 | } 29 | \details{ 30 | This is a simple wrapper for the terra focal function, returning local statistical moments 31 | } 32 | \examples{ 33 | \donttest{ 34 | library(terra) 35 | r <- rast(nrows=500, ncols=500, xmin=571823, xmax=616763, 36 | ymin=4423540, ymax=4453690) 37 | crs(r) <- "epsg:9001" 38 | r[] <- runif(ncell(r), 1000, 2500) 39 | 40 | # Calculate 10th percentile for 3x3 window 41 | r.p10 <- raster.moments(r, type="quantile", p=0.10) 42 | } 43 | 44 | } 45 | \author{ 46 | Jeffrey S. Evans 47 | } 48 | -------------------------------------------------------------------------------- /man/raster.vol.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/raster.vol.R 3 | \name{raster.vol} 4 | \alias{raster.vol} 5 | \title{Raster Percent Volume} 6 | \usage{ 7 | raster.vol( 8 | x, 9 | p = 0.75, 10 | sample = FALSE, 11 | spct = 0.05, 12 | type = c("random", "regular") 13 | ) 14 | } 15 | \arguments{ 16 | \item{x}{A terra SpatRaster class object} 17 | 18 | \item{p}{percent raster-value volume} 19 | 20 | \item{sample}{(FALSE/TRUE) base volume on systematic point sample} 21 | 22 | \item{spct}{sample percent, if sample (TRUE)} 23 | 24 | \item{type}{If sample=TRUE type of sample, options are "random" or "regular"} 25 | } 26 | \value{ 27 | if sample (FALSE) binary raster object with 1 representing designated 28 | percent volume else, if sample (TRUE) n sf POINT object with points 29 | that represent the percent volume of the sub-sample 30 | } 31 | \description{ 32 | Calculates a percent volume on a raster or based on a 33 | systematic sample 34 | } 35 | \note{ 36 | Since this model needs to operate on all of the raster values, it is not memory safe 37 | } 38 | \examples{ 39 | \donttest{ 40 | library(terra) 41 | r <- rast(ncols=100, nrows=100) 42 | r[] <- runif(ncell(r), 0, 1) 43 | r <- focal(r, w=focalMat(r, 6, "Gauss")) 44 | #r[sample(1:ncell(r)),10] <- NA 45 | 46 | # full raster percent volume 47 | p30 <- raster.vol(r, p=0.30) 48 | p50 <- raster.vol(r, p=0.50) 49 | p80 <- raster.vol(r, p=0.80) 50 | 51 | opar <- par(no.readonly=TRUE) 52 | par(mfrow=c(2,2)) 53 | plot(r, col=cm.colors(10), main="original raster") 54 | plot(p30, breaks=c(0,0.1,1), col=c("cyan","red"), legend=FALSE, 55 | main="30\% volume") 56 | plot(p50, breaks=c(0,0.1,1), col=c("cyan","red"), legend=FALSE, 57 | main="50\% volume") 58 | plot(p80, breaks=c(0,0.1,1), col=c("cyan","red"), legend=FALSE, 59 | main="80\% volume") 60 | par(opar) 61 | } 62 | 63 | } 64 | \author{ 65 | Jeffrey S. Evans 66 | } 67 | -------------------------------------------------------------------------------- /man/rasterCorrelation.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rasterCorrelation.R 3 | \name{rasterCorrelation} 4 | \alias{rasterCorrelation} 5 | \title{Raster correlation} 6 | \usage{ 7 | rasterCorrelation(x, y, s = 3, type = "pearson") 8 | } 9 | \arguments{ 10 | \item{x}{A terra SpatRaster class object for x} 11 | 12 | \item{y}{A terra SpatRasterclass object for y} 13 | 14 | \item{s}{Scale of window. Can be a single value, two 15 | values for uneven window or a custom matrix. 16 | Must be odd number (eg., s=3, for 3x3 window or 17 | s=c(3,5) for 3 x 5 window)} 18 | 19 | \item{type}{Type of output, options are: "pearson", "spearman", 20 | "covariance"} 21 | } 22 | \value{ 23 | A terra SpatRaster class object 24 | } 25 | \description{ 26 | Performs a moving window correlation between two rasters 27 | } 28 | \note{ 29 | The NA behavior is set to na.rm = TRUE to make default outputs 30 | consistent between the terra and raster packages. 31 | } 32 | \examples{ 33 | \donttest{ 34 | library(terra) 35 | 36 | r <- rast(system.file("ex/logo.tif", package="terra")) 37 | x <- r[[1]] 38 | y <- r[[3]] 39 | 40 | r.cor <- rasterCorrelation(x, y, s = 5, type = "spearman") 41 | plot(r.cor) 42 | } 43 | 44 | } 45 | \author{ 46 | Jeffrey S. Evans 47 | } 48 | -------------------------------------------------------------------------------- /man/remove.holes.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/remove.holes.R 3 | \name{remove.holes} 4 | \alias{remove.holes} 5 | \title{Remove or return polygon holes} 6 | \usage{ 7 | remove.holes(x, only.holes = FALSE) 8 | } 9 | \arguments{ 10 | \item{x}{sf POLYGON or MULTIPOLYGON object} 11 | 12 | \item{only.holes}{Delete holes (FALSE) or returns only holes (FALSE)} 13 | } 14 | \value{ 15 | sf POLYGON object 16 | } 17 | \description{ 18 | Removes or returns all holes (null geometry) in sf polygon 19 | class objects 20 | } 21 | \details{ 22 | A hole is considered a polygon within a polygon (island) representing null 23 | geometry. If you want to return only holes, no longer NULL, use keep = TRUE. 24 | To delete holes use default only.holes = FALSE. Single part features will be 25 | returned regardless of input. 26 | } 27 | \examples{ 28 | library(sf) 29 | 30 | p <- sf::st_as_sf(sf::st_sfc( 31 | sf::st_polygon(list( 32 | cbind(c(2,4,4,1,2),c(2,3,5,4,2)), 33 | cbind(c(2.33, 2.05, 3.25, 3.25, 2.33), 34 | c(3.00, 3.56, 3.95, 3.46, 3.00)))), 35 | sf::st_polygon(list( 36 | cbind(c(5,4,2,5),c(2,3,2,2)))), 37 | sf::st_polygon(list( 38 | cbind(c(4,4,5,10,4),c(5,3,2,5,5)), 39 | cbind(c(5,6,6,5,5),c(4,4,3,3,4)) 40 | )))) 41 | p$ID <- 1:3 42 | 43 | rh <- remove.holes(p) 44 | kh <- remove.holes(p, only.holes=TRUE) 45 | 46 | opar <- par(no.readonly=TRUE) 47 | par(mfrow=c(2,2)) 48 | plot(st_geometry(p), main="Original with holes") 49 | plot(st_geometry(rh), main="holes removed only.holes=FALSE") 50 | plot(st_geometry(kh), main="return holes only.holes=TRUE") 51 | par(opar) 52 | 53 | } 54 | \author{ 55 | Jeffrey S. Evans 56 | } 57 | -------------------------------------------------------------------------------- /man/remove_duplicates.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/remove_duplicates.R 3 | \name{remove_duplicates} 4 | \alias{remove_duplicates} 5 | \title{Remove duplicate geometries} 6 | \usage{ 7 | remove_duplicates(x, threshold = 0.00001) 8 | } 9 | \arguments{ 10 | \item{x}{An sf POINT, POLYGON or LINESTRING object} 11 | 12 | \item{threshold}{A distance threshold indicating fuzzy duplication, 13 | default i 0.00001} 14 | } 15 | \value{ 16 | sf object, of same feature class as x, with duplicate geometries removed 17 | } 18 | \description{ 19 | Removes duplicate geometries in a single-part feature class 20 | } 21 | \details{ 22 | This function removes duplicate geometries based on order and not "non null" 23 | attribution or other factors, the first feature gets to stay. If one needs to 24 | know which points were removed sf::st_difference can be used between original 25 | data and results of the function. 26 | } 27 | \examples{ 28 | library(sf) 29 | 30 | # data with 10 duplicate obs 31 | s <- data.frame(x = runif(100), y = runif(100)) 32 | s <- data.frame(rbind(s, s[sample(1:nrow(s), 10),]) ) 33 | s <- st_as_sf(s, coords = c("x", "y")) 34 | s$ID <- 1:nrow(s) 35 | 36 | nrow(s) 37 | nrow( srmd <- remove_duplicates(s) ) 38 | 39 | } 40 | \author{ 41 | Jeffrey S. Evans 42 | } 43 | -------------------------------------------------------------------------------- /man/rm.ext.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rm.ext.R 3 | \name{rm.ext} 4 | \alias{rm.ext} 5 | \title{Remove extension} 6 | \usage{ 7 | rm.ext(x) 8 | } 9 | \arguments{ 10 | \item{x}{A character vector representing a file with extension} 11 | } 12 | \value{ 13 | The file name with extension and file path stripped off 14 | } 15 | \description{ 16 | Removes file extension (and path) from string 17 | } 18 | \examples{ 19 | rm.ext("C:/path/file.txt") 20 | 21 | } 22 | -------------------------------------------------------------------------------- /man/rotate.polygon.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rotate.polygon.R 3 | \name{rotate.polygon} 4 | \alias{rotate.polygon} 5 | \title{Rotate polygon} 6 | \usage{ 7 | rotate.polygon( 8 | p, 9 | angle = 45, 10 | sp = FALSE, 11 | anchor = c("center", "lower.left", "upper.right") 12 | ) 13 | } 14 | \arguments{ 15 | \item{p}{A polygon object of sf or sp class} 16 | 17 | \item{angle}{Rotation angle in degrees} 18 | 19 | \item{sp}{(FALSE | TRUE) Output sp class object} 20 | 21 | \item{anchor}{Location to rotate polygon on options are "center", 22 | "lower.left" and "upper.right"} 23 | } 24 | \value{ 25 | an sp or sf polygon object with rotated polygon 26 | } 27 | \description{ 28 | rotates polygon by specified angle 29 | } 30 | \details{ 31 | The anchor is the location that the rotation is anchored to. The center 32 | is the centroid where the lower.left and upper.right are based on the 33 | min or max of the coordinates respectively. 34 | } 35 | \examples{ 36 | library(sf) 37 | 38 | data(meuse, package = "sp") 39 | meuse <- st_as_sf(meuse, coords = c("x", "y"), 40 | crs = 28992, agr = "constant") 41 | 42 | e <- st_convex_hull(st_union(meuse)) 43 | e30 <- rotate.polygon(e, angle=30) 44 | 45 | plot(e, main="rotated 30 degrees") 46 | plot(e30, add=TRUE) 47 | 48 | } 49 | -------------------------------------------------------------------------------- /man/sar.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/sar.R 3 | \name{sar} 4 | \alias{sar} 5 | \title{Surface Area Ratio} 6 | \usage{ 7 | sar(x, s = NULL, scale = TRUE) 8 | } 9 | \arguments{ 10 | \item{x}{A terra SpatRaster object} 11 | 12 | \item{s}{cell resolution (default is NULL and not needed if projection 13 | is in planar units)} 14 | 15 | \item{scale}{(TRUE/FALSE) Scale (row standardize) results} 16 | } 17 | \value{ 18 | A terra SpatRaster class object of the Surface Area Ratio 19 | } 20 | \description{ 21 | Calculates the Berry (2002) Surface Area Ratio based on slope 22 | } 23 | \details{ 24 | SAR is calculated as: resolution^2 * cos( (degrees(slope) * (pi / 180)) ) 25 | } 26 | \examples{ 27 | library(terra) 28 | elev <- rast(system.file("extdata/elev.tif", package="spatialEco")) 29 | ( surface.ratio <- sar(elev) ) 30 | plot(surface.ratio) 31 | 32 | } 33 | \references{ 34 | Berry, J.K. (2002). Use surface area for realistic calculations. Geoworld 15(9):20-1. 35 | } 36 | \author{ 37 | Jeffrey S. Evans 38 | } 39 | -------------------------------------------------------------------------------- /man/shannons.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/shannons.R 3 | \name{shannons} 4 | \alias{shannons} 5 | \title{Shannon's Diversity (Entropy) Index} 6 | \usage{ 7 | shannons(x, counts = TRUE, ens = FALSE, margin = "row") 8 | } 9 | \arguments{ 10 | \item{x}{data.frame object containing counts or proportions} 11 | 12 | \item{counts}{Are data counts (TRUE) or relative proportions (FALSE)} 13 | 14 | \item{ens}{Calculate effective number of species (TRUE/FALSE)} 15 | 16 | \item{margin}{Calculate diversity for rows or columns. c("row", "col")} 17 | } 18 | \value{ 19 | data.frame with "H" (Shannon's diversity) and "evenness" (Shannon's 20 | evenness where H / max( sum(x) ) ) and ESN 21 | } 22 | \description{ 23 | Calculates Shannon's Diversity Index and Shannon's Evenness Index 24 | } 25 | \details{ 26 | The expected for H is 0-3+ where a value of 2 has been suggested as medium-high diversity, 27 | for evenness is 0-1 with 0 signifying no evenness and 1, complete evenness. 28 | } 29 | \examples{ 30 | # Using Costa Rican ant diversity data from Roth et al. (1994) 31 | data(ants) 32 | 33 | # Calculate diversity for each covertype ("col") 34 | shannons(ants[,2:ncol(ants)], ens = TRUE, counts = FALSE, margin = "col") 35 | 36 | # Calculate diversity for each species ("row") 37 | ant.div <- shannons(ants[,2:ncol(ants)], ens = TRUE, counts = FALSE, 38 | margin = "row") 39 | row.names(ant.div) <- ants[,1] 40 | ant.div 41 | 42 | } 43 | \references{ 44 | Shannon, C. E. and W. Weaver (1948) A mathematical theory of communication. The Bell 45 | System Technical Journal, 27:379-423. 46 | 47 | Simpson, E. H. (1949) Measurement of diversity. Nature 163:688 48 | 49 | Roth, D. S., I. Perfecto, and B. Rathcke (1994) The effects of management systems on 50 | ground-foraging ant diversity in Costa Rica. Ecological Applications 4(3):423-436. 51 | } 52 | \author{ 53 | Jeffrey S. Evans 54 | } 55 | -------------------------------------------------------------------------------- /man/shift.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/shift.R 3 | \name{shift} 4 | \alias{shift} 5 | \title{shift} 6 | \usage{ 7 | shift(x, lag = 1, pad = NA) 8 | } 9 | \arguments{ 10 | \item{x}{A vector} 11 | 12 | \item{lag}{Number of lagged offsets, default is 1} 13 | 14 | \item{pad}{Value to fill the lagged offset with, default is NA} 15 | } 16 | \value{ 17 | A vector, length equal to x, with offset length filled with pad values 18 | } 19 | \description{ 20 | Shift a vector by specified positive or negative lag 21 | } 22 | \examples{ 23 | x <- 1:10 24 | 25 | shift(x, 1) # shift positive (from beginning of vector) by 1 26 | shift(x, -1) # shift negative (from end of vector) by 1 27 | shift(x, 5, 0) # Shift by 5 and fill (pad) with 0 28 | 29 | } 30 | \author{ 31 | Jeffrey S. Evans 32 | } 33 | -------------------------------------------------------------------------------- /man/sieve.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/sieve.R 3 | \name{sieve} 4 | \alias{sieve} 5 | \title{Sieve raster data} 6 | \usage{ 7 | sieve(x, a, unit = c("m", "km", "ha")) 8 | } 9 | \arguments{ 10 | \item{x}{An integer terra SpatRaster} 11 | 12 | \item{a}{Query area to remove} 13 | 14 | \item{unit}{The unit to use for area query options are c("m", "km", "ha")} 15 | } 16 | \value{ 17 | A terra SpatRaster with cells < a set to NA 18 | } 19 | \description{ 20 | Removes contiguous cells < specified query area 21 | } 22 | \details{ 23 | A sieve can be used to establish a minimal mapping unit where 24 | contiguous cells < specified query area are set to NA. These NA 25 | values can then be filled using focal (majority, median, mean) 26 | } 27 | \examples{ 28 | \donttest{ 29 | library(terra) 30 | elev <- rast(system.file("extdata/elev.tif", package="spatialEco")) 31 | m <- matrix(c(100,200,1,200,300,2,300,400,3,400, 32 | 500,4, 500,600,5), ncol=3, byrow=TRUE) 33 | x <- classify(elev, m) 34 | 35 | # Sieve to a MMU of 60km 36 | sv <- spatialEco::sieve(x, a = 60, unit = "km") 37 | plot(c(x, sv)) 38 | } 39 | } 40 | \author{ 41 | Jeffrey S. Evans 42 | } 43 | -------------------------------------------------------------------------------- /man/spatialEcoNews.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/spatialEcoNews.R 3 | \name{spatialEcoNews} 4 | \alias{spatialEcoNews} 5 | \title{spatialEco news} 6 | \usage{ 7 | spatialEcoNews(...) 8 | } 9 | \arguments{ 10 | \item{...}{not used} 11 | } 12 | \value{ 13 | Shows package NEWS file 14 | } 15 | \description{ 16 | Displays release notes 17 | } 18 | -------------------------------------------------------------------------------- /man/squareBuffer.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/squareBuffer.R 3 | \name{squareBuffer} 4 | \alias{squareBuffer} 5 | \title{Square buffer} 6 | \usage{ 7 | squareBuffer(x, a, ...) 8 | } 9 | \arguments{ 10 | \item{x}{An sf object} 11 | 12 | \item{a}{Numeric single or vector indicating buffer distance(s)} 13 | 14 | \item{...}{Additional arguments passed to st_buffer} 15 | } 16 | \value{ 17 | A single feature sf class polygon object 18 | } 19 | \description{ 20 | Creates a square buffer of a feature class 21 | } 22 | \details{ 23 | Function creates a square buffer of feature class. 24 | } 25 | \examples{ 26 | library(sf) 27 | xy <- st_as_sf(data.frame(x = c(1,3,6,7), 28 | y = c(3,2,7,8), z = c(38,23,12,12), 29 | area = c(32,23,45,67)), 30 | coords = c("x", "y"), 31 | agr = "constant") 32 | 33 | # With fixed buffer 34 | sb <- squareBuffer(xy, 32) 35 | plot(st_geometry(sb)) 36 | plot(st_geometry(xy), pch=20, add=TRUE) 37 | 38 | # With variable buffer 39 | sb.var <- squareBuffer(xy, xy$area) 40 | plot(st_geometry(sb.var)) 41 | plot(st_geometry(xy), pch=20, add=TRUE) 42 | 43 | } 44 | \author{ 45 | Jeffrey S. Evans 46 | } 47 | -------------------------------------------------------------------------------- /man/srr.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/srr.R 3 | \name{srr} 4 | \alias{srr} 5 | \title{Surface Relief Ratio} 6 | \usage{ 7 | srr(x, s = 5, ...) 8 | } 9 | \arguments{ 10 | \item{x}{A terra SpatRaster object} 11 | 12 | \item{s}{Focal window size} 13 | 14 | \item{...}{Additional arguments passed to terra::lapp} 15 | } 16 | \value{ 17 | A terra SpatRaster object of Pike's (1971) Surface Relief Ratio 18 | } 19 | \description{ 20 | Calculates the Pike (1971) Surface Relief Ratio 21 | } 22 | \details{ 23 | Describes rugosity in continuous raster surface within a specified window. 24 | The implementation of SRR can be shown as: (mean(x) - min(x)) / (max(x) - min(x)) 25 | } 26 | \examples{ 27 | \donttest{ 28 | library(terra) 29 | elev <- rast(system.file("extdata/elev.tif", package="spatialEco")) 30 | r.srr <- srr(elev, s=5) 31 | plot(r.srr, main="Surface Relief Ratio") 32 | } 33 | } 34 | \author{ 35 | Jeffrey S. Evans 36 | } 37 | -------------------------------------------------------------------------------- /man/subsample.distance.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/subsample.distance.R 3 | \name{subsample.distance} 4 | \alias{subsample.distance} 5 | \title{Distance-based subsampling} 6 | \usage{ 7 | subsample.distance(x, size, d, d.max = NULL, replacement = FALSE) 8 | } 9 | \arguments{ 10 | \item{x}{A POLYGON or POINT sf object} 11 | 12 | \item{size}{Subsample size} 13 | 14 | \item{d}{Minimum sampling distance in meters} 15 | 16 | \item{d.max}{Maximum sampling distance in meters} 17 | 18 | \item{replacement}{(FALSE/TRUE) Subsample with replacement} 19 | } 20 | \value{ 21 | A subsampled POLYGON or POINT sf object 22 | } 23 | \description{ 24 | Draws a minimum, and optional maximum constrained, distance sub-sampling 25 | } 26 | \note{ 27 | This function provides a distance constrained subsample of existing point 28 | or polygon data. Please note that units are in meters regardless of input 29 | CRS projection units (including lat/long). 30 | } 31 | \examples{ 32 | 33 | \donttest{ 34 | if(require(sp, quietly = TRUE)) { 35 | library(sf) 36 | data(meuse, package = "sp") 37 | meuse <- st_as_sf(meuse, coords = c("x", "y"), crs = 28992, 38 | agr = "constant") 39 | 40 | # Subsample with a 500m minimum sample spread 41 | sub.meuse <- subsample.distance(meuse, size = 10, d = 500) 42 | plot(st_geometry(meuse), pch=19, main="min dist = 500") 43 | plot(st_geometry(sub.meuse), pch=19, col="red", add=TRUE) 44 | 45 | # Check distances 46 | dm <- st_distance(sub.meuse) 47 | diag(dm) <- NA 48 | cat("\n", "Min distance for subsample", min(dm, na.rm=TRUE), "\n") 49 | cat("Max distance for subsample", max(dm, na.rm=TRUE), "\n") 50 | 51 | } else { 52 | cat("Please install sp package to run example", "\n") 53 | } 54 | } 55 | } 56 | \author{ 57 | Jeffrey S. Evans 58 | } 59 | -------------------------------------------------------------------------------- /man/summary.cross.cor.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/summary.cross.cor.R 3 | \name{summary.cross.cor} 4 | \alias{summary.cross.cor} 5 | \title{Summary of spatial cross correlation} 6 | \usage{ 7 | \method{summary}{cross.cor}(object, ...) 8 | } 9 | \arguments{ 10 | \item{object}{Object of class cross.cor} 11 | 12 | \item{...}{Ignored} 13 | } 14 | \value{ 15 | When not simulated k=0, prints functions list object containing: 16 | \itemize{ 17 | \item I - Global autocorrelation statistic 18 | \item SCI - - A data.frame with two columns representing the xy and yx autocorrelation 19 | \item nsim - value of NULL to represent p values were derived from observed data (k=0) 20 | \item p - Probability based observations above/below confidence interval 21 | \item t.test - Probability based on t-test 22 | } 23 | 24 | When simulated (k>0), prints functions list object containing: 25 | \itemize{ 26 | \item I - Global autocorrelation statistic 27 | \item SCI - A data.frame with two columns representing the xy and yx autocorrelation 28 | \item nsim - value representing number of simulations 29 | \item global.p - p-value of global autocorrelation statistic 30 | \item local.p - Probability based simulated data using successful rejection of t-test 31 | \item range.p - Probability based on range of probabilities resulting from paired t-test 32 | } 33 | } 34 | \description{ 35 | summary method for class "cross.cor" 36 | } 37 | -------------------------------------------------------------------------------- /man/summary.effect.size.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/summary.effect.size.R 3 | \name{summary.effect.size} 4 | \alias{summary.effect.size} 5 | \title{Summarizing effect size} 6 | \usage{ 7 | \method{summary}{effect.size}(object, ...) 8 | } 9 | \arguments{ 10 | \item{object}{Object of class effect.size} 11 | 12 | \item{...}{Ignored} 13 | } 14 | \value{ 15 | Prints the output data.frame contaning; effect size with upper and lower confidence 16 | and, mean and sd by group 17 | } 18 | \description{ 19 | Summary method for class "effect.size". 20 | } 21 | -------------------------------------------------------------------------------- /man/summary.loess.boot.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/summary.loess.boot.R 3 | \name{summary.loess.boot} 4 | \alias{summary.loess.boot} 5 | \title{Summarizing Loess bootstrap models} 6 | \usage{ 7 | \method{summary}{loess.boot}(object, ...) 8 | } 9 | \arguments{ 10 | \item{object}{Object of class loess.boot} 11 | 12 | \item{...}{Ignored} 13 | } 14 | \value{ 15 | same as print lowess.boot data.frame including; 16 | \itemize{ 17 | \item nreps Number of bootstrap replicates 18 | \item confidence Confidence interval (region) 19 | \item span alpha (span) parameter used loess fit 20 | \item degree polynomial degree used in loess fit 21 | \item normalize Normalized data (TRUE/FALSE) 22 | \item family Family of statistic used in fit 23 | \item parametric Parametric approximation (TRUE/FALSE) 24 | \item surface Surface fit, see loess.control 25 | \item data data.frame of x,y used in model 26 | \item fit data.frame including: 27 | \enumerate{ 28 | \item x - Equally-spaced x index (see NOTES) 29 | \item y.fit - loess fit 30 | \item up.lim - Upper confidence interval 31 | \item low.lim - Lower confidence interval 32 | \item stddev - Standard deviation of loess fit at each x value 33 | } 34 | } 35 | } 36 | \description{ 37 | Summary method for class "loess.boot". 38 | } 39 | -------------------------------------------------------------------------------- /man/topo.distance.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/topo.distance.R 3 | \name{topo.distance} 4 | \alias{topo.distance} 5 | \title{Topographic distance} 6 | \usage{ 7 | topo.distance(x, r, echo = FALSE) 8 | } 9 | \arguments{ 10 | \item{x}{sf LINESTRING object} 11 | 12 | \item{r}{terra SpatRaster class elevation raster} 13 | 14 | \item{echo}{(FALSE/TRUE) print progress to screen} 15 | } 16 | \value{ 17 | Vector of corrected topographic distances same length as nrow(x) 18 | } 19 | \description{ 20 | Calculates topographic corrected distance for a line object 21 | } 22 | \details{ 23 | This function corrects straight-line (euclidean) distances for topographic-slope effect. 24 | } 25 | \examples{ 26 | library(sf) 27 | library(terra) 28 | 29 | # create example data 30 | elev <- rast(system.file("extdata/elev.tif", package="spatialEco")) 31 | names(elev) <- "elev" 32 | 33 | lns <- lapply(1:5, function(i) { 34 | p <- st_combine(st_as_sf(spatSample(elev, size=2, as.points=TRUE))) 35 | st_as_sf(st_cast(p, "LINESTRING")) }) 36 | lns <- do.call(rbind, lns) 37 | 38 | plot(elev) 39 | plot(st_geometry(lns), add=TRUE) 40 | 41 | # Calculate topographical distance 42 | ( tdist <- topo.distance(lns, elev) ) 43 | ( lgt <- as.numeric(st_length(lns)) ) 44 | 45 | # Increase in corrected distance 46 | tdist - lgt 47 | 48 | # Percent increase in corrected distance 49 | ((tdist - lgt) / lgt) * 100 50 | 51 | } 52 | \author{ 53 | Jeffrey S. Evans 54 | } 55 | -------------------------------------------------------------------------------- /man/tpi.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tpi.R 3 | \name{tpi} 4 | \alias{tpi} 5 | \title{Topographic Position Index (tpi)} 6 | \usage{ 7 | tpi(x, scale = 3, win = "rectangle", normalize = FALSE, zero.correct = FALSE) 8 | } 9 | \arguments{ 10 | \item{x}{A terra SpatRaster object} 11 | 12 | \item{scale}{focal window size (n-cell x n-cell for rectangle or 13 | distance for circle)} 14 | 15 | \item{win}{Window type. Options are "rectangle" and "circle"} 16 | 17 | \item{normalize}{Apply deviation correction that normalizes to local 18 | surface roughness} 19 | 20 | \item{zero.correct}{Apply correction for zero values in matrix weights} 21 | } 22 | \value{ 23 | A terra SpatRaster object of tpi A terra SpatRaster object 24 | } 25 | \description{ 26 | Calculates topographic position using mean deviations 27 | } 28 | \examples{ 29 | \donttest{ 30 | library(terra) 31 | elev <- rast(system.file("extdata/elev.tif", package="spatialEco")) 32 | 33 | # calculate tpi and plot 34 | tpi7 <- tpi(elev, scale=7) 35 | tpi025 <- tpi(elev, win = "circle", scale=2500) 36 | tpi025.zc <- tpi(elev, win = "circle", scale=2500, 37 | zero.correct = TRUE) 38 | 39 | opar <- par(no.readonly=TRUE) 40 | par(mfrow=c(2,2)) 41 | plot(elev, main="original raster") 42 | plot(tpi7, main="tpi 7x7") 43 | plot(tpi025, main="tpi Circular window d=2500m") 44 | plot(tpi025, main="tpi Circular window d=2500m, zero correct") 45 | par(opar) 46 | } 47 | 48 | } 49 | \references{ 50 | De Reu, J., J. Bourgeois, M. Bats, A. Zwertvaegher, V. Gelorini, et al., (2014) 51 | Application of the topographic position index to heterogeneous landscapes. 52 | Geomorphology, 186:39-49. 53 | } 54 | \author{ 55 | Jeffrey S. Evans 56 | } 57 | -------------------------------------------------------------------------------- /man/trasp.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/trasp.R 3 | \name{trasp} 4 | \alias{trasp} 5 | \title{Solar-radiation Aspect Index} 6 | \usage{ 7 | trasp(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{A terra SpatRaster object} 11 | 12 | \item{...}{Additional arguments passed to terra::app} 13 | } 14 | \value{ 15 | A terra SpatRaster object of Roberts and Cooper (1989) Solar-radiation Aspect Index 16 | } 17 | \description{ 18 | Calculates the Roberts and Cooper (1989) Solar-radiation Aspect Index 19 | } 20 | \details{ 21 | Roberts and Cooper (1989) rotates (transforms) the circular aspect to assign a 22 | value of zero to land oriented in a north-northeast direction, (typically the 23 | coolest and wettest orientation), and a value of one on the hotter, dryer 24 | south-southwesterly slopes. The result is a continuous variable between 0 - 1. 25 | The metric is defined as: trasp = ( 1 - cos((pi/180)(a-30) ) / 2 26 | where; a = aspect in degrees 27 | } 28 | \examples{ 29 | library(terra) 30 | elev <- rast(system.file("extdata/elev.tif", package="spatialEco")) 31 | s <- trasp(elev) 32 | plot(s) 33 | 34 | } 35 | \references{ 36 | Roberts. D.W., and Cooper, S.V. (1989). Concepts and techniques of vegetation mapping. 37 | In Land Classifications Based on Vegetation: Applications for Resource Management. 38 | USDA Forest Service GTR INT-257, Ogden, UT, pp 90-96 39 | } 40 | \author{ 41 | Jeffrey S. Evans 42 | } 43 | -------------------------------------------------------------------------------- /man/trend.line.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/trend.line.R 3 | \name{trend.line} 4 | \alias{trend.line} 5 | \title{trend.line} 6 | \usage{ 7 | trend.line(x, y, type = "linear", plot = TRUE, ...) 8 | } 9 | \arguments{ 10 | \item{x}{Vector of x} 11 | 12 | \item{y}{Vector of y} 13 | 14 | \item{type}{Trend line types are: 'linear', 'exponential', 15 | 'logarithmic', 'polynomial'} 16 | 17 | \item{plot}{plot results (TRUE/FALSE)} 18 | 19 | \item{...}{Additional arguments passed to plot} 20 | } 21 | \value{ 22 | A list class object with the following components: 23 | \itemize{ 24 | \item for type = 'linear' x is slope and y is intercept 25 | \item for type = 'exponential', 'logarithmic', or 'polynomial' 26 | x is original x variable and y is vector of fit 27 | regression line 28 | } 29 | } 30 | \description{ 31 | Calculated specified trend line of x,y 32 | } 33 | \examples{ 34 | x <- 1:10 35 | y <- jitter(x^2) 36 | 37 | opar <- par(no.readonly=TRUE) 38 | par(mfcol=c(2,2)) 39 | trend.line(x,y,type='linear',plot=TRUE,pch=20,main='Linear') 40 | trend.line(x,y,type='exponential',plot=TRUE,pch=20,main='Exponential') 41 | trend.line(x,y,type='logarithmic',plot=TRUE,pch=20,main='Logarithmic') 42 | trend.line(x,y,type='polynomial',plot=TRUE,pch=20,main='Polynomial') 43 | par(opar) 44 | 45 | } 46 | \author{ 47 | Jeffrey S. Evans \href{mailto:jeffrey_evans@tnc.org}{jeffrey_evans@tnc.org} 48 | } 49 | -------------------------------------------------------------------------------- /man/vrm.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/vrm.R 3 | \name{vrm} 4 | \alias{vrm} 5 | \title{Vector Ruggedness Measure (VRM)} 6 | \usage{ 7 | vrm(x, s = 3) 8 | } 9 | \arguments{ 10 | \item{x}{A terra SpatRaster class object} 11 | 12 | \item{s}{Scale of window. Must be odd number, can represent 2 dimensions 13 | (eg., s=c(3,5) would represent a 3 x 5 window)} 14 | } 15 | \value{ 16 | A terra SpatRaster class object of the VRI 17 | } 18 | \description{ 19 | Implementation of the Sappington et al., (2007) vector 20 | ruggedness measure 21 | } 22 | \details{ 23 | This function measures terrain ruggedness by calculating the vector 24 | ruggedness measure 25 | } 26 | \examples{ 27 | library(terra) 28 | elev <- rast(system.file("extdata/elev.tif", package="spatialEco")) 29 | vrm3 <- vrm(elev) 30 | vrm5 <- vrm(elev, s=5) 31 | plot(c(vrm3, vrm5)) 32 | 33 | } 34 | \references{ 35 | Sappington, J.M., K.M. Longshore, D.B. Thomson (2007). Quantifying Landscape 36 | Ruggedness for Animal Habitat Analysis: A case Study Using Bighorn Sheep in 37 | the Mojave Desert. Journal of Wildlife Management. 71(5):1419-1426 38 | } 39 | \author{ 40 | Jeffrey S. Evans 41 | } 42 | -------------------------------------------------------------------------------- /man/wt.centroid.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/wt.centroids.R 3 | \name{wt.centroid} 4 | \alias{wt.centroid} 5 | \title{Weighted centroid} 6 | \usage{ 7 | wt.centroid(x, p = NULL, spatial = TRUE) 8 | } 9 | \arguments{ 10 | \item{x}{sf POINT class object} 11 | 12 | \item{p}{Weights column in x} 13 | 14 | \item{spatial}{(TRUE/FALSE) Output sf POINT object} 15 | } 16 | \value{ 17 | An x,y coordinate or sf POINT object representing the weighted or unweighted 18 | coordinate centroid 19 | } 20 | \description{ 21 | Creates centroid of [x,y] coordinates with optional 22 | weights field 23 | } 24 | \details{ 25 | The weighted centroid is calculated as: 26 | [Xw]=[X]*[p], [Yw]=[Y]*[p], [sXw]=SUM[Xw], [sYw]=SUM[Yw], [sP]=SUM[p] 27 | wX=[sXw]/[sP], wY=[sYw]/[sP] 28 | where; X=X coordinate(S), Y=Y coordinate(S), p=WEIGHT 29 | } 30 | \examples{ 31 | p = c("sf", "sp") 32 | if(any(!unlist(lapply(p, requireNamespace, quietly=TRUE)))) { 33 | m = which(!unlist(lapply(p, requireNamespace, quietly=TRUE))) 34 | message("Can't run examples, please install ", paste(p[m], collapse = " ")) 35 | } else { 36 | invisible(lapply(p, require, character.only=TRUE)) 37 | 38 | data(meuse, package = "sp") 39 | meuse <- st_as_sf(meuse, coords = c("x", "y"), crs = 28992, 40 | agr = "constant") 41 | 42 | wt.copper <- wt.centroid(meuse, p='copper') 43 | wt.zinc <- wt.centroid(meuse, p='zinc') 44 | 45 | plot(st_geometry(meuse), pch=20, cex=0.75, 46 | main='Weighted centroid(s)') 47 | plot(st_geometry(wt.copper), pch=19, col='red', 48 | cex=1.5, add=TRUE) 49 | plot(st_geometry(wt.zinc), pch=19, col='blue', 50 | cex=1.5, add=TRUE) 51 | legend('topleft', legend=c('all','copper', 'zinc'), 52 | pch=c(20,19,19),col=c('black','red','blue')) 53 | } 54 | } 55 | \author{ 56 | Jeffrey S. Evans 57 | } 58 | --------------------------------------------------------------------------------