[R-sig-Geo] thinning a SpatialPolygonsDataFrame

Michael Friendly friendly at yorku.ca
Wed Nov 18 20:18:10 CET 2009


I think, for my application, I'd be happy with the D-P polyline 
simplification algorithm, because that is what is used
in SAS (worked well), and I don't think there are unusual topologies in 
my map of France that would be so severely
out of whack as to lead to *significant* visual artifacts.  In fact, you 
might well expect some artifacts from any visual
thinning, but it's a matter of the tradeoff in the way the thinned map 
is used in a visualization.  Mark Monmonier's
US Visibility Map might be an extremely thinned, but highly useful example.

For R spatial analysis, I think this is worth pursuing and integrating 
into sp methods.  In SAS, proc greduce works simply
by adding another variable, density, to the (x,y) coordinates of the 
spatial polygons, density %in% 1:5, where density==5
is the full map.  It is then a simple matter to subset the polygon 
outlines by saying

data smallmap;
    set mymap;
    where density<4;

or

proc gmap map=mymap(where=(density<4));
 ...

Meanwhile, I can't see easily how I could use shapefiles::dp() to thin 
my Guerry::gfrance maps, because the documentation is,
shall we say, somewhat thin. 

-Michael



Roger Bivand wrote:
> On Wed, 18 Nov 2009, Pinaud David wrote:
>
>> Hi Michael,
>> maybe you should try the function dp() in the package shapefiles that 
>> is an implementation of the Douglas-Peucker polyLine simplification 
>> algorithm.
>
> Note that its help page does warn that it is not topology-preserving, 
> that is that lines are generalised, but that coincident lines 
> (boundaries of neighbouring polygons) may be generalised differently. 
> GEOS offers a topology-preserving line generalisation facility, which 
> ought to take longer but do better than dp(), because it will not lead 
> to visual artefacts (overlapping polygons, interpolygon slivers, etc.).
>
> Roger
>
>> HTH
>> David
>>
>> Michael Friendly a écrit :
>>> The Guerry package contains two maps of france (gfrance, gfrance85) 
>>> which are quite detailed and large in size (~900K).
>>> In writing a vignette for the package, there are quite a few figures 
>>> that use the map multiple times in a layout, and
>>> consequently result in huge file sizes for the .PDF files created.  
>>> For these purposes, the map need not be nearly
>>> so detailed.
>>>
>>> I'm wondering if there is a facility to "thin" the map by drawing it 
>>> at a lower density of lines in the polygon regions.
>>> When I was working with SAS, there was a GREDUCE procedure that did 
>>> this nicely.
>>>
>>> thanks,
>>> -Michael
>>>
>>
>>
>


-- 
Michael Friendly     Email: friendly AT yorku DOT ca 
Professor, Psychology Dept.
York University      Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele Street    http://www.math.yorku.ca/SCS/friendly.html
Toronto, ONT  M3J 1P3 CANADA



More information about the R-sig-Geo mailing list