Docsity

Example: Spatial Interaction Modeling | GEOG 494M, Exams of Geography

Toggle sidebar
bg1
Geog 494m - Geodemographics
Spring 2009
1
Example 3 – Spatial Interaction Modeling
Objectives:
1. Practice creating weights matrices in Geoda.
2. Use Excel to calculate gravity weights based on distance and population.
3. Use the gravity weights to estimate percent poverty by county and test these values using a
chi-squared analysis.
Data:
WestVirginia (shapefile)
WV attributes (spreadsheet)
Step 1: Open Geoda and create weights.
Open Geoda from the desktop and open the WestVirginia.shp that we have used in previous
exercises.
Go to Tools – Weights – Create (or just click on the second „W‟ button along the top). This
should bring up a „create weights‟ window.
For the input file, select your WestVirginia shapefile. Name your output file WV_weights and
save it somewhere that you can access later.
Keep the default for the ID variable
Step 2: Create several weights files with different
parameters
Name each file differently so you remember
what they mean (it may be helpful to note
which parameters you use for each file)
Contiguity: rook v. queen
Order of contiguity: “My neighbor‟s
neighbor.”
Distance metric: use arc for each file
X- and Y- coordinates: keep the defaults for
each file
Threshold distance: Only includes counties
within the threshold (the far right includes all
distances)
K-Nearest neighbors: Not necessarily
symmetric – the number of closest (most
similar) neighbors
Figure 1: Weights files created in Geoda and their naming
conventions.
Step 3: Examine each weights file in Geoda.
To see how many neighbors are included in each matrix, go to the 3rd „W‟ button (weight
characteristics)
Load each file you created one by one and examine the graph for each.
What are the graphs telling us?
Step 4: Create a single weights file to use in the exercise.
pf3
pf4

Partial preview of the text

Download Example: Spatial Interaction Modeling | GEOG 494M and more Exams Geography in PDF only on Docsity!

Example 3 – Spatial Interaction Modeling

Objectives:

_1. Practice creating weights matrices in Geoda.

  1. Use Excel to calculate gravity weights based on distance and population.
  2. Use the gravity weights to estimate percent poverty by county and test these values using a_ chi-squared analysis.

Data:

WestVirginia (shapefile) WV attributes (spreadsheet)

Step 1: Open Geoda and create weights.

 Open Geoda from the desktop and open the WestVirginia.shp that we have used in previous exercises.  Go to Tools – Weights – Create (or just click on the second „W‟ button along the top). This should bring up a „create weights‟ window.  For the input file, select your WestVirginia shapefile. Name your output file WV_weights and save it somewhere that you can access later.  Keep the default for the ID variable

Step 2: Create several weights files with different parameters

 Name each file differently so you remember what they mean (it may be helpful to note which parameters you use for each file)  Contiguity: rook v. queen  Order of contiguity: “My neighbor‟s neighbor.”  Distance metric: use arc for each file  X- and Y- coordinates: keep the defaults for each file  Threshold distance: Only includes counties within the threshold (the far right includes all distances)  K-Nearest neighbors: Not necessarily symmetric – the number of closest (most similar) neighbors

Figure 1 : Weights files created in Geoda and their naming conventions.

Step 3: Examine each weights file in Geoda.

 To see how many neighbors are included in each matrix, go to the 3rd^ „W‟ button (weight characteristics)  Load each file you created one by one and examine the graph for each.  What are the graphs telling us?

Step 4 : Create a single weights file to use in the exercise.

 Create one more weights file using the highest threshold (pull the bar to the far right), so you include all distances  Keep arc as the distance metric and the defaults for x- and y- coordinates

Step 4: Open the weights files in Excel.

 You can open the weights file that you just created in Excel by importing it (similar to what you did in the chi-square exercise)  Once in Excel, the matrix must be further manipulated into a form that you can use. This process is basically just grunt work and would take too much time to do during this exercise, but the method for doing it is listed at the end of the exercise (in the Appendix).  If you want to use spatial interaction modeling in your final project, you should hold onto this exercise and use the appendix to do this with your own data.

Step 5: Go to ecampus and download the finished WVCountyDistMatrix. Also open the table (WVAttributes) that you created during the chi-square exercise.

 Instead of spending time doing the grunt work, just download the pre-prepared matrix from ecampus and open it in Excel. Also open your WV_attributes table from the last exercise (you‟ll need to copy and paste a few things from that table).  From your WV_attributes tables, copy the column „POP2000‟ and paste it into the distance matrix spreadsheet (maybe a column or two past the last column in the distance matrix so you can differentiate it from your matrix, but it doesn‟t really matter where you paste it) – IMPORTANT : Make sure you sort the „POP2000‟ column alphabetically by county before you copy it over to the new table, otherwise it will not be in the correct order!  You will also want to create a new matrix below the first one where you can calculate the gravity weight for each pair of counties. The easiest way to do this is to copy the entire matrix and paste it a row or two below the original matrix, then just delete all of the numbers so you are left with just column and row headings. This will give you an open matrix where you can calculate the gravity weights for each pair.

Step 6: Calculate the gravity weight for each pair of counties.

 Calculate the gravity weight for each pair of counties by taking the population of the county in the row of the matrix entry, and dividing it by the square of the distance between the two counties.  An example of this formula for the Barbour/Berkeley weight is C60=$BF2/(C2^2). The exact cells may differ depending on where you pasted your population column and where your matrix is located in the spreadsheet. The $ sign means that when this formula is copied and pasted, the column in this address stays the same. Since BF is the column my population values ended up in, this is appropriate.  Replace everything on the diagonal (the interaction of a county with itself) with zeroes. We‟re going to use these weights to predict the value of each county‟s „pctpoor,‟ so we don‟t want to cheat by using a county‟s value to predict itself.  Below your matrix table add a row called „total‟ and sum up the weights from each county column. This sum shows how much interaction each particular county has with all other counties. It should be a different number for each county.

Appendix:

Follow these steps to create a distance matrix from the weight file created in Geoda:

  1. First, the labels 1 through 55 are distinctly unhelpful, and should be replaced with the county names. A „find & replace all‟ operation does this, although you need to first highlight the two columns of labels to avoid creating entries like 47.Marion3470, and also start with the 2-digit labels so label 55 doesn‟t become MonongaliaMonongalia.
  2. I added column headings of „To,‟ „From‟ and „Miles.‟ Do a custom sort with two levels: „To‟ being the first level (A to Z) and „From‟ being the second level (also A to Z). Add one column for each county. Now all the counties are in order.
  3. Copy and paste the first set of 54 distances under the Barbour column. Copy and paste the second set under the Berkeley column. Repeat for all counties. Also, add in a cell in each column at the appropriate row to correspond to the distance from each county to itself. This creates a diagonal series of blank cells from the top left to the bottom right. Fill them with ones. (I‟d say zeroes, but ones avoid any divide-by-zero errors.)
  4. Save the file. Delete everything that isn‟t in the matrix, its column headings, or its row headings. You don‟t need it anymore.