View source: R/geoThinApprox.r
| geoThinApprox | R Documentation |
This function thins a set of geographic points so of the remainder, none are closer than a given distance. The function is nearly the same as the function thin.algorithm in the spThin package, except that it accepts a data frame, matrix, SpatialPoints, or SpatialPointsDataFrame as a main argument and the user can specify the distance function to be used and that it returns an object of the same kind.
geoThinApprox( x, minDist, longLat = NULL, distFunct = NULL, verbose = FALSE, ... )
x |
Data frame, matrix, or SpatialPoints* object. See |
minDist |
Numeric. Minimum distance (usually in m) thinned points must be from their nearest neighbor. |
longLat |
Two-element character list or two-element integer list. If |
distFunct |
Either a function or |
verbose |
Logical. If |
... |
Extra arguments to pass to |
If x is a data frame or a matrix then it will be assumed to be unprojected (WGS84 coordinate reference system) and minDist should be in units of meters.
Object of class x.
distGeo, geoThin
x <- data.frame(long=c(-90.1, -90.1, -90.15, -90.17, -90.2, -89),
lat=c(38, 38, 38, 38, 38, 38), point=letters[1:6])
set.seed(123)
geoThinApprox(x, 10000, longLat=c(1, 2)) # run #1
geoThinApprox(x, 10000, longLat=c(1, 2)) # run #2
geoThinApprox(x, 10000, longLat=c(1, 2)) # run #3
geoThinApprox(x, 10, longLat=c(1, 2))
# example using SpatialPointsDataFrame
data(lemur)
data(mad0)
par(mfrow=c(1, 3))
for (count in 1:3) {
plot(mad0, main='Madagascar')
points(lemur, col='red')
thinned <- geoThinApprox(lemur, 50000)
points(thinned, pch=16)
legend('topright', legend=c('retained', 'discarded'),
col=c('black', 'red'), pch=c(16, 1))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.