findLand | R Documentation |
The generic function findLand
uses information from a GIS shapefile
to define which nodes are on land, and which are not. Strickly speaking,
being 'on land' is in fact being inside a polygon of the shapefile.
findLand(x, ...)
## S4 method for signature 'matrix'
findLand(x, shape = "world", ...)
## S4 method for signature 'data.frame'
findLand(x, shape = "world", ...)
## S4 method for signature 'gGraph'
findLand(x, shape = "world", attr.name = "habitat", ...)
x |
a matrix, a data.frame, or a valid gGraph object. For matrix and data.frame, input must have two columns giving longitudes and latitudes of locations being considered. |
... |
further arguments to be passed to other methods. Currently not used. |
shape |
a shapefile of the class |
attr.name |
a character string giving the name of the node attribute in which the output is to be stored. |
Nodes can be specified either as a matrix of geographic coordinates, or as a gGraph object.
The output depends on the nature of the input:
- matrix,
data.frame
: a factor with two levels being 'land' and 'sea'.
gGraph
: a gGraph object with a new node attribute,
possibly added to previously existing node attributes (@nodes.attr
slot).
extractFromLayer
, to retrieve any information from a
GIS shapefile.
## create a new gGraph with random coordinates
myCoords <- data.frame(long = runif(1000, -180, 180), lat = runif(1000, -90, 90))
obj <- new("gGraph", coords = myCoords)
obj # note: no node attribute
plot(obj)
## find which points are on land
obj <- findLand(obj)
obj # note: new node attribute
## define rules for colors
temp <- data.frame(habitat = c("land", "sea"), color = c("green", "blue"))
temp
obj@meta$color <- temp
## plot object with new colors
plot(obj)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.