[R-sig-Geo] How to neighbours list functions match coords?
Lee Hachadoorian
Lee.Hachadoorian+L at gmail.com
Tue Nov 9 22:03:54 CET 2010
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"
--Lee
--
Lee Hachadoorian
PhD Student, Geography
Program in Earth & Environmental Sciences
CUNY Graduate Center
--
Lee Hachadoorian
PhD Student, Geography
Program in Earth & Environmental Sciences
CUNY Graduate Center
More information about the R-sig-Geo
mailing list