Ilona Naujokaitis-Lewis wrote:
NO
Dear list-serve,
Thanks in advance to all those who help out with the inquiries, it is has
helped me numerous times. Here go my questions...
I am trying to vary existing landscapes which are composed of habitat
(patches) and non-habitat. My goals are to vary the number of patches in a
landscape, and the size of each patch.
My landscape files are originally raster files, which I have converted to
ascii format. When importing into R, they are of class SpatialGridDataFrame,
are fully gridded. Each cell is represented by a 0: non-habitat, or a value
ranging between >0 and <=1, which represents varying degrees of habitat
quality. Patches are simply identified where adjoining cells are
The approach I have taken is to create a mask of my ascii landscape file so
that already existing patches are masked. This allows me to sample a point
in the region of my landscape that is identified as non-habitat. I then
apply the dilate function to essentially 'grow' a patch.
I have followed the code from the following link:
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/115868.html
The only difference is that once I have effected the dilate function, which
is of class 'owin', I then:
1) coerce "owin" to "im" object class
2) coerce "im" object class to a SpatialGridDataframe
My problems are:
1. How to overlay my final 2 layers: 1) dilated object (object class
SpatialGridDataFrame) and 2) original landscape patch layer (also object
class SpatialGridDataFrame). I need the resulting object to be an object of
class SpatialGridDataFrame with only 1 band consisting of original patches,
the new patches, and non-habitat so I can perform additional data
manipulations. The overlay function does not appear to work with 2 objects
of this class. Any alternative suggestions?
Method overlay only combines objects of different class. If you have two
grids and want to create a third, and all three have the same
topology/number of cells, then simply use vectorized expressions like
grd$out = grd$dilated != grd$original