[R-sig-Geo] spplot - sort legend (colorkey)

Florian Endel florian.endel at gmail.com
Fri Jan 8 01:00:44 CET 2010


Hi,

I downloaded and ploted maps from http://gadm.org/ for Austria and a 
special province:

### <CODE> ###

library(sp)
library(RColorBrewer)

# load from web
con <- url("http://gadm.org/data/rda/AUT_adm2.RData")
print(load(con)) # gadm hold all the data!
close(con)

# select one province
noe = new("SpatialPolygonsDataFrame")
noe = gadm[gadm$NAME_1=="Nieder\xf6sterreich",]

noe$NAME_1 = factor(noe$NAME_1)
noe$NAME_2 = factor(noe$NAME_2)

# utf8
noe_bez_names = iconv(noe$NAME_2, "ISO_8859-2", "UTF-8")
noe$bez = factor(noe_bez_names)

# plot
col = rainbow(length(levels(noe$bez)))
spplot(noe, zcol="bez", col.regions=col, col="white", scales=list(draw = 
TRUE), colorkey=TRUE)

### </CODE> ###

everything just works fine, but the legend (colorkey) is ordered in the 
wrong direction...

How can I rearrange / sort the legend?

--
greets
FloE



More information about the R-sig-Geo mailing list