POST
|
Thanks Xander. It makes sense now. I will use this code to make changes in my subbasin shape files too.
... View more
11-15-2017
07:24 PM
|
0
|
0
|
404
|
POST
|
yes it is working now. Thanks Dan. I appreciate that.
... View more
11-15-2017
07:22 PM
|
0
|
1
|
404
|
POST
|
# on line 10 before equal sign there should be "no_" instead of "tonode" (typo i guess) because you have not defined tonode. #if i make that change code does not produce the result that line 16 is showing when i run your code i got is_good array([2, 2, 3, 4, 5, 2, 2, 3, 6, 4, 5,7]) looks like your code is setting values in "is_good" equal to the last value of "to_" when "to_=from_" or when "to_" is equal to any value "in from_" if to_!=from_ then no change in values of "is_good" #That is replacemnet rather than updating values (if on line 10 it's "no_" rather than tonode) I guessing wording for my question was very confusing to begin with. But I liked practicing on your code for my own understanding :-). It helped me to understand about replacement Now going to practice on arcpy:-)
... View more
11-15-2017
06:08 PM
|
0
|
1
|
404
|
POST
|
>>> node_values My dictionary. for first part (search cursor) {1: 1, 3: 2, 4: 5, 5: 3, 6: 4, 7: 6, 8: 8, 9: 7, 10: 12, 11: 9, 12: 10, 13: 11, 14: 13, 15: 14, 16: 19, 17: 24, 18: 15, 19: 16, 20: 17, 21: 18, 22: 20, 23: 21, 25: 22, 26: 23, 27: 26, 28: 29, 29: 25, 30: 27, 31: 33, 32: 28, 33: 32, 34: 30, 35: 31, 37: 35, 38: 34, 39: 37, 40: 36, 42: 38, 43: 39, 44: 40} yes the code for search cursor part is correct. I matched it with attribute table(in attached shaped file).because i am updating my "from code" based on "grid code". Next step is to update "to node" but i am getting error there (update cursor part), because to_node does not have all values that "from node" has and that's how it should be. code should not care about matching it should just update "to node".
... View more
11-15-2017
01:50 PM
|
0
|
7
|
1670
|
POST
|
"to_node" depends on "from node".I just want to update "to_node". if i change "from node " lets say from node =3 has been changed to 2 then all 3's in "to node" should also changed to 2. Yes the reason I am getting error is because some values in "to_node" are occurring twice, because tributaries can drain into more than one river/streams. Repitition is ok. As long as values are being updated.But no repetition in "grid code" and "from node"
... View more
11-15-2017
01:43 PM
|
0
|
0
|
1670
|
POST
|
yes that's what i did in the above code. node_values = {} is dictionary but code gets an error when I try to change no node. It works fine for grid code and from node.
... View more
11-15-2017
01:05 PM
|
0
|
2
|
1670
|
POST
|
Dan Patterson i attached shapefile. You can familiar with watershed delineation so i guess i can give you some background why am i am doing this. I used swat model to delineate my watershed but because of low elevation, I am getting unwanted streams too (i tried burning original streams, arc hydro and different threshold value).Still I need to make some changes that involve removing some sub basins/streams , merging others. Because swat does not except any subbasin that does not have any stream draining into it. So if i remove unwated streams, i need to merge some subbasins. When i remove some streams it means that gridcode and from node will not be in consecutive order. Since swat model only accept watershed and streams that have consecutive gridcode for streams. So If I change gridcode, then it will also change from node and to node connection for streams. Long story 🙂 so i am trying to use arcpy to update my from node and to node when i change gridcode. gridcode should be same as from node and then no node will also change accordingly
... View more
11-15-2017
12:53 PM
|
0
|
0
|
1670
|
POST
|
I have three columns (other than OID FID) in my shapefiles for river. And I want to update "from node" and "to node column" Before update from node to node gridcode
2 3 8
3 2 9
7 2 5 After update, I want "node column" to be same as "grid code" column, so I used field calculator in ArcGIS (from node = gridcode). My "from node" column has been changed to gridcode but not sure how to update "to node" column (that depends on values in “from node” column) Below is the final result I want: from node to node gridcode
8 9 8
9 8 9
5 8 5 Half of the code is working
import arcpy, os, sys
from arcpy import env
fc=r"C:/Users/wis/Desktop/python/fe/fea_c.shp"
# instantiate empty dictionary
#'FROM_NODE','GRID_CODE','TO_NODE' name of columns in my attribute table
node_values = {}
# build dictionary of values
with arcpy.da.SearchCursor(fc, ['FROM_NODE','GRID_CODE']) as cursor:
for row in cursor:
old_node = row[0]
new_node= row[1]
node_values[FROM_NODE] = new_node
with arcpy.da.UpdateCursor(fc, ['FROM_NODE','TO_NODE','GRID_CODE']) as cursor:
for row in cursor: # set fromnode to gridcode value
row[0] = row[2] # set tonode to new equivalent node
to_node = row[1]# I get an error here
new_to_node = node_values[TO_NODE]
row[1] = new_to_node
cursor.updateRow(row) The error is because row[1] or "to node" does not have all numbers that are in "from node" or "grid code" Because some values will repeat in t"no node" because one river can be connected to more than one rivers. However no repetition in "gridcode" and "from node" Any suggestions
... View more
11-15-2017
12:12 PM
|
2
|
15
|
3695
|
POST
|
@ Phil Morefield did you find solution to your problem. I guess I followed some suggestions from stack overflow and now getting a new error File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\__init__.py", line 22, in <module> from arcpy.geoprocessing import gp File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\geoprocessing\__init__.py", line 14, in <module> from _base import * ModuleNotFoundError: No module named '_base' Please let me know if anyone has fixed this issue.
... View more
11-13-2017
09:17 PM
|
0
|
1
|
1042
|
POST
|
Any luck with ar hydro for v 10.4.1. It is keep crashing. Arc hydro worked when I was using 10.2.1. But i am unable to use i on new version for 10.4.1 yellow.esri.com - /archydro/archydro/Setup/10.4/10.4.0.12/ArcHydroTools10.4x64/
... View more
09-08-2017
09:46 AM
|
0
|
1
|
678
|
POST
|
I was using arc Swat to delineate my watershed. arc swat produce streams network using DEM and my resultant streams were disconnected so I came across arc hydro tool to burn actual network in my DEM. I am using 10 m USGS dem. Probably not the best choice (for hydrologic modeling) but LIDAR <5 DEM is not available in my study area. I reconditioned my DEM (somehow DEM leveling did not work for me after trying several times. I got error in arc hydro). Reconditioning worked then I build walls and in the last I did filling. Inner wall:- roads (all network, major minor) Breach line- all stream network I noticed that after using the resultant Dem, the flow paths for my network have improved, but my network is still disconnected at few locations. (see the images below please) Changing stream buffer from 5 number of cells to 10 also did not make a difference. However I have not played around with smooth drop raise and sharp raise. I was using default values in arc hydro manual. I also think that in my case there is not actually significant mismatch between actual and delineated streams but more like shorter length of delineates streams. The segments that dem missed to delineate are not only first order streams (that’s what I thought initially). Half of them are first order, remaining half ae higher order streams Some other things I am planning to do based on suggestions from old posts: Take raw DEM, convert it form 10 m to 1 meter by (raster resampling) and then repeat Dem Reconditioning, Build walls and Filling. However I don’t think that I will make much difference Take DEM that I have already reconditioned, burn it again with stream segments where there is mismatch between my actual and delineated network. (but I think that I am overusing burning and forcing my streams to follow a certain path. Still there is a chance this method wont work where segments are disconnected) By browsing through answers in this community related to arc hydro, someone suggested using roads as buffers and then clip streams segments where roads intersect. I think arc hydo already does that during building wall process. So I don’t need to do that Just in case I separately clipped my streams using 5 meter road buffer outside of arc hydro in arc gis and I got some tiny dots as segments where stream is crossing a roads. Now if I zoom , does not look like the problem is because of road crossing. For some reasons I think that I should fill my raw dem first then DEM reconditioning and then building walls) Any suggestions from experienced people would help me to improve my dem.
... View more
08-17-2017
11:00 AM
|
0
|
0
|
1437
|
Title | Kudos | Posted |
---|---|---|
2 | 11-15-2017 12:12 PM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|