On Tue, 8 Jun 2010, Sebastian P. Luque wrote:
Hi,
Using the example from the vignette "sp" (section 7.1):
Well, not really, because the example on p. 19 builds a SpatialPolygons
object, for which there is a plot() method. There is no plot() method for
Polygon or Polygons objects exposed at the user level, mostly because of
plot order and hole handling issues.
Roger
---<--------------------cut here---------------start------------------->---
R> sr1
An object of class "Polygon"
Slot "labpt":
[1] 2.697 3.545
Slot "area":
[1] 5.5
Slot "hole":
[1] TRUE
Slot "ringDir":
[1] -1
Slot "coords":
[,1] [,2]
[1,] 2 2
[2,] 4 3
[3,] 4 5
[4,] 1 4
[5,] 2 2
R> plot(sr1)
Error in as.double(y) :
cannot coerce type 'S4' to vector of type 'double'
R> showMethods("plot")
Function: plot (package graphics)
x="ANY", y="ANY"
x="Polygon", y="missing"
(inherited from: x="ANY", y="ANY")
x="SpatialLines", y="missing"
x="Spatial", y="missing"
x="SpatialPoints", y="missing"
x="SpatialPolygons", y="missing"
R> sessionInfo()
R version 2.11.1 (2010-05-31)
x86_64-pc-linux-gnu
locale:
[1] LC_CTYPE=en_CA.UTF-8 LC_NUMERIC=C LC_TIME=en_CA.UTF-8
[4] LC_COLLATE=en_CA.UTF-8 LC_MONETARY=C
LC_MESSAGES=en_CA.UTF-8
[7] LC_PAPER=en_CA.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] rgdal_0.6-27 maptools_0.7-34 foreign_0.8-40 mapdata_2.1-2 maps_2.1-3
[6] sp_0.9-64 slmisc_0.7.6 lattice_0.18-8
loaded via a namespace (and not attached):
[1] grid_2.11.1 tools_2.11.1
---<--------------------cut here---------------end--------------------->---
Why is plot() failing with that error?
Cheers,
--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: roger.biv...@nhh.no
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo