[R-sig-Geo] Reducing the size of the R-produced maps while saving

Karl Ove Hufthammer karl at huftis.org
Fri Feb 3 11:05:09 CET 2012

Roger Bivand wrote:

>> However, once the map is saved, I am getting a huge .emf file (e.g., 74
>> MB). Is there any way to save it in a smaller size?
> If you have to use a vector output format, then you should simplify the
> input, which has extremely detailed coastlines but coarser resolution
> administrative boundaries. Maybe try gSimplify() in rgeos.

Couldn’t (part of) the problem also be that the map object contains much 
more information than what is displayed? I have experienced this when 
plotting small parts of large maps using xlim and ylim. The resulting map 
displayed on screen and saved in a vector format (e.g., PDF) would show just 
the few countries within the xlim and ylim boundaries, but the file would 
actually contain (for example) the entire Eurasia continent (this could be 
seen by opening the file in Inkscape and moving map outlines or changing the 
boundary box).

The best solution is to crop the map object before saving. Note that for 
detailed map objects, this can be a *very* slow process. And the polygons 
are actually closed, so you will see black horizontal or vertical lines in 
the margin. I guess you could could crop the map to slightly outside the 
xlim and ylim boundaries before saving it to avoid this last problem.

Karl Ove Hufthammer

More information about the R-sig-Geo mailing list