[R-sig-Geo] merging sp objects
Roger Bivand
Roger.Bivand at nhh.no
Tue Jul 1 23:40:59 CEST 2008
On Tue, 1 Jul 2008, David Hugh-Jones wrote:
> OK, writing http://wiki.r-project.org/rwiki/doku.php?id=tips:spatial-data:merging,
> a question comes up:
>
> I am trying to rbind() two SpatialLines (or SpatialPolygons or
> whatever) objects and I keep getting the error that they have
> overlapping IDs - not surprisingly as they were independently created.
> Is there a simple way to give new IDs to these objects, and to know
> how many I have to give?
?spChFIDs in maptools for the methods, but the choice of unique IDs will
depend on your domain. The default readOGR IDs are the feature IDs,
usually 0:(n-1), which will not be unique. If there are known official
codes, like US FIPS codes, they can be used to disambiguate. You can use
unique(c(IDs_A, IDs_B)) to proceed. Have you looked at spRbind methods in
maptools as an alternative to rbind.* in sp?
Roger
>
> David Hugh-Jones
> PhD Candidate
> Essex University Department of Government
> http://davidhughjones.googlepages.com
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at 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.Bivand at nhh.no
More information about the R-sig-Geo
mailing list