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

Edzer Pebesma edzer.pebesma at uni-muenster.de
Wed Jul 6 17:35:03 CEST 2011


Agus, sp::overlay will be deprecated at some stage in favour of
sp::over, which is a more consistent and complete approach to the same
problem. For instance, overlay(x,y) would do the same as overlay(y,x),
which is not good, if you think about it a bit longer (my own mistake,
long time ago).

Could you please check if sp::over has the same problems? See also
http://cran.r-project.org/web/packages/sp/vignettes/over.pdf

On 07/06/2011 05:28 PM, Agustin Lobo wrote:
> 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
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

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