[R-sig-Geo] How to delete a single polygon in a shape file

Roger Bivand Roger.Bivand at nhh.no
Tue May 11 13:16:36 CEST 2010


On Fri, 7 May 2010, Everton Emanuel wrote:

> Dear all,
>
> I have a small problem, and hope to get some help from you guys.
>
> I have a shape file of Brazilian micro regions; in order to estimate spatial
> correlation I need to construct a weight scheme of this shape. However, the
> shape contains "islands" that unables its construction. I want to know how
> is it possible to manipulate the original shape and erase these islands?

I'm not sure what you mean. If you want to subset a 
SpatialPolygonsDataFrame, use the "[" method:

sub <- <logical vector of same length as dim(a)[1]>
asub <- a[sub, ]

If you really want to drop the subset in order to generate spatial 
weights, you could do it in this way. However, you could use a graph-based 
method that would retain off-shore islands if they are substantive 
records. I don't think that you are obliged to drop islands in order to 
construct weights.

Hope this helps,

Roger

>
> I appreciate any help,
>
> Everton.
>

-- 
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