Skip to content
Prev 1412 / 29559 Next

Problems graphing shapefiles with detailed boundaries

On Thu, 19 Oct 2006 matt.pettis at thomson.com wrote:

            
This is a simple mistake in subsetting, you have to specify the chosen 
values in an appropriate way:

x12 <- vtd[vtd[["SEN"]] == 1 | vtd[["SEN"]] == 2, "SEN"]
spplot(x12)
I'm not sure whether the above clears up the problems, I'd also use 
vtd$SEN rather than vtd[["SEN"]], less error prone unless you need to 
insert the fiel/column name as a string.

I can also see the internal debris in vtd$SEN == 2, those are slivers 
from the original shapefile:

x2 <- vtd[vtd[["SEN"]]  == 2,]
x <- unionSpatialPolygons(x2, x2[["SEN"]])
plot(x)
summary(sapply(slot(slot(x, "polygons")[[1]], "Polygons"), function(x) 
  slot(x, "area")))

is:

     Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
7.485e-05 2.075e-02 9.230e-02 2.593e+08 3.406e-01 1.996e+10 

so pruning the output object to leave only the large polygon is an option.

Hope this helps,

Roger