<SPAN class="keyword token">import</SPAN> arcpy
<SPAN class="keyword token">from</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>sa <SPAN class="keyword token">import</SPAN> <SPAN class="operator token">*</SPAN>
<SPAN class="keyword token">from</SPAN> arcpy <SPAN class="keyword token">import</SPAN> env
arcpy<SPAN class="punctuation token">.</SPAN>CheckOutExtension<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"spatial"</SPAN><SPAN class="punctuation token">)</SPAN>
main_dir <SPAN class="operator token">=</SPAN> <SPAN class="string token">"F:\Independent_Study\\"</SPAN>
flow_dir <SPAN class="operator token">=</SPAN> main_dir <SPAN class="operator token">+</SPAN> <SPAN class="string token">"Flow"</SPAN>
env<SPAN class="punctuation token">.</SPAN>workspace <SPAN class="operator token">=</SPAN> main_dir
env<SPAN class="punctuation token">.</SPAN>overwriteOutput <SPAN class="operator token">=</SPAN> <SPAN class="token boolean">True</SPAN>
threshold <SPAN class="operator token">=</SPAN> <SPAN class="number token">3000</SPAN>
dem <SPAN class="operator token">=</SPAN> Raster<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"F:\\Independent_Study\\Newfiles\\Newfiles\\UDW1_dtm.tif"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">#invert DEM</SPAN>
dem_neg <SPAN class="operator token">=</SPAN> dem <SPAN class="operator token">*</SPAN> <SPAN class="operator token">-</SPAN><SPAN class="number token">1</SPAN>
gps_pts <SPAN class="operator token">=</SPAN> <SPAN class="string token">"F:\\Independent_Study\\UDW_with_UTM_Coordinates\\UDW_with_UTM_Coordinates.shp"</SPAN>
<SPAN class="comment token">#run flow direction on DEM</SPAN>
neg_Direction <SPAN class="operator token">=</SPAN> FlowDirection<SPAN class="punctuation token">(</SPAN>dem_neg<SPAN class="punctuation token">)</SPAN>
neg_Direction<SPAN class="punctuation token">.</SPAN>save<SPAN class="punctuation token">(</SPAN>flow_dir <SPAN class="operator token">+</SPAN> <SPAN class="string token">"\\neg_flow_direction.tif"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">#Extracts values at GPS Points</SPAN>
direction_value <SPAN class="operator token">=</SPAN> ExtractValuesToPoints<SPAN class="punctuation token">(</SPAN>gps_pts<SPAN class="punctuation token">,</SPAN> neg_Direction<SPAN class="punctuation token">,</SPAN> flow_dir <SPAN class="operator token">+</SPAN> <SPAN class="string token">"\\direction_values.shp"</SPAN><SPAN class="punctuation token">)</SPAN>
values <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>ListFields<SPAN class="punctuation token">(</SPAN>direction_value<SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">#create an update cursor to update the X and Y coordinate values based on flow direction.</SPAN>
cursor <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>UpdateCursor<SPAN class="punctuation token">(</SPAN>flow_dir <SPAN class="operator token">+</SPAN> <SPAN class="string token">"\\direction_values.shp"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="string token">"*"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">#Save spatial reference information</SPAN>
spatial_reference <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>Describe<SPAN class="punctuation token">(</SPAN>flow_dir <SPAN class="operator token">+</SPAN> <SPAN class="string token">"\\direction_values.shp"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>spatialReference
<SPAN class="comment token">#Create new feature class for updated values</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>CreateFeatureclass_management<SPAN class="punctuation token">(</SPAN>flow_dir<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"\\updated_dir_values.shp"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"POINT"</SPAN><SPAN class="punctuation token">,</SPAN> flow_dir <SPAN class="operator token">+</SPAN> <SPAN class="string token">"\\direction_values.shp"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"DISABLED"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"DISABLED"</SPAN><SPAN class="punctuation token">,</SPAN> spatial_reference<SPAN class="punctuation token">)</SPAN>
cur <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>InsertCursor<SPAN class="punctuation token">(</SPAN>flow_dir <SPAN class="operator token">+</SPAN> <SPAN class="string token">"\\updated_dir_values.shp"</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">"SHAPE@"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">#for loop that iterates through feature class and modifies X and Y coordinates based on the flow direction at that point</SPAN>
<SPAN class="keyword token">for</SPAN> row <SPAN class="keyword token">in</SPAN> cursor<SPAN class="punctuation token">:</SPAN>
<SPAN class="comment token">#East</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>row <SPAN class="punctuation token">[</SPAN><SPAN class="number token">10</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">==</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">9</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> int<SPAN class="punctuation token">(</SPAN>row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">9</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="number token">1</SPAN>
cursor<SPAN class="punctuation token">.</SPAN>updateRow<SPAN class="punctuation token">(</SPAN>row<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="string token">"EAST"</SPAN>
<SPAN class="comment token">#SE</SPAN>
<SPAN class="keyword token">elif</SPAN> <SPAN class="punctuation token">(</SPAN>row <SPAN class="punctuation token">[</SPAN><SPAN class="number token">10</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">==</SPAN> <SPAN class="number token">2</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">8</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> int<SPAN class="punctuation token">(</SPAN>row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">8</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">-</SPAN> <SPAN class="number token">1</SPAN>
row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">9</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> int<SPAN class="punctuation token">(</SPAN>row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">9</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="number token">1</SPAN>
cursor<SPAN class="punctuation token">.</SPAN>updateRow<SPAN class="punctuation token">(</SPAN>row<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="string token">"SOUTH-EAST"</SPAN>
<SPAN class="comment token">#SW</SPAN>
<SPAN class="keyword token">elif</SPAN> <SPAN class="punctuation token">(</SPAN>row <SPAN class="punctuation token">[</SPAN><SPAN class="number token">10</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">==</SPAN> <SPAN class="number token">8</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">8</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> int<SPAN class="punctuation token">(</SPAN>row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">8</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">-</SPAN> <SPAN class="number token">1</SPAN>
row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">9</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> int<SPAN class="punctuation token">(</SPAN>row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">9</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">-</SPAN> <SPAN class="number token">1</SPAN>
cursor<SPAN class="punctuation token">.</SPAN>updateRow<SPAN class="punctuation token">(</SPAN>row<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="string token">"SOUTHWEST"</SPAN>
<SPAN class="comment token">#NW</SPAN>
<SPAN class="keyword token">elif</SPAN> <SPAN class="punctuation token">(</SPAN>row <SPAN class="punctuation token">[</SPAN><SPAN class="number token">10</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">==</SPAN> <SPAN class="number token">32</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">8</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> int<SPAN class="punctuation token">(</SPAN>row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">8</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="number token">1</SPAN>
row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">9</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> int<SPAN class="punctuation token">(</SPAN>row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">9</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">-</SPAN> <SPAN class="number token">1</SPAN>
cursor<SPAN class="punctuation token">.</SPAN>updateRow<SPAN class="punctuation token">(</SPAN>row<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="string token">"NORTHWEST"</SPAN>
<SPAN class="comment token">#NE</SPAN>
<SPAN class="keyword token">elif</SPAN> <SPAN class="punctuation token">(</SPAN>row <SPAN class="punctuation token">[</SPAN><SPAN class="number token">10</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">==</SPAN> <SPAN class="number token">128</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">8</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> int<SPAN class="punctuation token">(</SPAN>row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">8</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="number token">1</SPAN>
row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">9</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> int<SPAN class="punctuation token">(</SPAN>row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">9</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="number token">1</SPAN>
cursor<SPAN class="punctuation token">.</SPAN>updateRow<SPAN class="punctuation token">(</SPAN>row<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="string token">"NORTHEAST"</SPAN>
<SPAN class="comment token">#North</SPAN>
<SPAN class="keyword token">elif</SPAN> <SPAN class="punctuation token">(</SPAN>row <SPAN class="punctuation token">[</SPAN><SPAN class="number token">10</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">==</SPAN> <SPAN class="number token">64</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">8</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> int<SPAN class="punctuation token">(</SPAN>row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">8</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="number token">1</SPAN>
cursor<SPAN class="punctuation token">.</SPAN>updateRow<SPAN class="punctuation token">(</SPAN>row<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="string token">"NORTH"</SPAN>
<SPAN class="comment token">#South</SPAN>
<SPAN class="keyword token">elif</SPAN> <SPAN class="punctuation token">(</SPAN>row <SPAN class="punctuation token">[</SPAN><SPAN class="number token">10</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">==</SPAN> <SPAN class="number token">4</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">8</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> int<SPAN class="punctuation token">(</SPAN>row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">8</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">-</SPAN> <SPAN class="number token">1</SPAN>
cursor<SPAN class="punctuation token">.</SPAN>updateRow<SPAN class="punctuation token">(</SPAN>row<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="string token">"SOUTH"</SPAN>
<SPAN class="comment token">#West</SPAN>
<SPAN class="keyword token">elif</SPAN> <SPAN class="punctuation token">(</SPAN>row <SPAN class="punctuation token">[</SPAN><SPAN class="number token">10</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">==</SPAN> <SPAN class="number token">16</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">9</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> int<SPAN class="punctuation token">(</SPAN>row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">9</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">-</SPAN> <SPAN class="number token">1</SPAN>
cursor<SPAN class="punctuation token">.</SPAN>updateRow<SPAN class="punctuation token">(</SPAN>row<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="string token">"WEST"</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>Append_management<SPAN class="punctuation token">(</SPAN>flow_dir <SPAN class="operator token">+</SPAN> <SPAN class="string token">"\\direction_values.shp"</SPAN><SPAN class="punctuation token">,</SPAN> flow_dir <SPAN class="operator token">+</SPAN> <SPAN class="string token">"\\updated_dir_values.shp"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"TEST"</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">""</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">""</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>Hi, there, I'm trying to run a for-loop that iterates through a shape feature class of GPS points, extracts the value for the flow direction at that point, and modifies the x (UTM_E) and y (UTM_N) coordinates based on which direction the flow path will take. I'm trying to then redraw that point based on the new x and y coordinates, but I'm having trouble writing the code that actually redraws the points using the new coordinate values, which are stored as fields in the feature class. And finally, I want to put that into another loop that it updates the values and redraws them N number of times.
Thank you!