Learn R Programming

sperich (version 1.4-0)

edgeNotValid: Edge-Water-Test

Description

This function checks if an edge would cross a water or mountain surface.

Usage

edgeNotValid(grid,point.a, point.b, landwatermask, upperbound)

Arguments

grid
A grid to which the edge should be added if it hits no water or mountain surfaces.
point.a
A point in a grid given by its row and column.
point.b
A point in a grid given by its row and column.
landwatermask
A grid containing the land-water-information of the observed area. If a grid cell containes no land, the value of the cell in the landwatermask is -1, otherwise it is 0. Additional, height-informations could be added for land surfaces. In this ca
upperbound
This value determines the height (based on values in 'landwatermask') which is considered to be a barrier for species distribution.

Value

  • A boolean value which determines if the edge would cross a water or mountain surface.

Details

This function checks if an edge would cross a water or mountain surface.

Examples

Run this code
##load data
data(dataset.all.species)
data(dataset.landwater)

##initialize variables
distance <- 5

##create grid parameters
dimension <- getDimension(dataset.all.species)
shift <- getShift(dataset.all.species)

##create landwatermask
landwatermask.nocoast <- createLandwatermask(dataset.landwater, dimension, shift)

##extract datasets of one species out of database
dataset.one.species <- extract.species(dataset.all.species, 3)

##create grid
grid <- matrix(0,dimension[1],dimension[2])

##add points
grid <- add.Data.to.Grid(dataset.one.species, dimension, shift)

##points to list
points <- which(grid > 0)
points.xy <- list()
for (i in 1:length(points)){
		points.xy[[i]] <- c(ifelse((points[i] %% dimension[1]) == 0, dimension[1], 
					points[i] %% dimension[1]), 
					ceiling(points[i]/dimension[1]))
	}

##Edge-Water-Test
check <- edgeNotValid(grid, points.xy[[1]],points.xy[[2]], 
				landwatermask.nocoast, 1000)
print(check)

Run the code above in your browser using DataLab