1. Home
  2. PTSINPOLYGON procedure

PTSINPOLYGON procedure

Returns points inside or outside a polygon (M.A. Mugglestone, S.A. Harding, B.Y.Y. Lee, P.J. Diggle & B.S. Rowlingson).

Options

PRINT = string token What to print (summary); default summ
METHOD = string token Whether to select points inside or outside the polygon (inside, outside); default insi

Parameters

OLDY = variates Vertical coordinates of each spatial point pattern; no default – this parameter must be set
OLDX = variates Horizontal coordinates of each spatial point pattern; no default – this parameter must be set
YPOLYGON = variates Vertical coordinates of each polygon; no default – this parameter must be set
XPOLYGON = variates Horizontal coordinates of each polygon; no default – this parameter must be set
NEWY = variates Variates to receive the vertical coordinates of points inside (or outside) the polygons
NEWX = variates Variates to receive the horizontal coordinates of points inside (or outside) the polygons

Description

This procedure takes as input two variates containing the coordinates of a spatial point pattern (specified by the OLDX and OLDY parameters) and another two variates containing the coordinates of the polygon (specified by the XPOLYGON and YPOLYGON parameters). The output of the procedure depends upon the setting of the METHOD option. The default setting of inside returns the events of the spatial point pattern which lie inside the polygon. Setting the option to outside returns the events which lie outside the polygon. Note that any events which lie on the boundary of the polygon will be regarded as being outside the polygon.

The coordinates of the points satisfying the condition implied by the setting of METHOD can be saved using the parameters NEWX and NEWY. If no points satisfy the condition, then the structures specified by NEWX and NEWY will be declared as variates of undefined length and with no values.

Printed output is controlled by the PRINT option. The default setting of summary prints the coordinates of the points satisfying the condition implied by the setting of METHOD under the headings NEWX and NEWY.

Options: PRINT, METHOD.

Parameters: OLDY, OLDX, YPOLYGON, XPOLYGON, NEWY, NEWX.

Method

A procedure PTCHECKXY is called to check that OLDX and OLDY have identical restrictions. A similar check is made on XPOLYGON and YPOLYGON. The procedure then calls PTCLOSEPOLYGON to close the polygon specified by XPOLYGON and YPOLYGON. It then calls a procedure PTPASS to call a Fortran program to determine which of the points in OLDX and OLDY are inside the polygon. Finally, the RESTRICT directive is used to select the points which are inside/outside the polygon, according to the setting of the METHOD option.

Action with RESTRICT

If OLDX and OLDY are restricted, only the subset of values specified by the restriction will be included in the calculations. XPOLYGON and YPOLYGON may also be restricted, as long as the same restrictions apply to both parameters.

See also

Procedures: DPOLYGON, PTAREAPOLYGON, PTCLOSEPOLYGON, INSIDE.

Commands for: Spatial statistics.

Example

CAPTION 'PTSINPOLYGON example'; STYLE=meta
VARIATE pinex,piney
READ    [SETNVALUES=yes] pinex,piney
 0.09 0.91   0.02 0.71   0.03 0.62   0.18 0.61   0.03 0.52
 0.02 0.41   0.16 0.35   0.13 0.33   0.13 0.27   0.03 0.21
 0.13 0.14   0.08 0.11   0.02 0.02   0.18 0.98   0.31 0.89
 0.22 0.58   0.13 0.52   0.21 0.38   0.23 0.27   0.23 0.11
 0.41 0.98   0.44 0.97   0.42 0.93   0.42 0.48   0.43 0.36
 0.59 0.92   0.63 0.92   0.63 0.88   0.66 0.88   0.58 0.83
 0.53 0.69   0.52 0.68   0.49 0.58   0.52 0.48   0.52 0.09
 0.58 0.06   0.68 0.66   0.68 0.63   0.67 0.53   0.67 0.48
 0.67 0.41   0.68 0.34   0.66 0.24   0.73 0.27   0.74 0.11
 0.78 0.06   0.79 0.02   0.86 0.03   0.84 0.88   0.94 0.89
 0.95 0.83   0.79 0.79   0.84 0.71   0.83 0.68   0.86 0.65
 0.79 0.61   0.93 0.48   0.83 0.42   0.93 0.31   0.93 0.23
 0.97 0.64   0.96 0.64   0.96 0.61   0.96 0.57   0.97 0.38  :
VARIATE xpoly; VALUES=!(0.0,0.5,0.5,0.0)
&       ypoly; VALUES=!(0.0,0.0,0.5,0.5)
PTSINPOLYGON OLDY=piney; OLDX=pinex; YPOLYGON=ypoly; XPOLYGON=xpoly
Updated on March 6, 2019

Was this article helpful?