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

Edzer Pebesma edzer.pebesma at uni-muenster.de
Fri Sep 12 10:06:02 CEST 2014


if this is knearneigh in spdep, the documentations says:

     knearneigh(x, k=1, longlat = NULL, RANN=TRUE)

Arguments:

       x: matrix of point coordinates or a SpatialPoints object
       ...

if the documentation is correct, it should not work with spatial
polygons objects for x. Maybe you meant:

knearneigh(coordinates(gadmsimpl4_poly), k = 4, longlat = FALSE)

in order to find the knn's from the polygon centroids?

On 09/12/2014 09:35 AM, 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".
> 
> 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
> 

-- 
Edzer Pebesma
Institute for Geoinformatics (ifgi), University of Münster
Heisenbergstraße 2, 48149 Münster, Germany. Phone: +49 251
83 33081 http://ifgi.uni-muenster.de GPG key ID 0xAC227795

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: OpenPGP digital signature
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20140912/5ce451bb/attachment.bin>


More information about the R-sig-Geo mailing list