[R] Re: using shapefile as owin

Lisa Schweitzer lschwei at ucla.edu
Mon Dec 1 19:13:23 CET 2003


My sincerest apologies, as this is a very elementary problem, but I have
searched through archives and FAQs and on the web, and I am at the end of my
own resources.

I need to do analysis of a spatial point process occuring with four
counties, using spatstat. I've had no trouble importing the shapefiles, but
I can't seem to figure out what I need to do in order to use the boundary as
an owin. Why I use the Map2poly command, it appears to work, but not when I
attempt define the window using the shapefile; it also gives me errors when
I try to define a ppp.object.  I am using the latest release of Raqua on G4.
My process looks like this:

#begin code
> library(maptools)
> Shapefile<-read.shape("county.shp", dbf.data=TRUE)
Shapefile Type: Polygon   # of Shapes: 4
> plot(Shapefile, fg="white")
> rm(Map)
 
> shapepoly<-Map2poly(Shapefile, region.id = NULL)
     Map2lines(Shapefile)
     Map2points(Shapefile)
     Map2bbs(Shapefile)

[[1]]
             [,1]     [,2]
   [1,] -116.1655 34.03370
   [2,] -116.1672 34.03370
   [3,] -116.1819 34.03364

#R does its thing for a gillion more lines, then,

Error in Map2lines(Shapefile) : maptype not line/arc

> plot(shapepoly)
Error in plot.window(xlim, ylim, log, asp, ...) :
    need finite xlim values
In addition: Warning messages:
1: no finite arguments to min; returning Inf
2: no finite arguments to max; returning -Inf
3: no finite arguments to min; returning Inf
4: no finite arguments to max; returning -Inf
> library(spatstat)
spatstat 1.3-3
Type "demo(spatstat)" for a demonstration
See the Introduction and Quick Reference in
/Users/lschwei/Library/RAqua/library/spatstat/doc
> owin(shapepoly)
Error in owin(shapepoly) : If one of xrange, yrange is specified then both
must be.
#end code


Lisa
-------
Lisa Schweitzer 
Center for the Study of Urban Poverty
Dept. of Urban Planning
University of California, Los Angeles
(lschwei at ucla.edu)




More information about the R-help mailing list