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

Florian Endel florian.endel at gmail.com
Fri Jan 8 10:41:52 CET 2010


Thanks - it worked perfectly :)

--
Florian


Edzer Pebesma wrote:
> Florian, please try
> 
> noe$bez1 = factor(noe$bez, levels = rev(levels(noe$bez)))
> spplot(noe, zcol="bez1", col.regions=rev(col), col="white", 
> scales=list(draw = TRUE), colorkey=TRUE)
> 
> Florian Endel wrote:
>> 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
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at stat.math.ethz.ch
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> 
>



More information about the R-sig-Geo mailing list