[R] dnearneigh::spdep: undesired behaviour with SpatialPoints object: bug or feature? Please confirm.

Jan Holstein jan.holstein at awi.de
Mon Mar 24 11:04:13 CET 2014


Dear Roger,

thanks for pointing out

> This will only generate compliant behaviour when rgdal is loaded,
> converting 
> +init=epsg:4326 to +init=epsg:4326 +proj=longlat +datum=WGS84 +no_defs 
> +ellps=WGS84 +towgs84=0,0,0, so that is.projected(spdf) is FALSE 



> which was the intention - either provide an object inheriting from 
> SpatialPoints, with longlat set internally, or set it manually. Following 
> the removal of the logic bug: 

> dnearneigh(as(spdf,"SpatialPoints"), 0, 20, longlat = TRUE) 
> #Neighbour list object: 
> #Number of regions: 1000 
> #Number of nonzero links: 9288 
> #Percentage nonzero weights: 0.9288 
> #Average number of links: 9.288 
> #Warning message: 
> #In dnearneigh(as(spdf, "SpatialPoints"), 0, 20, longlat = TRUE) : 
> #  dnearneigh: longlat overriden for Spatial object 

Of course you can have one argument overiding the other in case of conflict
(Now, is.projected(spdf) overides lonlat). 
Personally, I would be more restrict and have dnearneigh throw an error if
lonlat==is.projected.

Next time on 
> R-sig-geo 

Thanks,
Jan




-----
Jan M. Holstein, Dept. Functional Ecology, Alfred Wegener Institut for Polar and Marine Research (AWI)
--
View this message in context: http://r.789695.n4.nabble.com/dnearneigh-spdep-undesired-behaviour-with-SpatialPoints-object-bug-or-feature-Please-confirm-tp4687200p4687427.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list