I am doing a Python project on Stream Order.
So far my script can generate a stream vector fc (called 'Stream') and copy this into a map (called 'Map')
The script then colours the polylines blue according to a classification in the field 'grin_code' (actually the Strahler classification number, 1 to 4).
"# specify map in project named "Map"
m = p.listMaps('Map')[0]
# specify lyaer in map named "stream"
lyr = m.listLayers('Stream')[0]
# access symbology of maps and change symbology to graduated colors
sym = lyr.symbology
sym.updateRenderer('UniqueValueRenderer')
sym.renderer.fields = ['grid_code']
colorRamp = p.listColorRamps("Blues")[0]
sym.renderer.colorRamp = colorRamp
# sym.renderer.colorRamp = "Blues(4 Classes)_Sequential_2"
# save symbology back onto maps
lyr.symbology = sym
# save project
p.save()"
Now, I would like to adjust the line thickness for each category according to 'grid_code'.
This is what I did in ArcGIS Pro to achieve what I wanted.
What I would like to know is , how do I go about this in Python?
Creating these flow analyses is a fairly common task - so it is possible that creating this visualisation this has been tackled before.
Any help very much appreciated.
Solved! Go to Solution.
for width, item in enumerate(sym.renderer.groups[0].items):
item.symbol.size = width
lyr.symbology = sym
for width, item in enumerate(sym.renderer.groups[0].items):
item.symbol.size = width
lyr.symbology = sym
Well done Johannes,
So simple and easy to add to my code.
I only made one small change "width+1" as the zero indexing caused the '1' class to be zero width.
Such an elegant solution,
Thanks so much,
Anthony
for width, item in enumerate(sym.renderer.groups[0].items):
item.symbol.size = width+1
lyr.symbology = sym