Skip to content

Commit

Permalink
Add Documenation to Sinuosity and Moving Window
Browse files Browse the repository at this point in the history
  • Loading branch information
KellyMWhitehead committed Apr 6, 2018
1 parent bae2d29 commit 6d93f80
Show file tree
Hide file tree
Showing 4 changed files with 149 additions and 32 deletions.
117 changes: 117 additions & 0 deletions docs/MovingWindowTool.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
---
title: Moving Window Analysis
---

The moving window analysis tool summarizes attributes on length based 'windows' centered around 'seed points'.

![]()

[TOC]

# Usage

![](Images/MovingWindowToolWindow.PNG)

1. The Moving Window Summary requires a Stream Branch or similar field to identify tributary routing. The moving window can summarize numeric data fields only.
2. In ArcMap navigate to Geomorphic Network and Analysis Toolbox / Utilities / Moving Window Summary in ArcToolbox.
1. Specify the **Stream Network Polyline Feature Class** to run the summary over.
2. Specify a **Stream name or Branch Field** that is used to make continuous stretches of the stream. For Example, GNAT uses a "Stream Branch ID" system.
3. Specify the **Seed Point Distance** to use for spacing the seed points along the network. Seed points will start at 1/2 the distance of the largest window size in order to retain all window sizes for every seed point.
4. Specify the window size(s) you want to use. Each window size will provide a summary at each seed point.
5. Specify the Attribute Fields that will be used to **Calculate Statistics**. Numeric (Float, Double or Integer types only).
6. Specify the output **Moving Windows** and **Seed Point** Feature classes .
7. (Optional) specify a Temporary workspace. If one is not specified, the "in_memory" workspace will be used.
8. (Optional) Specify Riverscapes project and outputs.
9. Click OK to run the tool.

# Parameters

## Inputs ##

### Line Network

The Line network on which the Moving Window analysis will be generated. ****

Requirements:

* Contains the network attributes for which the moving window summary will be calculated.
* The Line Network must have tributary topology information as an attribute to dissolve the network (i.e. GNIS names, Stream Order, etc)

### Stream Route ID

The field that contains a unique ID for each Stream/Route. The tool will dissolve based on this ID, so as to create the longest continuous river segments for generating the Seed Points.

### Seed Point Distance

Distance between seed points. Seed Points represent the center of each window, and multiple windows are aligned on each seed point. The first seed point is located at half the distance of the largest window size from the ends of each stream route. This is to ensure that each seed point has every window size associated with it.

### Window Sizes

Window size (in meters) to be generated at each seed point. Multiple window sizes can be specified.

### Generate Statistics Fields

Select the fields to generate statistics on. Only Numeric (Float, Double Integer) types are allowed.

## Outputs ##

In the output workspace you will find:

### Seed Points

Points feature class that contain the calculated attribute for each window size, centered on each seed point feature. This layer contains the following attributes:

* `RouteID`: The same attribute as the `StreamBranchID` specified in the inputs.
* `SeedID`: Unique ID for each seed point. Can be used to join back to Window line features in Moving Window Lines.
* Attribute summaries will saved in fields that are named using the following structure `wXXSS_ATRB`:
* `wXX` The first part of the field name contains "w" followed by the first two digits fo the window size.
* `ST_` Statistics Type:
* `N` Count
* `Av` Average
* `Sm` Sum
* `Rn` Range
* `Mn` Minimum Value
* `Mx` Maximum Value
* `Sd` Standard Deviation
* `WA` Weighted Average (by length of segment)
* `ATRB` The first few letters of the original attribute field for that statistic generated.

### Moving Window Lines

The line features that represent the moving windows. These features will overlap both in window spacing (seed distance) and window sizes. This layer contains the following attributes:

* `SeedID`: Unique id for each seed point. This can be used to join back to the individual seed points.
* `Window size`: Size of the window (due to geometric rounding, the actual shape length may be slightly larger or smaller than the window size).

## Methods

1. Line Network is dissolved by user specified "StreamRoute" Field.
2. Iterate through each Stream Route
1. Generate Seed Points starting at a distance of 1/2 largest window size, using a spacing distance as provided by user.
2. for each seed point:
1. For each window size provided by user,
1. find the upper distance and lower distance of window centered on the seed point.
2. Use the distances to find segment along line (arcpy geometry method)
3. Generate Feature classes of Seed Points and windows
4. Intersect the Windows with the Original Line network.
5. Read the Intersected Line Network into Python Dictionaries
6. Add new fields to store calculated statistics to Seed Points
7. Calculate statistics for each statistic type for each attribute, for each seed and window size .
8. Save outputs to user specified destinations.

# About

- **Code Repository** https://github.com/Riverscapes/arcGNAT
- **Software Architecture** Python 2.7 with standard library and the following 3rd-Party Dependencies:
- arcpy
- **ArcGIS** version 10.4 or higher.
- Code for this tool written and maintained by Kelly Whitehead at South Fork Research.

# Release Notes

- `version 0.0.2` 2018-04-05
- Use Python Dictionaries and Cursors to generate statistics instead of arcpy Summary Statistics tool.
- `version 0.0.1` 2018-03-28
- Tool initialized.

[TOOL HOME](index.md)
56 changes: 28 additions & 28 deletions docs/Stream-Sinuosity-and-Planform.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,47 @@
---
title: Stream Sinousity and Planform
title: Sinuosity Attributes Tool
---

In general Sinuosity is a ratio of the sinuous length of stream or valley reach the to straight-line distance for that same reach. This tool generates three different sets of sinuosity attributes for each segment within a particular stream network and its associated valley centerline:

Sinuosity is a ratio of the sinuous length of stream or valley reach the to straight-line distance for that same reach.
Planform is a ratio of the sinuosity of a stream reach to the length of the encompassing valley segment. The **Stream Sinuosity
and Planform** tool calculates sinuosity (per polyline feature) for valley centerline and stream network features. The
tool also transfers the valley sinuosity to the stream network and calculates river planform attribute.
* `Planform Sinuosity` ratio of channel segment length / channel segment dist
* `Channel Sinuosity` ratio of channel segment length / Valley Bottom Length
* `Valley Sinuosity` ratio of valley bottom segment length / valley bottom segment distance

![sinuosity_example]({{site.baseurl}}assets/images/sinuosity_example.png)

_______________________________________________________________
## Usage

### Geoprocessing Environments ###
* All inputs must be in the same projected coordinate system.
* We recommended running this tool with 64-bit python geoprocessing.
* Disable Z and M geometry in the Shape field if topology errors are encountered.

### Input Parameters

![sinuosityplanform_form]({{site.baseurl}}assets/images/sinuosityplanform_form.png)

**Input Segmented Stream Network**

Segmented stream network polyline feature class (i.e. flowline, centerline, etc). Stream sinuosity values will be
calculated for each segment. New channel sinuosity, valley sinousity, and planform attribute fields will appended
calculated for each segment. New channel sinuosity, valley sinuosity, and planform sinuosity attribute fields will appended
to this dataset on completion of the processing.

**Input Segmented Valley Centerline**

Segmented valley bottom centerline polyline feature class. Valley sinuosity values will be calculated for each segment.

**Input Valley Bottom Polygon**
**Segment ID Field**

Valley bottom polygon feature class of the stream network. This can also serve as input to the
[Transfer Line Attribute](http://gnat.riverscapes.xyz/Transfer-Line-Attributes) tool.
SegmentID field.

### Outputs
**Temporary Workspace**

**Output Valley Centerline with Sinuosity Attribute**
Saves temporary processing files. Leave blank to use "in_memory" workspace.

Output polyline feature class includes calculated sinuosity as an attribute.
**(Optional) SegmentFilter Field**

*Please note*: If this analysis is part of Riverscapes project, the `Input Stream Network` will automatically
be switched to the stream network feature class associated with the Realization Analysis found in the project.rs.xml
file, which the user selects in the `Riverscape Project Management` parameters of this tool.
Use this parameter to filter lines to include in the calculation as an Integer field that will ignore lines with "0" and calculate lines with "1".

### Outputs

***No Outputs. This tool modifies the original input data***

### Riverscapes Project Management

Expand All @@ -68,18 +64,22 @@ analysis will be assigned.

**Attribute Analysis Name** (optional)

* Name of the new Sinuosity and Planform analysis.
* Name of the new Sinuosity Attribute analysis.

_______________________________________________________________

## Technical Background

### Calculation Method

1. Use [Sinuosity By Segment Tool](http://gnat.riverscapes.xyz/Sinuosity-by-Segment) for stream and valley centerlines
* Convert segment ends to points
* Find straight-line distance
* Calculate sinuosity (segment distance/straight-line distance)
2. Transfer valley bottom sinuosity to stream centerline using the
[Transfer Line Attributes](http://gnat.riverscapes.xyz/Transfer-Line-Attributes) tool
3. Calculate the planform metric for each divided segment
1. Find endpoints of the line segments
2. Use Near Analysis to find points on valley bottom centerline nearest to the endpoints.
3. Generate Valley Bottom centerline segments and straight lines from near points.
4. Generate Selection Polygons used to associate valley bottom segments with stream network segments.
5. Generate length values and distances used in sinuosity calculations.
6. Calculate the sinuosity metrics for each segment

# Release Notes

* `version 2.0.1` 2018-03-01
* Major rewrite of this tool, including new attribute definitions, and valley bottom centerline transfer method.
4 changes: 2 additions & 2 deletions tools/ValleyPlanform.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,12 @@ def main(source_segments,

arcpy.CalculateField_management(out_segments,
fieldPlanformSinuosity,
"calculate_sinuosity(!{}!, !{}!)".format(field_chanlength, field_vblength),
"calculate_sinuosity(!{}!, !{}!)".format(field_chanlength, field_chandist),
"PYTHON_9.3",
codeblock)
arcpy.CalculateField_management(out_segments,
field_chansin,
"calculate_sinuosity(!{}!, !{}!)".format(field_chanlength, field_chandist),
"calculate_sinuosity(!{}!, !{}!)".format(field_chanlength, field_vblength),
"PYTHON_9.3",
codeblock)
arcpy.CalculateField_management(out_segments,
Expand Down
4 changes: 2 additions & 2 deletions tools/moving_window.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Moving Window for GNAT"""

import math
from math import sqrt
import arcpy
from lib import gis_tools

Expand Down Expand Up @@ -130,7 +130,7 @@ def main(fcLineNetwork,
max_vals = max(vals)
min_vals = min(vals)
range_vals = max_vals - min_vals
sd_vals = math.sqrt(sum([abs(float(x) - float(ave_vals))**2 for x in vals]) / float(count_vals))
sd_vals = sqrt(sum([abs(float(x) - float(ave_vals))**2 for x in vals]) / float(count_vals))
wave_vals = sum([val / slen for val, slen in zip(vals, seglen)])/ float(count_vals)
new_row.extend([count_vals, ave_vals, sum_vals, range_vals, min_vals, max_vals, sd_vals, wave_vals])
ucSeedPoints.updateRow(new_row)
Expand Down

0 comments on commit 6d93f80

Please sign in to comment.