[R-sig-Geo] ssplot freezes R [was] really slow plot of Portugal
Jon Skoien
jon.skoien at jrc.ec.europa.eu
Wed Sep 17 11:24:44 CEST 2014
Hi Agustin,
I didn't try all your commands last time, most plotting run faster for
me (Windows 7, R 3.1-1, sp 1.0-15, rgdal 0.8-16). If you call spplot
without selecting one of the features, it might be rather slow or freeze
as they have 70 columns => 70 maps. Do you really want to plot all these
maps in a matrix form? Anyway,
spplot(gadm, "Shape_Area")
should for example be faster. If you still struggle, you can look at the
result of summaryRprof() after running:
Rprof()
spplot(gadm, "shape_area")
Rprof(NULL)
and post it to the list if you have questions about it.
Hope this helps,
Jon
On 9/17/2014 10:31 AM, Agustin Diez Castillo wrote:
> Hi Jon,
> This explain why it takes so long for drawing but not why R is freezing with ssplot.
> Did you test this spplot in a no Mac machine?
> In my machine when working it takes 21000 times more to draw Portugal instead of the expected 126.
> Thanks
> On 16Sep, 2014, at 3:23 PM, Jon Skoien <jon.skoien at jrc.ec.europa.eu> wrote:
>
>> 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.
>>
>>
>
--
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