[R-sig-Geo] Using rbind with SpatialLinesDataFrame

Edzer Pebesma edzer.pebesma at uni-muenster.de
Tue Jul 5 23:24:01 CEST 2011


Please try:

row.names(basin1) = 2029:4682
row.names(basin2) = 1:2028
rbind(basin1, basin2)


On 07/05/2011 08:13 PM, Jonathan Callahan wrote:
> I have a rather large dataset of watershed data stored as a
> SpatialLinesDataFrame. I can plot and subset the data just fine.
> 
> In an effort to speed up plotting times I have broken up the watershed into
> separate basins so that I can load and plot only those basins in my region
> of interest. (This improves performance quite a lot.)
> 
> I would like to use "subWatershed = rbind(basin1,basin2,...)" to
> reconstitute a single SpatialLinesDataFrame from just a few of the basins.
> 
> My problem is that the row.names in the sub-basins retain the row.names from
> the original dataset:
> 
> rownames(basin1 at data) = 2029:4682
> rownames(basin2 at data) = 1:2028
> 
> When I use rbind(basin1,basin2) I get the following error:
> 
> Error in SpatialLinesDataFrame(ll, df) :
>   row.names of data and Lines IDs do not match
> 
> If I reverse the ordering and use rbind(basin2,basin1) everything is OK but
> I want to do this reconstitution programmatically. I won't know ahead of
> time which basins are involved or what their ordering is. In the future I
> might also use basins from adjacent watersheds which have separate numbering
> schemes.
> 
> Can anyone explain to me what exactly this error means and how I might
> resolve it?
> 
> Thanks in advance,
> 
> Jon
> 
> 

-- 
Edzer Pebesma
Institute for Geoinformatics (ifgi), University of Münster
Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251
8333081, Fax: +49 251 8339763  http://ifgi.uni-muenster.de
http://www.52north.org/geostatistics      e.pebesma at wwu.de



More information about the R-sig-Geo mailing list