[R-sig-Geo] rbind and spRbind

Roger Bivand Roger.Bivand at nhh.no
Sat Jul 26 21:06:49 CEST 2008


On Sat, 26 Jul 2008, Danlin Yu wrote:

> Agustin:
>
> Since you are using the sp method for binding, I suppose the coordinates (in 
> UTM project according to the name) are added automatically (as the added two 
> new names are UTMX and UTMY). Why not check these two values to see what's in 
> them.

Yes, that's right. Your (cryptic) SPDF is a SpatialPointsDataFrame (could 
be Pixels or Polygons too ...), where the as(, "data.frame") coercion 
method adds back the columns "hidden" by the coordinates()<- assignment 
step earlier. spRbind uses the coercion method, rbind grabs the data slot 
with the @ operator. Both are acceptable.

Roger

>
> Hope this helps.
>
> Danlin
>
>
> Agustin Lobo wrote:
>>  I'm a bit confused with the following:
>>
>>  I have a SPDF object ika1v4
>> 
>> >  dim(ika1v4geo at data)
>>  [1] 693  23
>> >  dim(ika1v4geo)
>>  [1] 693  23
>>
>>  Then I do an rbind:
>> 
>> >  a <- rbind(ika1v4geo,ika1v4geo)
>> >  dim(a)
>>  [1] 1386   23
>> >  dim(a at data)
>>  [1] 1386   23
>>
>>  But spRbind introduces 2 variables:
>> >  a2 <- spRbind(ika1v4geo,ika1v4geo)
>> >  dim(a2)
>>  [1] 1386   25
>> >  dim(a2 at data)
>>  [1] 1386   25
>> 
>> >  names(a at data)
>>   [1] "IKAPUNTO" "IKAID"    "CN"       "dia"      "hora_obs" "GPSID"
>>   [7] "GPS"      "N_PUNTO"  "GUIA"     "MONITOR"  "COD_SP_C" "SP_C"
>>  [13] "COD_OBS"  "OBS"      "N"        "VULN"     "VULNT"    "CL"
>>  [19] "A"        "H"        "D"        "S"        "V"
>> >  names(a2 at data)
>>   [1] "IKAPUNTO" "IKAID"    "CN"       "dia"      "hora_obs" "GPSID"
>>   [7] "GPS"      "UTMX"     "UTMY"     "N_PUNTO"  "GUIA"     "MONITOR"
>>  [13] "COD_SP_C" "SP_C"     "COD_OBS"  "OBS"      "N"        "VULN"
>>  [19] "VULNT"    "CL"       "A"        "H"        "D"        "S"
>>  [25] "V"
>> > 
>>
>>  Why? Which are the differences between rbind and spRbind?
>>
>>  Thanks!
>>
>>  Agus
>
>

-- 
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