neighbour patches

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

neighbour patches

Patrick Giraudoux
Hi,

I am tempted to dig in graph theory and analyse connections between
discrete landscape patches. Re-reading 'Applied Spatial Data Analysis
with R' I was happy to find basics chapter 9. However, it reports on
graphs where (euclidian) distance is computed between patch centroids.

Does anybody have an idea about strategies or packages permitting to use
the shortest distance between patch borders instead (which is more
realistic with regard to animal movement) ?

Patrick

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: neighbour patches

Jacob van Etten
Hi Patrick,

Nice question. This would be my approach:

#------------------------

library(raster)

#make "patches"
r <- raster(ncols=10, nrows=10)
r[] <- round(runif(ncell(r))*0.7)
rc <- clump(r)

#take a look
plot(rc)

#some preparation
n <- max(getValues(rc),na.rm=TRUE)
m <- matrix(NA,n,n)

#now calculate distances
for(i in 1:n)
{
  gd <- gridDistance(rc, origin=i)
  m[,i] <- zonal(gd, rc, min)[,2]
}

#and voilĂ 
m <- as.dist(m)
m

#------------------------

Alternatively, you could use the function distance() instead of gridDistance(). The advantage of gridDistance() is that you can indicate if animals can or cannot move through certain areas (optional argument 'omit', now not used). The disadvantage is that it is less precise than distance() -- it creates 'hexagonal' distance patterns.

Jacob.

--- On Sat, 26/2/11, Patrick Giraudoux <[hidden email]> wrote:

> From: Patrick Giraudoux <[hidden email]>
> Subject: [R-sig-Geo] neighbour patches
> To: [hidden email]
> Date: Saturday, 26 February, 2011, 8:54
> Hi,
>
> I am tempted to dig in graph theory and analyse connections
> between discrete landscape patches. Re-reading 'Applied
> Spatial Data Analysis with R' I was happy to find basics
> chapter 9. However, it reports on graphs where (euclidian)
> distance is computed between patch centroids.
>
> Does anybody have an idea about strategies or packages
> permitting to use the shortest distance between patch
> borders instead (which is more realistic with regard to
> animal movement) ?
>
> Patrick
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>


   
_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: neighbour patches

Roger Bivand
Administrator
In reply to this post by Patrick Giraudoux
On Sat, 26 Feb 2011, Patrick Giraudoux wrote:

> Hi,
>
> I am tempted to dig in graph theory and analyse connections between discrete
> landscape patches. Re-reading 'Applied Spatial Data Analysis with R' I was
> happy to find basics chapter 9. However, it reports on graphs where
> (euclidian) distance is computed between patch centroids.
>
> Does anybody have an idea about strategies or packages permitting to use the
> shortest distance between patch borders instead (which is more realistic with
> regard to animal movement) ?
>

If the patches are Polygons objects in a SpatialPolygons object, the
gDistance() function in rgeos on R-Forge does this for planar coordinates,
for example:

gDistance(SP, SP, byid=TRUE)

returns a square distance matrix.

Roger

> Patrick
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: [hidden email]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Roger Bivand
Department of Economics
Norwegian School of Economics
Helleveien 30
N-5045 Bergen, Norway