[R-sig-Geo] sp::overlay() not conserving row.names ?

Agustin Lobo alobolistas at gmail.com
Wed Jul 6 17:28:17 CEST 2011


I'm using sp::overlay between a SpPolDF and a SpPointsDF:

> delme <- overlay(rndp,q1km, fn = mean)
> class(q1km)
[1] "SpatialPolygonsDataFrame"
attr(,"package")
[1] "sp"
> class(rndp)
[1] "SpatialPointsDataFrame"
attr(,"package")
[1] "sp"
> class(delme)
[1] "data.frame"

but I'm confused by the fact that the row.names(delme) are not the same
as the row.names(q1km):
> delme[1:10,]
          ID       id      val
X1  356.3333 357.3333 643.3162
X2  454.3333 455.3333 653.1833
X3  305.0000 306.0000 101.8930
X4  486.7143 487.7143 448.4612
X5  456.2500 457.2500 544.1646
X6  255.4000 256.4000 139.7507
X7  403.6667 404.6667 659.8114
X8  462.5000 463.5000 537.7209
X9  629.2000 630.2000 399.1040
X10 416.5000 417.5000 278.2879
> q1km at data[1:10,]
   idname ID   XMIN   XMAX   YMIN   YMAX
X0     X0  0 -8.994 -8.594 43.595 43.995
X1     X1  1 -8.594 -8.194 43.595 43.995
X2     X2  2 -8.194 -7.794 43.595 43.995
X3     X3  3 -7.794 -7.394 43.595 43.995
X4     X4  4 -7.394 -6.994 43.595 43.995
X5     X5  5 -6.994 -6.594 43.595 43.995
X6     X6  6 -6.594 -6.194 43.595 43.995
X7     X7  7 -6.194 -5.794 43.595 43.995
X8     X8  8 -5.794 -5.394 43.595 43.995
X9     X9  9 -5.394 -4.994 43.595 43.995

Is this the way it has to be? If it is, then it's kind of inconvenient
as I would like to join the new table "delme" to q1km at data.
It seems I just have to subtract 1 to the numeric part of
row.names(delme), but would like to make sure.

Agus



More information about the R-sig-Geo mailing list