[R-sig-Geo] Blank polygons in stplot

Edzer Pebesma edzer.pebesma at uni-muenster.de
Tue May 5 15:58:48 CEST 2015



On 05/05/2015 03:08 PM, Edoardo Baldoni 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! For now only specifying "at" will help, as in

stplot(Produc.st[,'1970/1972' , "unemp"], col.regions = SAGA_pal[[4]],
at = 3:11)

or else update to the spacetime version that fixed this with

devtools::install_github("edzer/spacetime")


> 
> 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
> 

-- 
Edzer Pebesma
Institute for Geoinformatics (ifgi),  University of Münster,
Heisenbergstraße 2, 48149 Münster, Germany; +49 251 83 33081
Journal of Statistical Software:   http://www.jstatsoft.org/
Computers & Geosciences:   http://elsevier.com/locate/cageo/
Spatial Statistics Society http://www.spatialstatistics.info

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: OpenPGP digital signature
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20150505/50cb3442/attachment.bin>


More information about the R-sig-Geo mailing list