I often don't understand why I do what I do :-\ but I always RTFM first (not that I understand as you so kindly pointed out)

I was literally passing arguments to as.mask(), which require in some cases a window object. I will not be doing this in the future. 

You showed me how to prevent the error and I have to thank you for that...

Matthew Cracknell
PhD. Candidate
   
ARC Centre of Excellence in Ore Deposits
University of Tasmania
Private Bag 79
Hobart, 7001
Australia

Mob: 0409438924 

----- Original Message -----
From: Rolf Turner <r.turner@auckland.ac.nz>
Date: Wednesday, June 8, 2011 19:34
Subject: Re: [R-sig-Geo] Fwd: distmap() error with used defined image window and	resolution
To: mattc0 <M.J.Cracknell@utas.edu.au>
Cc: r-sig-geo@r-project.org

> 
> Perhaps I'm being obtuse (not an unusual occurrence :-) ) but I 
> don't understand
> why you do what you do.
> 
> (1) You create a new window for the patterns --- only very 
> slightly different from the
> window that ``comes with'' the patterns.  This has however 
> nothing to do with the
> resolution of the distmap () result that you say you are 
> concerned about.
> 
> (2) The distmap function takes as arguments the pattern (of 
> points or segments)
> (or window, as the case may be) and ``...'' which (sayeth the 
> help) consists of
> ``Arguments passed to as.mask to control pixel 
> resolution''.   There is no mention
> of passing a ***window*** as an argument to  distmap.  
> (So I think that this may
> well be a case of RTFM.)
> 
> Anyway it is the fact that you are passing this unexpected 
> window that is causing
> the error.
> 
> You might want to do:
> 
>     cdm <- 
> with(copper,distmap(Lines,dimyx=c(158,70))
> Or, if you really want the window to be [0,70] x [0,158] you 
> could do
> 
>     copper$Lines$window <-  
> owin(c(0,70),c(0,158)
> and then
> 
>     cdm <- 
> with(copper,distmap(Lines,dimyx=c(158,70)) # Same as before.
> 
> or
> 
>     cdm <- with(copper,distmap(Lines,eps=1)) # 
> Gives the same result as above.
> 
> Does this accomplish your objectives?
> 
>     cheers,
> 
>         Rolf Turner
> 
> On 08/06/11 17:32, mattc0 wrote:Hi R-sig-geo'ers
> >I am attempting to generate an image with each pixel showing 
> the euclidean distance to nearest line feature using spatstat.
> >I  would like to set the image extent and resolution, 
> rather than the  default 100 x 100 (nx, ny) cells. However, 
> when attempting this I get  the following error
> >
> >Error in diff(w$yrange)/eps : non-numeric argument to binary operator
> >
> >I am using R version 2.12.1 64-bit and spatstat 1.22-1
> >
> >Below  is an example using the copper dataset that is 
> provided with spatstat.  This generates the same error that 
> I am getting with my data
> >
> >>library(spatstat)
> >>  # get data
> >>data(copper)
> >>  # set user defined window
> >>copper.win<- owin(c(0,70),c(0,158))
> >>  # default distmap image resolution with 100 x 100 (ny,nx)
> >>distmap.psp(copper$Lines) # OK
> >real-valued pixel image
> >100 x 100 pixel array (ny, nx)
> >enclosing rectangle: [-0.335, 70.11] x [0.19, 158.23] km
> >>  # user defined window and resolution 158 x 70 (ny,nx)
> >>distmap.psp(copper$Lines,as.mask(w=copper.win,eps=1)) # Error
> >Error in diff(w$yrange)/eps : non-numeric argument to binary operator
> >
> >  I have tried as.mask() with xy coordinates with pixel 
> locations but have encounter the same error.
> >
> >Thanks
> >
> >Matthew Cracknell
> >PhD. Candidate
> >
> >ARC Centre of Excellence in Ore Deposits
> >University of Tasmania
> >Private Bag 79
> >Hobart, 7001
> >Australia
> >
> >Mob: 0409438924

Matthew Cracknell
PhD. Candidate
   
ARC Centre of Excellence in Ore Deposits
University of Tasmania
Private Bag 79
Hobart, 7001
Australia

Mob: 0409438924 



	[[alternative HTML version deleted]]

