[R-sig-Geo] New (?) use of polypath() in package sp causing a problem?

MacQueen, Don macqueen1 at llnl.gov
Fri Aug 10 01:35:29 CEST 2012


I have encountered a problem I've never seen before.

The problem is:

> x11(type='Xlib')
> plot(sfbound)
Warning message:
In polypath(x = mcrds[, 1], y = mcrds[, 2], border = border, col = col, :
Path drawing not available for this device

And nothing is plotted.

The object sfbound is a SpatialPolygonsDataFrame object with one simple
polygon in it. 
Previously I have had no problem plotting such objects with
x11(type='Xlib').x11(type='cairo') succeeds.


It looks very likely that this relates to this entry in NEWS for R 2.12.0:

-- quote --
Added support for polygons with holes to the graphics
engine. This is implemented for the pdf(),
postscript(), x11(type="cairo"), windows(),
and quartz() devices (and associated raster formats),
but not for x11(type="Xlib") or xfig() or
pictex(). The user-level interface is the
polypath() function in graphics and
grid.path() in grid.
-- end quote --

That is, presuming a relatively recent change in sp in which polyplot() is
now used and previously was not, the change described in NEWS would
explain why I'm seeing this.



The problem is, I have found that for plots in which a very large number
of objects are being plotted, the Xlib version of X11() is much faster
than the cairo version. And I frequently plot spatial objects with
thousands of line segments in them, where the performance difference is
substantial, to the point of making use of the cairo version intolerable.

I guess the question is -- am I correct in this analysis?
If so, do I have any alternative when I need to plot spatial objects with
huge numbers of points/lines/polygons in them?

Thanks
-Don


> str(sfbound)
Formal class 'SpatialPolygonsDataFrame' [package "sp"] with 5 slots
  ..@ data       :'data.frame': 1 obs. of  1 variable:
  .. ..$ name: Factor w/ 1 level "Boundary.kml": 1
  ..@ polygons   :List of 1
  .. ..$ :Formal class 'Polygons' [package "sp"] with 5 slots
  .. .. .. ..@ Polygons :List of 1
  .. .. .. .. ..$ :Formal class 'Polygon' [package "sp"] with 5 slots
  .. .. .. .. .. .. ..@ labpt  : num [1:2] -121.7 37.7
  .. .. .. .. .. .. ..@ area   : num 3.71e-06
  .. .. .. .. .. .. ..@ hole   : logi FALSE
  .. .. .. .. .. .. ..@ ringDir: int 1
  .. .. .. .. .. .. ..@ coords : num [1:8, 1:2] -122 -122 -122 -122 -122
...
  .. .. .. ..@ plotOrder: int 1
  .. .. .. ..@ labpt    : num [1:2] -121.7 37.7
  .. .. .. ..@ ID       : chr "1"
  .. .. .. ..@ area     : num 3.71e-06
  ..@ plotOrder  : int 1
  ..@ bbox       : num [1:2, 1:2] -121.7 37.7 -121.7 37.7
  .. ..- attr(*, "dimnames")=List of 2
  .. .. ..$ : chr [1:2] "x" "y"
  .. .. ..$ : chr [1:2] "min" "max"
  ..@ proj4string:Formal class 'CRS' [package "sp"] with 1 slots
  .. .. ..@ projargs: chr "+proj=longlat +ellps=GRS80 +datum=NAD83
+no_defs +towgs84=0,0,0"


> sessionInfo()
R version 2.15.1 (2012-06-22)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

locale:
[1] C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] sp_0.9-99   rmacq_1.1-8

loaded via a namespace (and not attached):
[1] grid_2.15.1    lattice_0.20-6 tools_2.15.1

	

-- 
Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062



More information about the R-sig-Geo mailing list