fix.coastal.points: Shift points to the nearest non-NA cell of a base raster...

View source: R/fix.coastal.points.R

fix.coastal.pointsR Documentation

Shift points to the nearest non-NA cell of a base raster within a maximum distance

Description

The function moves points to the nearest non-NA cell of a base raster within a maximum distance.

Usage

fix.coastal.points(data,xy.cols,r,ncell,clip.by.poly=FALSE,poly,occ.desaggregation=FALSE)

Arguments

data

a matrix or data.frame containing the points coordinates.

xy.cols

a numeric vector indicating the IDs of the x-y columns.

r

a RasterLayer object to be used as base raster map.

ncell

an integer indicating the maximum number of cells away from the points where they can be shifted. If the nearest non-NA cell fall farther than this distance from a give point, this will be dropped.

clip.by.poly

a logical vector indicating if the base raster must be clipped along the boundaries of a polygon.

poly

a SpatialPolygons object used to clip the base raster map.

occ.desaggregation

a logical vector indicating if to apply the occ.desaggregation.RASTER function.

Value

A matrix including the shifted points

Author(s)

Mirko Di Febbraro

Examples


library(raster)
raster(system.file("exdata/prediction_ground.gri", package="EcoPast"))->prediction_ground
data(lgm)

data_clupus<-subset(lgm, spec=="Canis_lupus")

coordinates(data_clupus)<-~x+y
proj4string(data_clupus)<-"+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs"
data_clupus<-spTransform(data_clupus, proj4string(prediction_ground))
data_clupus<-as.data.frame(data_clupus)

data_mammuth_reduced<-fix.coastal.points(data_clupus, xy.cols = 4:5,
r = prediction_ground, ncell = 1, occ.desaggregation = FALSE)


francesco-carotenuto/EcoPast documentation built on April 16, 2023, 5:48 p.m.