[R-sig-Geo] subseting an spatial polygons data frame
Agustin Lobo
alobolistas at gmail.com
Thu Nov 12 18:19:28 CET 2009
Answering to myself:
This works fine:
plot(x[x at data$CODI_EQP!=413,])
plot(x[row.names(x)==20,])
Agus
Agustin Lobo wrote:
> I want to discard few polygons from an
> sp. poly. DF. I'm trying things such as:
> > str(x,max.level=2)
> Formal class 'SpatialPolygonsDataFrame' [package "sp"] with 5 slots
> ..@ data :'data.frame': 42 obs. of 9 variables:
> ..@ polygons :List of 42
> ..@ plotOrder : int [1:42] 32 35 38 1 8 29 33 26 27 31 ...
> ..@ bbox : num [1:2, 1:2] 437951 4605986 459732 4633538
> .. ..- attr(*, "dimnames")=List of 2
> ..@ proj4string:Formal class 'CRS' [package "sp"] with 1 slots
> >
> > x <- subset(x,row.names(x)!="1")
> Error in `[.data.frame`(x at data, i, j, ..., drop = FALSE) :
> undefined columns selected
>
> but the output of row.names(x)!="1"
> is correct, what am I doing wrong? Is subset() (from maptools) not
> appropriate for objects of type SPDF ?
>
> Thanks
>
> Agus
>
More information about the R-sig-Geo
mailing list