[R-sig-Geo] knearneigh: data non-numeric

Roger Bivand Roger.Bivand at nhh.no
Fri Sep 12 10:06:46 CEST 2014


On Fri, 12 Sep 2014, Andreas Forø Tollefsen wrote:

> Hi all,
>
> I have never experienced this issue before, but I assume there is something
> 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 
SpatialPoints.

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,

Roger

>
> 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
> before.
>
> Andreas
>
> Metadata:
>> class(gadmsimpl3_poly)
> [1] "SpatialPolygonsDataFrame"
> attr(,"package")
> [1] "sp"
>> length(colnames(gadmsimpl3_poly at data))
> [1] 84
>> length(gadmsimpl3_poly)
> [1] 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
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

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


More information about the R-sig-Geo mailing list