Skip to content

ArcGIS raster/vector to SPATSTATS im image file conversion

2 messages · Liza Koshy, Roger Bivand

#
On Wed, 5 Mar 2008, Liza Koshy wrote:

            
Assuming vector is a point shapefile, use readOGR() in the rgdal package - 
points do not make im objects (not files) directly. Do you have a plan of 
your workflow? Is it something like:

1) read a shapefile of points and convert to a ppp object;
2) read a grid and convert to an im object to use as a window for the
   point pattern analysis;

The first one would be:

library(rgdal)
my_pts <- readOGR(dsn=".", layer="my_shp") # for my_shp.shp in current
                                            # directory
plot(my_pts)
library(maptools)
my_ppp <- as(as(my_pts, "SpatialPoints"), "ppp") # coerce to SpatialPoints
                                             # before coercion to ppp
                                             # unless you need marks
plot(my_ppp)

and the second:

my_grd <- readGDAL("my_grid") # for my_grid as full file name
image(my_grd)
plot(my_pts, add=TRUE)
my_im <- as(my_grd, "im") # note that my_grd should only have a single
                           # column
plot(my_im)

Are you thinking of using the im object values to represent inhomogeneity? 
Or are you going to use missing values to define the owin window object 
for the point process? If the latter, you may want to say:

summary(my_grd)
names(my_grd)

to see what is inside the object before coercing to an im object. If need 
be, set the single column values to NA for areas outside the required 
window.

Hope this helps,

Roger
PS. From your description, it isn't clear that you have a viable work 
plan, or that point pattern analysis is appropriate. You have points 
(presence of something?) and rasters of environmental variables. Have you 
observed a point pattern in which interpoint distances are important, or 
just (some) points at which something has been observed? Do you have, for 
example, Fortin & Dale to hand, it might help?