[R-sig-Geo] stplot - legend/classes of categorical vairable

richard.redweik at posteo.de richard.redweik at posteo.de
Wed Mar 4 11:45:17 CET 2015


Hello,

I have an object of class STFDF named 'fdf'. I want to create a stplot 
in which the categorical variable crop_id resp. crop_short is visualized 
per year.

Currently I am only able to assign a color/legend entry to a range of 
crop_ids, e.g. green --> [1, 2], yellow --> (2, 3]:

> col <- brewer.pal(8, "Accent")
> color <- colorRampPalette(col)(18)
> stplot(fdf[,, "crop_id"], col.regions=color, cuts=18)

However, this does mean, that the crop_ids 1 and 2 are assigned to 
green.
When changing the cuts parameter to cuts=19, I get an unambigious but 
not very readable assignment, e.g. green --> [1, 1.947], yellow --> 
(1.947, 2.895].

Now I am wondering, what is the best way to get one class resp. legend 
entry per crop_id, e.g. green --> 1, yellow --> 2 etc.

Does someone know how to do this?

Thanks in advance,
Richard

PS:
Summary of my fdf object:

> summary(fdf)
Object of class STFDF
  with Dimensions (s, t, attr): (17511, 11, 6)
[[Spatial:]]
Object of class SpatialPoints
Coordinates:
       min     max
x 3464500 3654500
y 2828500 3026500
Is projected: NA
proj4string : [NA]
Number of points: 17511
[[Temporal:]]
      Index                       timeIndex
  Min.   :1995-01-01 00:00:00   Min.   : 1.0
  1st Qu.:1997-07-02 12:00:00   1st Qu.: 3.5
  Median :2000-01-01 00:00:00   Median : 6.0
  Mean   :2000-01-01 08:43:38   Mean   : 6.0
  3rd Qu.:2002-07-02 12:00:00   3rd Qu.: 8.5
  Max.   :2005-01-01 00:00:00   Max.   :11.0
[[Data attributes:]]
     objectid          crop_id        crop_short         year           
prob
  Min.   :3222754   Min.   : 1.00   WSWH   :79136   Min.   :1995   Min.   
:1
  1st Qu.:3255362   1st Qu.: 3.00   MAIF   :62594   1st Qu.:1997   1st 
Qu.:1
  Median :3287732   Median :10.00   RAPE   :13881   Median :2000   Median 
:1
  Mean   :3289614   Mean   :11.56   PULS   :10785   Mean   :2000   Mean   
:1
  3rd Qu.:3322247   3rd Qu.:19.00   WBAR   :10095   3rd Qu.:2003   3rd 
Qu.:1
  Max.   :3367519   Max.   :19.00   MAIZ   : 5069   Max.   :2005   Max.   
:1
                                    (Other):11061
  nuts_code
  FR25:192621



More information about the R-sig-Geo mailing list