Plot a spatial.neighbor Object

DESCRIPTION:

Plot an object of class spatial.neighbor with lines connecting points that are neighbors.

USAGE:

plot.spatial.neighbor(x, xcoord, ycoord, line.col=1, line.type=1, 
                      line.width=1, matrix.id=1, add=F, arrows=F, 
                      size.arrow=0.1, scaled=T, ...) 

REQUIRED ARGUMENTS:

x
an object of class "spatial.neighbor".
xcoord
a numeric vector containing the x-coordinates of the data whose neighbor relations are defined in x.
ycoord
a numeric vector containing the y-coordinates of the data whose neighbor relations are defined in x. Must be the same length as xcoord.

OPTIONAL ARGUMENTS:

line.col
a numeric value indicating the color to draw the lines connecting the points that are neighbors. See the col parameter in the par help file.
line.type
a numeric value indicating the line type to use for the lines connecting the points that are neighbors. See the lty parameter in the par help file.
line.width
a numeric value indicating the line width to use for the lines connecting the points that are neighbors. See the lwd parameter in the par help file.
matrix.id
a positive integer indicating which spatial neighbor matrix is to be plotted. Only one spatial neighbor matrix can be plotted per call to the function but objects of class "spatial.neightbor" can contain more than one matrix.
add
a logical value, if TRUE no initial plot is drawn, only the lines joining the neighbors are added to the current plot.
arrows
a logical value, if TRUE, arrows are drawn from each point to its neighbor, if FALSE, segments are drawn from each point to its neighbor. Plotting with arrows can be useful when there are one way neighbor relations in x i.e. point B is a neighbor of point A but point A is not a neighbor of point B. If x is a symmetric spatial neighbor object, ( attr(x,symmetric) is TRUE) then all neighbor relations are bi-directional and setting arrows=TRUE just results in a messy graph.
size.arrows
the size of the arrowhead width in inches. See the arrows help file for details.
scaled
a logical value, if TRUE then scaled.plot is used to set up the plot coordinates instead of plot. This produces an equally scaled plot which is often useful when xcoord and ycoord are geographic locations. Graphical parameters may also be supplied as arguments to this function (see ).

SIDE EFFECTS:

a plot is produced on the current graphics device or lines are added to the current plot (if add=T).

DETAILS:

The coordinate system for the plot is drawn based on the values in xcoord, ycoord. The graphical parameters specified in ... are used to draw this initial graph. If scaled=TRUE the scale.ratio parameter to scaled.plot can also be passed in the ... arguments. The lines are added through a call to segments or arrows. The graphical parameters line.col, line.type and line.width are used in the call to segments or arrows. This function is a method for the generic function for class spatial.neighbor. It can be invoked by calling for an object x of the appropriate class, or directly by calling regardless of the class of the object.

BUGS:

With S-PLUS 5.1, if you are calling this function as a plot method (i.e. plot) you must specify the xcoord and ycoord arguments by name (not by position) otherwise the wrong method will be called.

SEE ALSO:

, , , , , .

EXAMPLES:

# Plot the sids.neighbor object using the easting and northing 
#   values from sids as the coordinates 
plot(sids.neighbor, xc=sids$easting, yc=sids$northing, scaled=T) 
# Create a second order spatial neighbor object on a 10 x 10 grid 
ng10 <- neighbor.grid(10, 10, neighbor.type="second.order") 
sn10 <- spatial.neighbor(ng10) 
# Generate a 10 x 10 set of coordinates 
xy <- expand.grid(x=1:10, y=1:10) 
# Plot the spatial neighbor object 
plot(sn10, xc=xy$x, yc=xy$y) 
# Create and plot spatial neighbor object for the bramble canes 
#   nearest neighbors 
nb <- find.neighbor(bramble, k=2, drop.self=T) 
sn <- spatial.neighbor(nb) 
plot(sn, xc=bramble$x, yc=bramble$y)