spatiotemp_thin {dynamicSDM}R Documentation

Thin species occurrence records by spatial and temporal proximity.


Thins species occurrence records that are within minimum spatial and temporal distance apart.


  spatial.dist = 0,
  iterations = 100,
  prj = "+proj=longlat +datum=WGS84"


a data frame, with columns for occurrence record co-ordinates and dates with column names as follows; record longitude as "x", latitude as "y", year as "year", month as "month", and day as "day".


a character string, the method to calculate temporal distance between records. One of DOY or day. See details for more information.


a numeric value, the temporal buffer in days to thin records by.


a numeric value, the grid cell resolution in degrees to split occurrence records by before temporal thinning.


a numeric value, the spatial buffer distances in metres to thin records by. Default no spatial thinning.


a numeric value, the number of iterations to randomly thin occurrence records by. Default; 100.


a character string, the coordinate reference system of co-ordinates. Default is "+proj=longlat +datum=WGS84".


Returns data frame of occurrence records thinned by specified temporal and spatial distance.


spatiotemp_thin() calculates the temporal distance between occurrence records in given area and excludes records below minimum temporal distance apart. Then calculates the spatial distance between all occurrence records and filters records below the minimum spatial distance apart using the spThin package function for spatial thinning (Aiello-Lammens et al., 2015). This approach has been shown to improve species distribution model performance (Boria et al., 2014).

Temporal thinning methods

For temporal thinning, the function first splits occurrence records into grid cells of given size in degrees (set by spatial.split.degrees). This is to prevent spatially distant but temporally close records from being excluded. For each grid cell, all records within the cell are temporally thinned. This process works by removing records that are within given temporal distance (temporal.dist) from each other by randomly selecting one of the two. This iterates through until no records are within the given temporal distance of each other in each grid cell, following a similar algorithm to spThin (Aiello-Lammens et al., 2015).

Two methods exist for measuring the temporal distance between occurrence records.

For instance, two dates “2010-01-05” and “2012-12-05” can be calculated as either 1065 absolute days apart, or within the annual cycle these dates represent day 5 and day 339 of the year, and are 31 days apart. Therefore, thinning by 40 days using the DOY method would remove one of these records, but using the day method would not. The chosen temporal.method will depend upon whether bias towards a point within the annual cycle or a point in linear time.

Spatial thinning

Following temporal thinning, spatial thinning occurs across entire dataset. The spatial distance between each record is calculated, and records within the given spatial distance (spatial.dist) from each other are excluded by randomly selecting one of these. This iterates through until no records are with the given spatial distances of each other across entire dataset using the package spThin (Aiello-Lammens et al., 2015).

As random selection could alter the total number of occurrence records remaining in the occurrence record dataset, this process is iterated through a specified number of times (iterations) and the thinned data frame with the highest number of records remaining is returned.


Aiello-Lammens, M. E., Boria, R. A., Radosavljevic, A., Vilela, B. & Anderson, R. P. 2015. spThin: an R package for spatial thinning of species occurrence records for use in ecological niche models. Ecography, 38, 541-545.

Boria, R. A., Olson, L. E., Goodman, S. M. & Anderson, R. P. 2014. Spatial Filtering To Reduce Sampling Bias Can Improve The Performance Of Ecological Niche Models. Ecological Modelling, 275, 73-77.



n.iterations <- 500

spatiotemp_thin( = sample_filt_data,
 temporal.method = "day",
 temporal.dist = 100,
 spatial.split.degrees = 3,
 spatial.dist = 100000,
 iterations = n.iterations

[Package dynamicSDM version 1.3.4 Index]