Skip to content

Plotting point labels along with points using spplot sp.layout list

2 messages · Felix Andrews, Rick Reeves

#
On 9/30/07, reeves at nceas.ucsb.edu <reeves at nceas.ucsb.edu> wrote:
Look at sp.text, it is nothing but a constrained version of panel.text:
function (loc, txt, ...)
{
    if (length(loc) != 2)
        stop("loc should have length 2")
    if (!is.numeric(loc))
        stop("loc should be numeric")
    panel.text(loc[1], loc[2], txt, ...)
}
<environment: namespace:sp>

So you can just do this:
ptLabels <- list("panel.text", LatLongs[,1], LatLongs[,2], labels=ss,
col="white", pos=2)

You might also be interested in maptools::pointLabel to place the
labels so they don't overlap.

Felix
On 9/30/07, reeves at nceas.ucsb.edu <reeves at nceas.ucsb.edu> wrote:

  
    
#
Thanks Felix, this is the answer that I was looking for!



points <- list("sp.points", Centroids, pch = 21,col="green")
polys <- list("sp.lines", Counties_lines, col="white")
ptLabels =
list("panel.text",LatLongs[,1],LatLongs[,2],labels=ss,col="white",pos=2)
print("plotting the grob")
browser()
grob2 = spplot(psImg, "band1", col.regions=greys,
sp.layout=list(points,ptLabels,polys),cuts=length(greys),
colorkey=FALSE,scales=list(draw=TRUE))
plot(grob2)

the complete example will soon be posted on my Web site:

http://nceas.ucsb.edu/scicomp/GISSeminar/UseCases/MapProdWithRGraphics/OneMapProdWithRGraphics.html

Regards, Rick R
Felix Andrews wrote:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: reeves.vcf
Type: text/x-vcard
Size: 350 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20071001/5877be5f/attachment.vcf>