[R-sig-Geo] How to neighbours list functions match coords?

Edzer Pebesma edzer.pebesma at uni-muenster.de
Tue Nov 9 22:12:25 CET 2010



On 11/09/2010 10:03 PM, Lee Hachadoorian wrote:
> On Tue, 09 Nov 2010 21:19:45 +0100, Edzer Pebesma wrote:
> 
>> On 11/09/2010 09:05 PM, Lee Hachadoorian wrote:
>>>
>>> row.names(spdf) = as.character(spdf$key_field) sp = as(spdf,
>>> "SpatialPolygons")
>>> row.names(df) = df$key_field
>>> spdfNew = SpatialPolygonsDataFrame(sp, df, match.ID = TRUE)
>>
>> It would be rather trivial to make the following work:
>>
>> spdfNew = SpatialPolygonsDataFrame(sp, df, match.ID = "key_field")
>>
>> which would do the same as the last two of your commands.
> 
> match.ID is a logical, not a field name, so that doesn't work. From the
> documentation:
> 
> "match.ID   logical: (default TRUE): match SpatialPolygons member
> Polygons ID slot values with data frame row names, and re-order the data
> frame rows if necessary"
> 

You're right of course, sorry for the misunderstanding, I meant to say
"to modify sp such that ... works"
-- 
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