Skip to content

Manipulating SpatialPolygonsDataFrames

2 messages · Rob Robinson, Roger Bivand

#
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.
 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" =====
#
On Tue, 3 Apr 2007, Rob Robinson wrote:

            
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