spRbind provides rbind-like methods for Spatial*DataFrame objects

Methods

obj = "SpatialPoints", x = "SpatialPoints"

rbind two SpatialPoints objects

obj = "SpatialPointsDataFrame", x = "SpatialPointsDataFrame"

rbind two SpatialPointsDataFrame objects

obj = "SpatialLines", x = "SpatialLines"

rbind two SpatialLines objects

obj = "SpatialLinesDataFrame", x = "SpatialLinesDataFrame"

rbind two SpatialLinesDataFrame objects

obj = "SpatialPolygons", x = "SpatialPolygons"

rbind two SpatialPolygons objects

obj = "SpatialPolygonsDataFrame", x = "SpatialPolygonsDataFrame"

rbind two SpatialPolygonsDataFrame objects

Note

In addition to the spRbind-methods, there are also rbind-methods for Spatial* objects. The differences are:

  1. spRbind-methods can bind 2 objects, whereas rbind-methods can bind multiple object

  2. some rbind can accept objects with duplicated IDs, for all spRbind-methods these have to be modified explicitly, e.g. by calling spChFIDs-methods

Author

Roger Bivand

Examples

xx <- readShapePoly(system.file("shapes/sids.shp", package="maptools")[1], 
  IDvar="FIPSNO", proj4string=CRS("+proj=longlat +ellps=clrk66"))
#> Warning: shapelib support is provided by GDAL through the sf and terra packages among others
summary(xx)
#> Object of class SpatialPolygonsDataFrame
#> Coordinates:
#>         min       max
#> x -84.32385 -75.45698
#> y  33.88199  36.58965
#> Is projected: FALSE 
#> proj4string : [+proj=longlat +ellps=clrk66 +no_defs]
#> Data attributes:
#>       AREA          PERIMETER         CNTY_         CNTY_ID            NAME   
#>  Min.   :0.0420   Min.   :0.999   Min.   :1825   Min.   :1825   Alamance : 1  
#>  1st Qu.:0.0910   1st Qu.:1.324   1st Qu.:1902   1st Qu.:1902   Alexander: 1  
#>  Median :0.1205   Median :1.609   Median :1982   Median :1982   Alleghany: 1  
#>  Mean   :0.1263   Mean   :1.673   Mean   :1986   Mean   :1986   Anson    : 1  
#>  3rd Qu.:0.1542   3rd Qu.:1.859   3rd Qu.:2067   3rd Qu.:2067   Ashe     : 1  
#>  Max.   :0.2410   Max.   :3.640   Max.   :2241   Max.   :2241   Avery    : 1  
#>                                                                 (Other)  :94  
#>       FIPS        FIPSNO         CRESS_ID          BIR74           SID74      
#>  37001  : 1   Min.   :37001   Min.   :  1.00   Min.   :  248   Min.   : 0.00  
#>  37003  : 1   1st Qu.:37050   1st Qu.: 25.75   1st Qu.: 1077   1st Qu.: 2.00  
#>  37005  : 1   Median :37100   Median : 50.50   Median : 2180   Median : 4.00  
#>  37007  : 1   Mean   :37100   Mean   : 50.50   Mean   : 3300   Mean   : 6.67  
#>  37009  : 1   3rd Qu.:37150   3rd Qu.: 75.25   3rd Qu.: 3936   3rd Qu.: 8.25  
#>  37011  : 1   Max.   :37199   Max.   :100.00   Max.   :21588   Max.   :44.00  
#>  (Other):94                                                                   
#>     NWBIR74           BIR79           SID79          NWBIR79       
#>  Min.   :   1.0   Min.   :  319   Min.   : 0.00   Min.   :    3.0  
#>  1st Qu.: 190.0   1st Qu.: 1336   1st Qu.: 2.00   1st Qu.:  250.5  
#>  Median : 697.5   Median : 2636   Median : 5.00   Median :  874.5  
#>  Mean   :1050.8   Mean   : 4224   Mean   : 8.36   Mean   : 1352.8  
#>  3rd Qu.:1168.5   3rd Qu.: 4889   3rd Qu.:10.25   3rd Qu.: 1406.8  
#>  Max.   :8027.0   Max.   :30757   Max.   :57.00   Max.   :11631.0  
#>                                                                    
xx$FIPSNO
#>   [1] 37001 37003 37005 37007 37009 37011 37013 37015 37017 37019 37021 37023
#>  [13] 37025 37027 37029 37031 37033 37035 37037 37039 37041 37043 37045 37047
#>  [25] 37049 37051 37053 37055 37057 37059 37061 37063 37065 37067 37069 37071
#>  [37] 37073 37075 37077 37079 37081 37083 37085 37087 37089 37091 37093 37095
#>  [49] 37097 37099 37101 37103 37105 37107 37109 37111 37113 37115 37117 37119
#>  [61] 37121 37123 37125 37127 37129 37131 37133 37135 37137 37139 37141 37143
#>  [73] 37145 37147 37149 37151 37153 37155 37157 37159 37161 37163 37165 37167
#>  [85] 37169 37171 37173 37175 37177 37179 37181 37183 37185 37187 37189 37191
#>  [97] 37193 37195 37197 37199
xx1 <- xx[xx$CNTY_ID < 1982,]
xx2 <- xx[xx$CNTY_ID >= 1982,]
xx3 <- spRbind(xx2, xx1)
summary(xx3)
#> Object of class SpatialPolygonsDataFrame
#> Coordinates:
#>         min       max
#> x -84.32385 -75.45698
#> y  33.88199  36.58965
#> Is projected: FALSE 
#> proj4string : [+proj=longlat +ellps=clrk66 +no_defs]
#> Data attributes:
#>       AREA          PERIMETER         CNTY_         CNTY_ID            NAME   
#>  Min.   :0.0420   Min.   :0.999   Min.   :1825   Min.   :1825   Alamance : 1  
#>  1st Qu.:0.0910   1st Qu.:1.324   1st Qu.:1902   1st Qu.:1902   Alexander: 1  
#>  Median :0.1205   Median :1.609   Median :1982   Median :1982   Alleghany: 1  
#>  Mean   :0.1263   Mean   :1.673   Mean   :1986   Mean   :1986   Anson    : 1  
#>  3rd Qu.:0.1542   3rd Qu.:1.859   3rd Qu.:2067   3rd Qu.:2067   Ashe     : 1  
#>  Max.   :0.2410   Max.   :3.640   Max.   :2241   Max.   :2241   Avery    : 1  
#>                                                                 (Other)  :94  
#>       FIPS        FIPSNO         CRESS_ID          BIR74           SID74      
#>  37001  : 1   Min.   :37001   Min.   :  1.00   Min.   :  248   Min.   : 0.00  
#>  37003  : 1   1st Qu.:37050   1st Qu.: 25.75   1st Qu.: 1077   1st Qu.: 2.00  
#>  37005  : 1   Median :37100   Median : 50.50   Median : 2180   Median : 4.00  
#>  37007  : 1   Mean   :37100   Mean   : 50.50   Mean   : 3300   Mean   : 6.67  
#>  37009  : 1   3rd Qu.:37150   3rd Qu.: 75.25   3rd Qu.: 3936   3rd Qu.: 8.25  
#>  37011  : 1   Max.   :37199   Max.   :100.00   Max.   :21588   Max.   :44.00  
#>  (Other):94                                                                   
#>     NWBIR74           BIR79           SID79          NWBIR79       
#>  Min.   :   1.0   Min.   :  319   Min.   : 0.00   Min.   :    3.0  
#>  1st Qu.: 190.0   1st Qu.: 1336   1st Qu.: 2.00   1st Qu.:  250.5  
#>  Median : 697.5   Median : 2636   Median : 5.00   Median :  874.5  
#>  Mean   :1050.8   Mean   : 4224   Mean   : 8.36   Mean   : 1352.8  
#>  3rd Qu.:1168.5   3rd Qu.: 4889   3rd Qu.:10.25   3rd Qu.: 1406.8  
#>  Max.   :8027.0   Max.   :30757   Max.   :57.00   Max.   :11631.0  
#>                                                                    
xx3$FIPSNO
#>   [1] 37007 37013 37017 37019 37021 37025 37031 37035 37039 37043 37045 37047
#>  [13] 37049 37051 37055 37061 37071 37075 37079 37085 37087 37089 37093 37095
#>  [25] 37099 37101 37103 37105 37107 37109 37113 37119 37123 37125 37129 37133
#>  [37] 37137 37141 37147 37149 37153 37155 37161 37163 37165 37167 37173 37175
#>  [49] 37179 37191 37001 37003 37005 37009 37011 37015 37023 37027 37029 37033
#>  [61] 37037 37041 37053 37057 37059 37063 37065 37067 37069 37073 37077 37081
#>  [73] 37083 37091 37097 37111 37115 37117 37121 37127 37131 37135 37139 37143
#>  [85] 37145 37151 37157 37159 37169 37171 37177 37181 37183 37185 37187 37189
#>  [97] 37193 37195 37197 37199