[R-sig-Geo] really slow plot of Portugal

Jon Skoien jon.skoien at jrc.ec.europa.eu
Tue Sep 16 15:23:22 CEST 2014


Hi Augustin,
I guess this is related to the complexity of the border. Switzerland is 
defined by some nice lines (although not as simple as some of the 
borders in Sahara), Portugal and Spain have coastlines which can be 
rather complex, including their islands. Setting
prt = gadm
che = gadm
after downloading each of them, I get:
 > object.size(che)
63296 bytes
 > object.size(prt)
8013800 bytes
The SpatialPolygonsDataFrame-object of Portugal is 126 times the 
corresponding of Switzerland, additionally I guess there is also some 
non-linear scaling of the plotting time. To reduce plotting time for 
Portugal and Spain, you can try gSimplify from rgeos.

Cheers,
Jon





On 9/16/2014 2:11 PM, Agustin Diez Castillo wrote:
> Hi,
> I don�t know if this is related with the crisis, but Switzerland works wether Portugal or Spain take forever and even freezes R. Same with spplot. Any clues?
> # Switzerland
> library(sp)
> con <- url("http://gadm.org/data/rda/CHE_adm0.RData")
> print(load(con))
> [1] "gadm"
> close(con)
> plot(gadm)
> system.time(plot(gadm))
>    user  system elapsed
>   0.026   0.001   0.028
> system.time(spplot(gadm))
>    user  system elapsed
>   0.022   0.000   0.022
>
> #Portugal, sometimes the session got halted for a while, even with the system claiming that R is not responding (in mac)
> con <- url("http://gadm.org/data/rda/PRT_adm0.RData")
> print(load(con))
> close(con)
> [1] "gadm"
> system.time(plot(gadm))
>    user  system elapsed
> 556.032   1.133 565.243
>
> #Spain
> con <- url("http://gadm.org/data/rda/ESP_adm0.RData")
> print(load(con))
> [1] "gadm"
> close(con)
> system.time(plot(gadm))
>    user  system elapsed
> 62.595   0.237  62.974
>
> sessionInfo()
> R version 3.1.1 Patched (2014-07-13 r66131)
> Platform: x86_64-apple-darwin10.8.0 (64-bit)
>
> locale:
> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
>
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base
>
> other attached packages:
> [1] rgeos_0.3-6     maptools_0.8-30 sp_1.0-15
>
> loaded via a namespace (and not attached):
>   [1] colorspace_1.2-4 digest_0.6.4     dismo_0.9-3      foreign_0.8-61   ggplot2_1.0.0    grid_3.1.1       gtable_0.1.2     lattice_0.20-29  MASS_7.3-33
> [10] munsell_0.4.2    plyr_1.8.1       proto_0.3-10     raster_2.2-31    Rcpp_0.11.2      reshape2_1.4     scales_0.2.4     stringr_0.6.2    tools_3.1.1
>
>
> 	[[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
>

-- 
Jon Olav Skøien
Joint Research Centre - European Commission
Institute for Environment and Sustainability (IES)
Climate Risk Management Unit

Via Fermi 2749, TP 100-01,  I-21027 Ispra (VA), ITALY

jon.skoien at jrc.ec.europa.eu
Tel:  +39 0332 789205

Disclaimer: Views expressed in this email are those of the individual 
and do not necessarily represent official views of the European Commission.



More information about the R-sig-Geo mailing list