spatial.neighbor
Object
spatial.neighbor
with lines connecting points that
are neighbors.
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, ...)
"spatial.neighbor"
.
x
.
x
.
Must be the same length as
xcoord
.
col
parameter in the
par
help file.
lty
parameter in the
par
help file.
lwd
parameter in the
par
help file.
"spatial.neightbor"
can contain more than one matrix.
TRUE
no initial plot is drawn, only the
lines joining the neighbors are added to the current plot.
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.
arrows
help file for details.
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
).
add=T
).
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.
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.
# 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)