[R-sig-Geo] spatstat error: owin & "im" object

Silvia Cordero-Sancho corderos at umich.edu
Thu Feb 12 23:09:27 CET 2015


Hello SIG-GEO community,

I followed the example for the Extract.im function to "subset" a object of
class "im" to the extent of an owin.

# make up an image
 X <- setcov(unit.square())
 plot <http://inside-r.org/r-doc/graphics/plot>(X)

 # a rectangular subset
 W <- owin(c <http://inside-r.org/r-doc/base/c>(0,0.5),c
<http://inside-r.org/r-doc/base/c>(0.2,0.8))
 Y <- X[W]
 plot <http://inside-r.org/r-doc/graphics/plot>(Y)


However, when I applied to my data, it does not properly work, the output
object is not a 'im'

Here the code:

# 1. Import tiff format file. It is a raster file, spatial resolution 30 x
30 m,  ny=2667, nx=700. Pixel value ranges: 1 to 11, each one represent a
category.

tn<-as(readGDAL("..../rasters/tnn.tif"),"im")
> class(tn)
[1] "im"

# 2. Subset to owin extent:

> class(W)
[1] "owin"

# note: *W* was created from a irregular polygonal shapefile, and it is the
same file used to define the owin for the point pattern

tn2<-tn[W]
class(tn2)
[1] "integer"


The same problem occur with all the tiff-format imported grids, (e.g. DEM)


Has anyone experienced this problem before? Does anyone has a suggestion? I
will appreciate your input

Thank you

Silvia Cordero

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list