Hello: Im working on a method to create multilayer raster/vector plots using spplot() and supporting functions. The question is: how do I efficiently add display list instructions for plotting the point labels that works for different sized point vectors?
Here is a working 'brute force' approach (I have omitted the string parsing code that produces the point labels) that creates the plot and labels the first two points only: library(sp) library(rgdal) library(maptools) # # read files # Counties <- readShapePoly("PugetSoundCountiesClp2.shp") psImg <- readGDAL("PugetSoundSub1.img") Centroids <- readShapePoints("PSCentroidPointShape") len = length([EMAIL PROTECTED]) LatLongs = [EMAIL PROTECTED] dim(LatLongs) = c(len/2,2) # # spplot 'sp.layout' list entries (demote polygons to spatial lines). # points <- list("sp.points", Centroids, pch = 21,col="green") Counties_lines <- as(Counties, "SpatialLines") polys <- list("sp.lines", Counties_lines, col="white") greys <- grey(0:256 / 256) # # Assume: ss[] is a char vector of point labels, one per Centroid element.. # display list entries for first two points # pt1 = list("sp.text",c(LatLongs[1,1],LatLongs[1,2]),ss[1],col="white",pos=2) pt2 = list("sp.text",c(LatLongs[2,1],LatLongs[2,2]),ss[2],col="white",pos=2) # # I could create these for all 'n' list elements I suppose, but then the code is not general. # grob2 = spplot(psImg, "band1", col.regions=greys, sp.layout=list(points,pl1,pl2,polys),cuts=length(greys), colorkey=FALSE,scales=list(draw=TRUE)) # plot(grob2) Something tells me Im doing this the hard way... I could construct the arguments to list() dynamically with string building code, and then call() or eval() the command, but isnt there a much simpler way to 1) tell sp.layout to add the point labels or 2) add the labels to the plot in a separate command? I have tried separate text() and update(trellis.last.object()) commands to no avail. Suggestions? Regards, Rick Reeves / NCEAS _______________________________________________ R-sig-Geo mailing list R-sig-Geo@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo