[R-sig-Geo] Blank polygons in stplot

Roman Luštrik roman.lustrik at gmail.com
Tue May 5 15:37:48 CEST 2015


Hum, the values for Washington are near 10 (black) according to the palette
you specify.

> SAGA_pal[4]
$SG_COLORS_RED_BLACK
 [1] "#FF0000" "#F10000" "#E40000" "#D60000" "#C90000" "#BB0000" "#AE0000"
"#A10000" "#930000" "#860000" "#780000" "#6B0000" "#5D0000" "#500000"
[15] "#430000" "#350000" "#280000" "#1A0000" "#0D0000" "#000000"

> was <- as.data.frame(Produc.st[,'1970/1972' , "unemp"])
> was[was$sp.ID == "washington", ]
           V1       V2      sp.ID       time    endTime timeIndex unemp
45  -120.3957 47.37073 washington 1970-01-01 1971-01-01         1   9.1
93  -120.3957 47.37073 washington 1971-01-01 1972-01-01         2  10.0
141 -120.3957 47.37073 washington 1972-01-01 1973-01-01         3   9.5

Cheers,
Roman



On Tue, May 5, 2015 at 3:08 PM, Edoardo Baldoni <edoardo.baldoni at gmail.com>
wrote:

> Hi all,
>
> I am using the function stplot to visualize data in STFDFs and find that
> the function does not seem to work properly when the STFDF is subsetted. In
> particular, the output of the plot function seems to miss some data as
> SpatialPolygons that should appear as colored are instead just
> white-colored (blank). Is there any bug in the code or am I missing
> something ?
>
> The  issue can be replicated using the example presented at page 17 of the
> spacetime article in the Journal of Statistical Software:
>
> library("spacetime")
> library("maps")
> library("plotKML")
>  states.m <- map("state", plot = FALSE, fill = TRUE)
> IDs <- sapply(strsplit(states.m$names, ":"), function(x) x[1])
> library("maptools")
>  states <- map2SpatialPolygons(states.m, IDs = IDs)
> yrs <- 1970:1986
>  time <- as.POSIXct(paste(yrs, "-01-01", sep = ""), tz = "GMT")
> library("plm")
> data("Produc")
> Produc.st <- STFDF(states[-8], time, Produc[order(Produc[2], Produc[1]),])
>  library("RColorBrewer")
>  stplot(Produc.st[,'1970/1972' , "unemp"], col.regions = SAGA_pal[[4]])
>
> The difference between the code above and the one of the article is the
> color used and the STFDF that here is subsetted. The state of Washington in
> 1971 appears blank while it should be colored according to the palette
> color. This error comes out with every STFDF I use.
> Can anyone help me fixing the issue ?
>
> Thanks
>
> Edoardo
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>



-- 
In God we trust, all others bring data.

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list