[R-sig-Geo] Manipulating SpatialPolygonsDataFrames

Roger Bivand Roger.Bivand at nhh.no
Tue Apr 3 21:00:27 CEST 2007


On Tue, 3 Apr 2007, Rob Robinson wrote:

> Dear All,
>  I am trying to combine various layers of data into a single image. The last
> layer is a sea mask to blank out some extraneous kernel areas. I have a map
> (read in from an ESRI shapefile using readShapePoly) as a
> SpatialPolygonsDataFrame, which obviously has all the countries as
> 'foreground', does anyone know of an easy to invert this, so the sea becomes
> forground? I can see in principle you might be able to do something with the
> RingDir slot (to turn polygons into holes and vice versa), but can't figure
> out how to access it to try.

It isn't that easy, unfortunately. You'll need not only to create an outer 
rectangle, but also to link up all of the internal holes so that the first 
fill of the mask doesn't flood the holes. That is, polygons are drawn from 
largest to smallest, so your initial graphic will be covered by the 
external mask first. 

Could the kernel points/rasters be overlay()ed over the land first, and
then select (as say SpatialPixels) the ones to image() if falling on land?

Roger

>  Any hints gratefully received!
> Cheers
> rob
> 
> *** Want to know about Britain's birds? Try  www.bto.org/birdfacts ***
> 
> Dr Rob Robinson, Senior Population Biologist
> British Trust for Ornithology, The Nunnery, Thetford, Norfolk, IP24 2PU
> Ph: +44 (0)1842 750050         E: rob.robinson at bto.org
> Fx: +44 (0)1842 750030         W: http://www.bto.org
> eSafe scanned this email for viruses, vandals and malicious content (!)
> 
> ==== "How can anyone be enlightened, when truth is so poorly lit" =====
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> 

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no




More information about the R-sig-Geo mailing list