How to Create: Proportional Index Matrix and Hydrologic Distance Matrix To Start:

advertisement
How to Create: Proportional Index Matrix
and Hydrologic Distance Matrix
Sharon Parkes- March 2008, modified Dona Horan - Aug 2010
To Start:
A. Preparation
Make sure the C:\temp and C:\Documents and Settings\username\Local
Settings\Temp directories exist and are clean
B. Create ArcGIS Workspace
In ArcCatalog, create a folder and add to it: stream layer and point file
Confirm that they’re in the same projection.
C. Snap Points
Evaluate the location of the sample points with regard to the stream layer. Snap
points to stream layer before beginning these steps.
Note: this tool will only work for small watersheds or if all first order streams are
removed from a large watershed. Removing the first order streams may work for
output that is a point distance matrix (where the points are not on the first order
streams). However, this will not work for PI index or RCA calculations. Use the
tool “Flip Line Version 9.1” script found at http://arcscripts.esri.com/details.asp?dbid=13926 to flip or reverse the direction
of a large watershed. You may have to use the Repair Geometry tool on the layer
again.
Step 1: Create the Landscape Network database
•
Open a new ArcMap project. Go to: ~FLoWs v9.2 > 2. Create Landscape
Network > Polyline to Landscape Network
o Polyline Shapefile > navigate to the stream layer (do not use the dropdown arrows)
o Output Landscape Network > navigate to folder and type
LandscapeNetwork.mdb in the working directory > Save > OK
Step 2: Snap Points to Landscape Network
•
•
•
•
•
Add the point file to ArcMap
Because the script will erase the 1st user-defined field (e.g., SITEID), create a
new field and populate it with the first field’s data (e.g., SITE_ID). Don’t delete
that first field!
Remove the point file from ArcMap
Add the “edges” line file to ArcMap (saved as a GeoDatabase called
LandscapeNetwork)
Close ArcCatalog if it is open
http://www.fs.fed.us/rm/boise/AWAE/projects/stream_temp/spatial/methods.shtml
Page 1
How to Create: Proportional Index Matrix and Hydrologic Distance Matrix
•
In ArcToolbox, open ~FLoWS v9.2 > 1. Pre-processing > Snap Points to
Landscape Network Edges
o Sample Points > navigate to the point layer
o Landscape Network Edges Feature Class > use the drop down arrow to
select “edges”
o Output Snapped Points > navigate to the LandscapeNetwork
GeoDatabase and create a name for the new point file (e.g., NewPts)
> Save
o Search Radius (in meters) > Choose 100 (for example) if the points were
already adjusted, or snapped to the line > OK
•
Add the new point file to ArcMap and open the attribute table. Confirm that all of
the points are included in the new point file by looking at the number of
observations. Note that the first attribute of the newly created/snapped point
feature class will be devoid of data.
o Check the “ratio” field in the point file attribute table: Options > Select
by Attributes > [ratio] < 0.001 OR [ratio] > 0.999 > Verify: The
response box should read: The expression was verified successfully,
no records were returned > OK > Close
If records are selected it may occur if the points are close to the end of a
segment. You can remove the points, split the line at the point (so the point
won’t snap to the end of the segment), or create the PI matrix using a
threshold smaller than 0.001.
2
How to Create: Proportional Index Matrix and Hydrologic Distance Matrix
Step 3: Define Projection of Point Feature Class
Define the projection in the newly created point file.
•
In ArcToolbox, Define Projection, Import the projection from the original point file
Step 4: Accumulate Values Downstream
•
In ArcToolbox, open ~FLoWS v9.2 > 4. Analysis > Accumulate Values
Downstream
o Landscape Network Feature Class > use edges stream layer from
LandscapeNetwork.mdb (use drop down arrow)
o Output Accumulate Field Name: acc_down
o Field to Accumulate: Shape_Length
o Additional Weight Field > leave blank
o OK
Note: Open attribute table for ‘edges’ stream layer and check the values of
acc_down. If they are all equal to “1”, you need to Reverse the Flow of the
stream layer (see “To Start” above).
Step 5: Calculate a Proportional Index (PI) Matrix
Calculating the PI of one sample site on another is a two-step process. First, the
Calculate Segment PI tool is used to compute the PI of each stream segment on the
segment directly downstream. At each node, or junction, in the network, the incoming
segment(s) are identified. The total incoming area is calculated by summing the
cumulative watershed area for the incoming stream segments. Then, the PI for each
incoming segment is calculated by dividing its cumulative watershed area by the total
incoming area. The PIs of the incoming segments always sum to one because they are
proportions. When the program is complete, each segment in the streams data set has
a PI value stored in its attribute table.
Second, the Calculate the Site PI Matrix tool is used to calculate the PI for each pair of
flow-connected sites. The PI for a pair of sites is equal to the product of the segment PIs
found in the downstream path between them. The PI of a site to itself is equal to 1 and
two sites that are not flow connected receive a PI value equal to zero.
Step 5A: Calculate the Segment Proportional Index
Make sure the “edges” feature class from the LandscapeNetwork.mdb is in the
ArcMap document
Note: You cannot run this script from ArcCatalog or from ArcMap and browse –
the edges layer must be in the ArcMap TOC. The PI2 field must not already
3
How to Create: Proportional Index Matrix and Hydrologic Distance Matrix
exist. If you have run it on another edges feature class, close down ArcMap
completely before running a new watershed (don’t just start a new document close down ArcMap).
•
Go to ~Sp. Modelling in River Networks v9.2 > Calculate Segment PI
o
o
o
o
Landscape Network Edges > edges
Edge field to calculate PI > acc_down
Output PI Field > type in PI2
OK
After the script has run, check the edges attribute table to make sure a variable
named PI2 is populated with numbers from 0 to 1. This value is the proportional
influence that each segment has on the segment directly downstream. It is based
on watershed area. Segments with value = 1 are those that enter a stream
segment without another tributary, or segment, at its lowest point.
4
How to Create: Proportional Index Matrix and Hydrologic Distance Matrix
Step 5B: Calculate the Site Proportional Index
•
In ArcToolbox Go to > ~Sp. Modelling in River Networks v9.2 > Calculate Site PI
Matrix
o Landscape Network Point Feature Class > snapped point file from the
Landscape Network (it was created in Step 2, use dropdown arrow)
o Point ID Field > a unique ID, such as SITE_ID
o Landscape Hydrologic Feature Class > edges line file from the Landscape
Network (select from drop down arrow)
o Weight Field (segment pi) > PI2
o Output Matrix File > In the working folder, name the output txt file
DownOnlyDist.txt (must type in .txt) > SAVE
o OK
Note: If the script finishes after only a few moments, there was probably an
error: Close ArcCatalog and ArcMap, delete the newly created TXT file (size =
0) and restart ArcMap and start the tool again.
The output matrix text file can be used in R or SAS and will be missing the ROW labels.
Step 6: Calculate the Hydrologic Distance Matrix
This tool creates an asymmetric matrix of downstream-only distances from all pairs of
points in the input feature class based on a LN feature class (e.g., edges). Distances are
computed using values from the user-defined field and are output as a comma delimited
text file. If a pair of points is not connected, their distance value is -1.
•
In ArcToolbox go to > ~Sp. Modelling in River Networks v9.2 >
Calculate D.S. Portion Instream Distance Matrix
o Landscape Network Point Feature Class > snapped point file from the
Landscape Network (it was created in Step 2, use dropdown arrow)
o Point ID Field > a unique ID, such as SITE_ID
o Landscape Network Hydrologic Feature Class > edges line file from the
Landscape Network (select from drop down arrow)
o Distance (Weight) Field > an accurate distance field (such as “Lengthkm”
from NHDplus)
Remember that the “Length” field from an original shapefile will not
have been updated when creating the Landscape Network. Do not use
any field other than a Length field.
o Output Matrix File > In the working folder, name the output txt file
DistMatrix.txt (for example) > SAVE
o OK
5
How to Create: Proportional Index Matrix and Hydrologic Distance Matrix
The End
6
How to Create: Proportional Index Matrix and Hydrologic Distance Matrix
Troubleshooting
General Solutions for all tools:
Check to make sure that you have a C:\temp directory because the tool writes
temporary files to this folder. If you do not have a C drive, you must change this
folder name in the python scripts that are associated with this tool. Note, this will
also be an issue with other tools.
Check the C:\temp directory. Data may have been written to C:\temp, but not
deleted in a previous model run. Go to C:\temp and manually delete the output.
Close and reopen all ArcGIS products.
Restart the computer.
Build a Landscape Network (LSN)
It is not uncommon that the LSN fails to build and an error similar to this one is
produced
Error in script PolylineToLandscapeNetwork.
Error in executing: cmd.exe /C
C:\PROGRA~1\GISTools\FLoWS\RCA200~2\POLYLI~1.PY
"E:\projects\shortcourse\teachmat\data\nhd_alb3.shp"
"E:\projects\shortcourse\lsn7.mdb"
Failed to execute (PolylineToLandscapeNetwork_3).
Potential work-around:
Make sure that the shapefile does not have an OBJECTID field or an rid
field. If it does, then delete those fields and try again.
Create a new streams shapefile by exporting the data to a new folder.
Try writing the LSN to a new directory folder.
FLoWS Settings Notes
• Running ArcGIS 9.1 and Python 2.1
• A C:\Temp directory is needed (and that it is empty)
• Do not type “.shp” for the output name, but you will need to type “.mdb” for the
Landscape Network Output Personal GeoDatabase
• No OID or OID1 should exist in the input edges attribute table
• Run ArcToolbox from ArcMap (ArcCatalog tends to lock files)
• If having problems with the script running and completing without errors, but not
producing output, remove the files from the c:\temp directory and close
ArcCatalog. Remove the Personal GeoDatabase Feature Data Class layers from
the ArcMap display window and run straight from ArcTools
7
Download