Edzer Pebesma wrote:


Michael Friendly wrote:
Two short questions about working with maps:

1. I'm reading a shapefile with character labels for the regions (FSA). I can add the labels using plot(), but when I try the same thing using spplot(), the labels are in the wrong positions -- they all seem to be
shrunk somewhat in toward the center of the map.  What am I doing wrong?

# this doesn't work-- labels in wrong position
spplot(toronto,"FSA_NAME", colorkey=FALSE)
text(coordinates(toronto), labels=as.character(toronto$FSA), cex=0.4)
Right: text() works with base graphics, not with lattice on which spplot is built.

Something like this should work:
spplot(toronto,"FSA_NAME", colorkey=FALSE,
sp.layout = list("sp.text", coordinates(toronto), as.character(toronto$FSA), cex=0.4))

Great!  Now I also know where to look to generalize this.

2. I have a bunch of attribute variables for the geographic regions, all on different scales. Id like to produce a set of comparative maps in the same figure (say with spplot()) with each attribute shaded by its quantiles, e.g., 5 classes each. Do I have to precompute these first, or is there something I can do in the call to spplot() to have this done, using the variables in the SpatialPolygonsDataFrame?
What exactly did you mean by "all on different scales"? They have different polygon structures?
No - some of the attribute values are percents, some are quantitative & positively skewed, like Income. If I do

spplot(toronto, c("Household.Income","Unemployed","University"))
a single scale is applied to all three, so the two % variables are shaded uniformly in the lowest range. What I'd like is to apply a function to take each of these and recode into quantiles for that variable.

It's partly that my data variables are now in the map object and, from the help, I only know how to refer to zcol= names of these, rather than some transformations on the underlying data.

--
Michael Friendly Email: friendly AT yorku DOT ca Professor, Psychology Dept.
York University      Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele Street    http://www.math.yorku.ca/SCS/friendly.html
Toronto, ONT  M3J 1P3 CANADA

_______________________________________________
R-sig-Geo mailing list
[email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to