[R-sig-Geo] problem creating point pattern class object with spatstat package

Rolf Turner r.turner at auckland.ac.nz
Wed Dec 1 20:05:54 CET 2010


On 2/12/2010, at 12:12 AM, zbynek.janoska at centrum.cz wrote:

> 
> I have troubles creating ppp object in spatstat using spatstat package.
> I would like to upload some lidar data and convert them to ppp, but error
> occured.
> I am working with dataset lidar, consisnting of two columns (x and y
> coordinates)
> 
>> x1 <- min(lidar[,1])-1
>> x2 <- max(lidar[,1])+1
>> y1 <- min(lidar[,2])-1
>> y2 <- max(lidar[,2])+1
>> owin1 <- owin(c(x1,x2),c(y1,y2))
> 
> so far it works well and I can also plot owin object
> 
>> ppp1 <- ppp(lidar[,1],lidar[,2],owin1)
> Error in owin(...) : 
>  If one of xrange, yrange is specified then both must be.
> 
> I can not get past this error.
> I have succesfully created owin1 - window of class owin, but i can not use
> it to create ppp object
> 
> Does anyone see what mistake I have done?
> Possibly it is something very easy, but I am quite new to R.


Very easy indeed.  RTFM.  It tells you that the argument list for ppp()
is given by:

	ppp(x,y, ..., window, marks, check=TRUE)

and that the ... argument is

	arguments passed to owin to create the window, if window is missing

so it is taking ``owin1'' in your call to be an argument to be passed to as.owin
(which confuses the living Drambuie out of it), rather than being the window argument.

Do:

	ppp1 <- ppp(lidar[,1],lidar[,2],window=owin1)

and all will be well.

	cheers,

		Rolf Turner



More information about the R-sig-Geo mailing list