[R-sig-Geo] knearneigh: data non-numeric
Andreas Forø Tollefsen
andreasft at gmail.com
Fri Sep 12 10:11:12 CEST 2014
Absolutely. I think it was just too early in the morning.
I forgot the difference between using poly2nb and knearneigh.
Using coordinates() works fine.
Sorry for the confusion.
2014-09-12 10:06 GMT+02:00 Roger Bivand <Roger.Bivand at nhh.no>:
> On Fri, 12 Sep 2014, Andreas Forø Tollefsen wrote:
> Hi all,
>> I have never experienced this issue before, but I assume there is
>> in my spatialpolygondataframe causing this.
>> Whenever I try to create a knn object using these data, I get the error
>> "knearneigh: data non-numeric".
> Which versions of the function actually worked with a
> SpatialPolygonsDataFrame? As far as I can see, this has always failed with
> the same error message; since 2007 x can be an object inheriting from
> The justification is to oblige the user to acknowledge that while point
> support is accepted without question, the change of support from areal to
> point is something the user needs to take responsibility for, for example
> using coordinates() to extract the label point of the largest exterior ring
> in the Polygons object.
> Hope this clarifies,
>> The code used:
>> knearneigh(gadmsimpl4_poly,k = 4,longlat = FALSE)
>> Error in knearneigh(gadmsimpl4_poly, k = 4, longlat = FALSE) :
>> knearneigh: data non-numeric
>> Any ideas what might be causing this error? I cannot remember seeing this
>>  "SpatialPolygonsDataFrame"
>>  "sp"
>>> length(colnames(gadmsimpl3_poly at data))
>>  84
>>  1095
>>> gadmsimpl3_poly at bbox
>> min max
>> x -25.36181 50.48654
>> y -34.63487 25.00001
>>> gadmsimpl3_poly at proj4string
>> CRS arguments:
>> +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0
>> [[alternative HTML version deleted]]
>> R-sig-Geo mailing list
>> R-sig-Geo at r-project.org
> Roger Bivand
> Department of Economics, Norwegian School of Economics,
> Helleveien 30, N-5045 Bergen, Norway.
> voice: +47 55 95 93 55; fax +47 55 95 91 00
> e-mail: Roger.Bivand at nhh.no
[[alternative HTML version deleted]]
More information about the R-sig-Geo