On Tue, 18 May 2010, Agustin Lobo wrote:
Hi!
I have a set of shapefiles, each one with one single polygon, and I
want to end up with one single SpPolDF including all polygons.
I read the set of shapefiles with readOGR() and thus get one SpPolDF
for each polygon.
I (unsuccessfully) try:
delme <- rbind.SpatialPolygonsDataFrame(BesosBoundary,TerBoundary)
Error in validObject(.Object) :
invalid class "SpatialPolygons" object: non-unique Polygons ID slot values
What about using spChFIDs() to assign unique FIDs? For example:
BesosBoundary <- spChFIDs(BesosBoundary, paste("Besos",
row.names(BesosBoundary), sep="_"))
and so on. As it is, all will have "0", "1", ..., which are then not
unique when rbind'ed. The user needs to control the FIDs, so needs to
assign unique values before rbind.
Roger
Calls: rbind.SpatialPolygons ... SpatialPolygons -> new -> initialize
-> initialize -> validObject
delme <- rbind.SpatialPolygonsDataFrame(BesosBoundary[1],TerBoundary[1])
Error in validObject(.Object) :
invalid class "SpatialPolygons" object: non-unique Polygons ID slot values
Calls: rbind.SpatialPolygonsDataFrame ... SpatialPolygons -> new ->
initialize -> initialize -> validObject
delme <-
rbind.SpatialPolygonsDataFrame(besosbound...@polygons,terbound...@polygons)
Error in as(x, "SpatialPolygons") :
no method or default for coercing "list" to "SpatialPolygons"
Calls: rbind.SpatialPolygonsDataFrame -> do.call -> lapply -> FUN -> as
and some other variants.
Any help on how to do this? A solution would be using joinPolys from
maptools (the polygons do not overlap), but think that
rbind.SpatialPolygonsDataFrame() is better suited for this operation.
Agus
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@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.biv...@nhh.no
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo