R/jitter.R

Defines functions jitter.points bstrap.points poly.labels

Documented in bstrap.points jitter.points poly.labels

jitter.points <- function(pts,scl) {
	x = coordinates(pts)
	x =  x + rnorm(length(x),0,scl) 
	res = SpatialPoints(x)
	proj4string(res)=CRS(proj4string(pts))
	if (class(pts)=="SpatialPointsDataFrame") {
		res = SpatialPointsDataFrame(res,data.frame(pts))}
	return(res) }

bstrap.points <- function(pts) {
	x = coordinates(pts)
	x = x[sample(nrow(x),replace=TRUE),]
	res = SpatialPoints(x)
	proj4string(res)=CRS(proj4string(pts))
	if (class(pts)=="SpatialPointsDataFrame") {
		res = SpatialPointsDataFrame(res,data.frame(pts))}
	return(res) }
	
poly.labels <- function(polys) {
	pts = SpatialPoints(t(sapply(slot(polys,'polygons'), function(x) slot(x,'labpt'))))
	proj4string(pts) = CRS(proj4string(polys))
	pts }

Try the GISTools package in your browser

Any scripts or data that you put into this service are public.

GISTools documentation built on May 6, 2019, 1:09 a.m.