[R-sig-Geo] overlay fx, consistent topology, sample a point on a 'patch edge'

Ilona Naujokaitis-Lewis ilonan at interchange.ubc.ca
Wed Feb 6 23:21:46 CET 2008


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
>0.

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? 

2. My dilated points object (SGDF) does not have topology identical to the
original layer - I think I need them to be the same for the overlay process,
and if yes, how do I change this. The cell size remains the same but the
offset and cell dimension are not identical.
For example:
	> getGridTopology(dilate_SGDF)
  	                  X1  X2
	cellcentre.offset 1050 890
	cellsize            20  20
	cells.dim           15  11
	> getGridTopology(original_layer)
        	             x   y
	cellcentre.offset 1030 870
	cellsize            20  20
	cells.dim           16  12

3. I would like to sample on the patch edge and use the dilate or erode
functions to increase or decrease the size of a patch. How can I force the
sampling of a spatial point, which becomes the centre for the dilate/erode
function, to fall on a patch edge. In other words, if I was to look at the
landscape file in ascii format I would need to sample a grid cell that has a
value of >0, but where at least 1 of the cells surrounding this point, in
all orthogonal directions, has a value = 0. 

4. How to constrain the newly added patches so that they does not overlap
with existing patches.

5. How to add patches of different sizes -perhaps I can simply add a loop to
my code?

I am using Windows XP and R.2.6.1. Any help on these issues would be greatly
appreciated. Thanks in advance for your help on these multiple but related
issues. I do appreciate the time that people take in responding to these
inquiries.

Best,
ilona

Ilona Naujokaitis-Lewis
Centre for Applied Conservation Research
Forest Sciences Department
University of British Columbia
3041-2424 Main Mall
Vancouver, BC V6T 1Z4
 
phone: 604 822.4382
email: ilonan at interchange.ubc.ca




More information about the R-sig-Geo mailing list