Skip to content

R_Calculating Thiessen weights for an area with irregular boundary

5 messages · Rolf Turner, Manoranjan Muthusamy

#
Hi R users,

I want to calculate Thiessen weights to compute areal rainfall from number
of point measurements. I am using R and thanks to some previous question in
the same topic, I got to know that I can usedeldir. But the problem is my
boundary polygon is not a rectangle; it's an irregular polygon (it's a
catchment boundary derived using ArcGIS). But in deldir the boundary can
only be a rectangle. Are there any other packages where I can calculate
Thiessen weights of an area covered by an irregular boundary?

Given below are my measurement points (meas_points) and coordinates of a
(simplified) boundary polygon(boundary)
X      Y[1,] 415720 432795[2,] 415513 432834[3,] 415325
432740[4,] 415356 432847[5,] 415374 432858[6,] 415426 432774[7,]
415395 432811[8,] 415626 432762
x      y[1,] 415491 432947[2,] 415269 432919[3,] 415211
432776[4,] 415247 432657[5,] 415533 432657[6,] 415781 432677[7,]
415795 432836[8,] 415746 432937

Any help is really appreciated. Thanks.

cheers,

Mano
#
(1) The manner in which you presented your data was a total mess.
If you ask for help, please have the courtesy to present your data in 
such a manner that a potential "helper" can access it without needing to 
do a great deal of editing and processing.  Like so:

pts <- as.data.frame(matrix(c(415720,432795,415513,432834,415325,
                               432740,415356,432847,415374,432858,
                               415426,432774,415395,432811,415626,
                               432762),ncol=2,byrow=TRUE))
names(pts) <- c("x","y")

bdry <- as.data.frame(matrix(c(415491,432947,415269,432919,415211,
                                432776,415247,432657,415533,432657,
                                415781,432677,415795,432836,415746,
                                432937),ncol=2,byrow=TRUE))
names(bdry) <- c("x","y")

(2) Well, at least you presented a usable data set (even though the 
presentation was lousy) which is better than what most posters do.  And 
you asked a "partially" clear question.

(3) I do not know what you mean by "Thiessen weights".  I am guessing 
that these are the areas of the Dirichlet tiles (Thiessen polygons), 
intersected with the "boundary polygon" (i.e. observation window).

(4) If my guess is correct, the following should accomplish the desired 
task:

require(spatstat) # You will (probably) need to install spatstat first.
W <- owin(poly=bdry)
X <- as.ppp(pts,W=W)
plot(X) # Just to make sure it looks right.
dX <- dirichlet(X)
plot(dX) # Just to make sure .....
sapply(tiles(dX),area.owin)

HTH

cheers,

Rolf Turner
On 22/04/15 02:50, Manoranjan Muthusamy wrote:

            

  
    
#
1. Apologies for the lousy presentation of the data and thank you for your
feedback. I promise it will not happen again.

2. Thank you

3. Yes, exactly!

4. Exactly what I wanted without much hassle. Thank you very much. Time to
explore the package 'spatstat'.
    How can I show the Dirichlet tile names (i.e. 1,2,3,....,8) in the plot?

Cheers,
Mano

On Tue, Apr 21, 2015 at 11:33 PM, Rolf Turner <r.turner at auckland.ac.nz>
wrote:

  
  
#
On 22/04/15 22:43, Manoranjan Muthusamy wrote:
<SNIP>
There's no built-in way at the moment as far as I can tell.

One way to get the tiles to be labelled/numbered in the plot would be:

plot(dX)
text(X,labels=1:npoints(X))

Slightly sexier:

cents <- as.data.frame(t(sapply(tiles(dX),centroid.owin)))
plot(dX)
text(cents,labels=1:nrow(cents))

Is this satisfactory?

cheers,

Rolf Turner
#
It certainly is! Thank you.

Cheers,
Mano

On Thu, Apr 23, 2015 at 12:02 AM, Rolf Turner <r.turner at auckland.ac.nz>
wrote: