3.6 Proximity Metrics using the Gamma Software

Exercises:

Gamma is software for constructing and conducting randomization tests of spatial data. For instructions on obtaining Gamma see Appendix C. This section briefly describes how proximity metrics are calculated in Gamma, and provides brief exercises.

Spatial entities are often represented as points, lines and polygons, referred to in this discussion as entity types. A simple collection is comprised of only one type of entity, such as a set of points. A complex collection is comprised of several different types (e.g. points, lines and polygons together). Proximity relationships must be carefully defined, and for this reason we focus on proximity relationships among simple collections. We may wish to calculate proximity metrics within a collection (e.g. interpoint distances), and also as mediated by other collections (e.g. distances from one point to another on a network). Hence proximity relationships may involve only one collection (as for interpoint distances), or two collections.

We have defined 3 types of proximity metrics (geographic distance, adjacency, and nearest neighbor), and 3 types of entities (point, line, polygon), whose proximity relationships may be mediated by a collection of 3 other types of entities. This yields 27 different possible kinds of proximity relationships. In practice, sample locations are typically represented as points. For example, the location of a trap, the coordinates of a health event, the centroid of a polygon and so on. For this reason the proximity metrics in Gamma are calculated among points, and may or may not be mediated by a second collection. Nine proximity metrics may be calculated using the Gamma software (Table 3-2).

Table 3-2. Description of Gamma's proximity metrics.

Proximity Metric

Description

Nearest Neighbor

For each point, identify the k nearest neighbors. nij =1 if point j is a k nearest neighbor of point i, 0 otherwise.

Adjacency, Point buffered

Two points are adjacent when their buffer zones overlap. aij=1 if the buffer zones for point i and point j overlap; 0 otherwise.

Adjacency, line buffered

Two points are adjacent when they both are within the buffer zone of a line. aij=1 if both points i and j are in the buffer zone; 0 otherwise.

Adjacency, polygon buffered

Two points are adjacent when they both are within the buffer zone of a polygon. aij=1 iff both points i and j are in the buffer zone of the polygon feature; 0 otherwise.

Adjacency, common border

Two points are adjacent when they are within polygons that share a common border. aij=1 if points i and j are in polygons with common borders; 0 otherwise.

Distance, point- point

Inter-point distance. gij is the Euclidean distance between points i and j.

Distance, point-line

Additive distance for two points to a line, gij = di + dj; di is distance from point i to nearest line.

Distance, point-polygon

Additive distance for two points to a polygon, gij = di + dj; di is distance from point i to nearest polygon.

User specified

User specifies ASCII file name containing proximity matrix. Use this to import proximity matrices from other software packages, and to specify design matrices.

As noted in Table 3-1, distance, adjacency and weight metrics are symmetric () while nearest neighbor and designer metrics are often asymmetric. To save space, Gamma symmetrizes proximity metrics using

(3-10)

Symmetrizing the metric has no effect on statistics calculated using the gamma product. Calculation of proximity metrics is illustrated in exercises 3-1 through 3-9.

 

xyt point
51.16850644.180501920.01
50.96130641.452101920.02
44.18695609.718401921.03
55.22965609.520801921.04
55.53575609.602001921.05

Figure 3-9. Data and sample locations in Chapter_3.pnt.

(a) Exercise 3-1: Nearest neighbors

Summary: Calculate k nearest neighbor relationships among a set of points. This exercise uses a simple data set of 5 points mapped in Figure 3-9.

Protocol:

  1. Start the Gamma software and select `New Session'.

  2. Matrix File Formats Screen: Set `Z File Coordinate Type' to `User Defined Coordinate'. Click on the "Next" button to advance to the next screen.

  3. Quantify Distance Matrix Screen: Select Chapter_3.pnt in `Choose a Z file' and set `Distance Metric' to `Manhattan'.

  4. Quantify Proximity Matrix: Set `Proximity Metric' to `Nearest Neighbor', and set `NNK' to `1'. This will calculate first nearest neighbor relationships among the locations.

  5. Step through the remaining screens in Gamma's wizard and press `Finish' on the Monte Carlo dialog. Then select `Matrices' on the menu bar, `Write matrices to an ASCII file' and `Proximity'. This will write the proximity matrix to the file Chapter_3.pmx in the same directory as the data without a dialog window. Use Notepad or another editor to view the proximity matrix. It will contain several records of header information and the proximity matrix:


    0.0 1.0 0.0 0.0 0.0
    1.0 0.0 0.0 0.0 0.0
    0.0 0.0 0.0 0.5 0.0
    0.0 0.0 0.5 0.0 1.0
    0.0 0.0 0.0 1.0 0.0

    The rows and columns correspond to the rows of the input data set. For example, the underlined element is n21 and indicates point 1 is the first nearest neighbor of point 2.

Problem: Construct the digraph of k=1 nearest neighbor relationships for the sample locations in Figure 3-9, and write the proximity matrix (recall the definition). If you compare your proximity matrix with that given above, you notice that they're slightly different (the one above is symmetric about the main diagonal, whereas yours is not).

(b) Exercise 3-2: Adjacency, point buffered

Summary: Calculate adjacency among the locations in exercise 3-1 using buffering. A buffer of radius 15 is used.

Protocol: Follow the protocol in Exercise 3-1 (you may choose a New session from the File menu), with the following changes:

  1. Quantify Proximity Matrix: Set `Proximity Metric' to `Adjacency, point buffered' and enter `15' for the `Buffer radius'. This will connect pairs of points separated by Euclidean distances less than or equal to 30 (2 times the buffer radius, see Figure 3-5). Point pairs separated by larger distances aren't connected.

  2. Step through the remaining screens in Gamma's wizard and press `Finish' on the `Monte Carlo' dialog. Then select `Matrices' on the menu bar, `Write matrices to an ASCII file' and `Proximity'. This will write the proximity matrix to the file `Chapter_3.pmx'. It will contain several records of header information and the proximity matrix:


0.0 1.0 0.0 0.0 0.0
1.0
0.0 0.0 0.0 0.0
0.0 0.0 0.0 1.0 1.0
0.0 0.0 1.0 0.0 1.0
0.0 0.0 1.0 1.0 0.0

The underlined element is a21 and indicates points 2 and 1 are connected.

Problem: Construct the digraph at this buffer radius by imposing the connections in the proximity matrix onto the map of sample locations. Change the buffer radius to 5 and remap the connections. What happens to the connection map?

(c) Exercise 3-3: Adjacency, line buffered

Summary: Calculate adjacency among the locations in exercise 3-1 using line buffering. A buffer of radius 2 is used.

Protocol: Follow the protocol in Exercise 3-1, with the following changes:

  1. Quantify Proximity Matrix: Set `Proximity Metric' to `Adjacency, line buffered' and enter `2' for the `Buffer radius'. Use the feature file named Ch3_line.bna. This will assign pairs of points within the buffer of the line an adjacency of 1. Point pairs with one or both members outside the buffer region are assigned an adjacency of 0.

  2. Step through the remaining screens in Gamma's wizard and press `Finish' on the `Monte Carlo' dialog. Then select `Matrices' on the menu bar, `Write matrices to an ASCII file' and `Proximity'. This will write the proximity matrix to the file `Chapter_3.pmx'. It will contain several records of header information and the proximity matrix:


0.0 1.0 0.0 0.0 0.0
1.0
0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0

The underlined element is a21 and indicates points 2 and 1 are both within the buffer region of the line (Figure 3-10).

Figure 3-10 (left). Map of line in the feature file Ch3_line.bna (solid vertical line), and its buffer (cross-hatched region). Points 1 and 2 are in the buffer zone and are adjacent. Note that the "line" should really be segment: the line drawn has been extended beyond the segment's actual extent: it should run from a y value of 609 to 645.

Problem: The line in the feature file consists of only two points, as recorded in the feature file Ch3_line.bna. Open this file using notepad or another ASCII editor. It has the following format:


"360590000002","NOT_USED","NOT_USED",-2
52.0, 609.0
52.0, 645.0

The first line contains an identifier for the line (360590000002), two optional fields (NOT_USED) and a negative integer (-2). The `-' indicates the object is a line; positive integers are used for polygons. The line is comprised of two points, with coordinates (52.0, 609.0) and (52.0, 645.0). The line is drawn between these points. Create a new file called `myline.bna' and copy in the above data. Change `-2' to `-3' (for three points) and insert `44.0, 610.0' in the file immediately after `52.0, 609.0'. The line specified in `myline.bna' now starts at (52.0, 609.0) and extends to (44.0, 610.0); from there it proceeds to (52.0, 645.0). Calculate the line-buffered adjacencies in Gamma using this new feature file and a buffer radius of 2.0, and output the proximity matrix. How have the adjacencies changed relative to those obtained earlier? Relate any changed adjacencies to the new line geography.

 

(d) Exercise 3-4: Adjacency, polygon buffered

Summary: Calculate adjacency among the locations in exercise 3-1 using polygon buffering. A buffer of radius 5 is used.

Protocol: Follow the protocol in Exercise 3-1, with the following changes:

  1. Quantify Proximity Matrix: Set `Proximity Metric' to `Adjacency, polygon buffered' and enter `5' for the `Buffer radius'. Use the feature file named Ch3_poly.bna. This will assign pairs of points within the buffer of the polygon an adjacency of 1. Point pairs with one or both members outside the buffer region are assigned an adjacency of 0.

  2. Step through the remaining screens in Gamma's wizard and press `Finish' on the `Monte Carlo' dialog. Then select `Matrices' on the menu bar, `Write matrices to an ASCII file' and `Proximity'. This will write the proximity matrix to the file `Chapter_3.pmx'. It will contain several records of header information and the proximity matrix:


0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 1.0
0.0 0.0 0.0 1.0 0.0

Figure 3-11 (Left). Locations 4 and 5 in the lower right hand corner of the Figure are within the buffer of the square polygon.

 

The underlined element is a54 and indicates points 4 and 5 are both within the buffer region of the polygon (Figure 3-11).

Problem: The feature file Ch3_poly.bna is as follows:


"360590000002","NOT_USED","NOT_USED",5
52.0, 613.0
53.0, 613.0
53.0, 612.0
52.0, 612.0
52.0, 613.0
 

The first line indicates the polygon ID (360590000002), two label fields (not used), and a positive integer (5) indicating the number of points comprising the vertices of the polygon. The polygon closes on itself, and the last coordinate (52.0, 613.0) repeats the first. Create a new bna file specifying a polygon containing points 1 and 2. In Gamma, calculate the polygon-buffered adjacencies using a buffer of 0, and inspect the proximity matrix. Are all of the adjacencies 0? How are points within the interior of a polygon treated when calculating this kind of adjacency?

(e) Exercise 3-5: Common border adjacency

Summary: Calculate adjacency among the locations in exercise 3-1 based on containment within polygons that have common borders.

Protocol: This example uses census geography for Long Island in the bna file G36059.bna.

  1. Click on `File' in the main menu and select `New Session'.

  2. Matrix File Formats: Set `Z File Coordinate Type' to `Latitude/Longitude'.

  3. Quantify Distance Matrix: Select Long_Island.pnt under `Choose a Z File' and set the distance metric to `Products'.

  4. Quantify Proximity Matrix: Set `Proximity Metric' to `Adjacency, common border' and enter G36059.bna. This proximity metric will assign pairs of points in adjoining census districts (census districts with common borders) an adjacency of 1. Also, point pairs contained within the same census district will also be assigned an adjacency of 1. Pairs of points from census districts without a common border are assigned an adjacency of 0.

  5. Location Model: Choose the Polygon radio button, then select Polygon File name and use G36059.bna.

  6. Step through the remaining screens in Gamma's wizard and press `Finish' on the `Monte Carlo' dialog. You may want to zoom in to see your points more clearly. Then select `Matrices' on the menu bar, `Write matrices to an ASCII file' and `Proximity'. This will write the proximity matrix to the file `Long_Island.pmx'. It will contain several records of header information and the proximity matrix:

    Figure 3-12. Census tracts (G36059.bna) and sampling points (Long_Island.pnt) in Long Island. Points in the same and also in adjoining census tracts are assigned an adjacency of 1.


    0.0 1.0 1.0 0.0 0.0 1.0 0.0
    1.0 0.0 1.0 0.0 0.0 1.0 0.0
    1.0 1.0 0.0 0.0 0.0 1.0 0.0
    0.0 0.0 0.0 0.0 1.0 0.0 0.0
    0.0 0.0 0.0 1.0 0.0 1.0 0.0
    1.0 1.0 1.0 0.0 1.0 0.0 0.0
    0.0 0.0 0.0 0.0 0.0 0.0 0.0

Problem: Relate the values in the proximity matrix to the map of the census boundaries and sample points in Figure 3-12. Can you identify all of the sampling points by examination of the map and proximity matrix? Why or why not?

(f) Exercise 3-6: Distance, point-point

Summary: Calculate the geographic (Euclidean) distances among the points in the file Chapter_3.pnt.

Protocol:

  1. Accomplish steps 1-3 in Exercise 3-1.

  2. Quantify Proximity Matrix: Set `Proximity Metric' to `Distance, point-point'. This will calculate the Euclidean distances between the locations in Chapter_3.pnt.

  3. Step through the remaining screens in Gamma's wizard and press `Finish' on the `Monte Carlo' dialog. Then select `Matrices' on the menu bar, `Write matrices to an ASCII file' and `Proximity'. This will write the proximity matrix to the file `Chapter_3.pmx'. Use Notepad or another ASCII editor to view the proximity matrix. It will contain several records of header information and the proximity matrix:

     

0.0002.73635.16234.89634.853
2.7360.00032.44832.21532.176
35.16232.4480.00011.04411.349
34.89632.21511.0440.0000.316
34.85332.17611.3490.3160.000

The bold element is g21 and is the geographic distance between points 2 and 1.

Problem: Distribution theory often is based on assumptions such as independent observations. Are the upper right off diagonal elements (underlined) of this distance matrix independent? Why or why not? Calculate the row sums of this matrix (e.g. the first row sum is 107.647). What do these sums mean in terms of the spatial relationships among the sample locations?

(g) Exercise 3-7: Point-line distances

Summary: Calculate distances between points as the sum of the distances from each point to the nearest line. This example uses Chapter_3.pnt and Ch3_line.bna.

Protocol:

  1. Accomplish steps 1-3 in Exercise 3-1.

  2. Quantify Proximity Matrix: Set `Proximity Metric' to `Distance, point-line', and `Feature File name' to Ch3_line.bna.

  3. Step through the remaining screens in Gamma's wizard and press `Finish' on the `Monte Carlo' dialog. Then select `Matrices' on the menu bar, `Write matrices to an ASCII file' and `Proximity'. This will write the proximity matrix to the file `Chapter_3.pmx'. Use Notepad or another ASCII editor to view the proximity matrix. It will contain several records of header information and the proximity matrix:


    0.000 1.870 8.644 4.061 4.367
    1.870 0.000 8.851 4.268 4.574
    8.644 8.851 0.000 11.042 11.348
    4.061 4.268 11.042 0.000 6.765
    4.367 4.574 11.348 6.765 0.000

    The elements of the proximity matrix are the sum of the distances from each point to the line feature. For example, the underlined elements are the sum of the distance from point 3 to the line plus the distance from point 4 to the line. For this proximity metric points 1 and 4 are nearer to one another than points 3 and 4.

    Problem: Describe a situation where proximity measured as point-line distances are a better proximity metric than point-point distances.

    (h) Exercise 3-8: Point-polygon distances

    Summary: Calculate distances between points as the sum of the distances from each point to the polygon. This example uses Chapter_3.pnt and Ch3_poly.bna. The map of the points and polygon are shown in Figure 3-11.

    Figure 3-13. Point-line distances. The distance from point 3 to point 4 is the sum of the distance from point 3 to the line feature plus the sum of the distance from point 4 to the line.

     

    Protocol:

    1. Accomplish steps 1-3 in Exercise 3-1.

    2. Quantify Proximity Matrix: Set `Proximity Metric' to `Distance, point-polygon', and `Feature File name' to Ch3_poly.bna.

    3. Step through the remaining screens in Gamma's wizard and press `Finish' on the `Monte Carlo' dialog. Then select `Matrices' on the menu bar, `Write matrices to an ASCII file' and `Proximity'. This will write the proximity matrix to the file `Chapter_3.pmx'. Use Notepad or another ASCII editor to view the proximity matrix. It will contain several records of header information and the proximity matrix:

    0.00059.66239.33034.52534.681
    59.6620.000036.61031.80531.961
    39.33036.6100.00011.47311.629
    34.52531.80511.4730.0006.824
    34.68131.96111.6296.8240.000

    The ijth element of the proximity matrix is the sum of the distances from the ith and jth distances to the polygon. For example, the underlined elements are the sum of the distance from point 1 to the polygon plus the distance from point 2 to the polygon.

    Problem: Describe a situation where proximity measured as point-polygon distances are a better proximity metric than point-point distances.