[R-sig-Geo] distance between centroids

Robert J. Hijmans r.hijmans at gmail.com
Thu Oct 23 19:00:39 CEST 2014


Alessandra,

This is pretty straightforward but you need to do your part (show us
what you have done) using a simple reproducible example. For example,
you can use the North Carolina data that comes with spdep. That
package also allows you to identify neighbors.


library(spdep)
library(raster)
nc <- shapefile(system.file("etc/shapes/sids.shp", package="spdep"))
crs(nc) <- "+proj=longlat +ellps=clrk66"


?poly2nb

....

Robert


On Thu, Oct 23, 2014 at 3:48 AM, Alessandra Carioli
<alessandracarioli at gmail.com> wrote:
> Dear all,
>
> I am trying to compute the average distance between centroids and between neighbors, starting from a spatial polygon shape file.
> What I am doing is compute the average distance between all centroids and compute the average distance between neighbors for different regions in order to better compare them. (Some are densely populated and have more centroids, others are the opposite).
> Does anyone have any ideas? I am sure it should be pretty simple.
>
> So far I have used dist but does not give me what I want.
>
> Bests,
>
> Ale
>         [[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



More information about the R-sig-Geo mailing list