I need to create a large number of Arcmap layer files (v9.3 or 10), perhaps a hundred, from lookup tables. I don't have to set the symbol patch itself, that can be random, but I do need the value and label attributes filled out. The lookup tables look like:
"FC","VALUE_FIELD","VALUE","LABEL"
"Wooded_area","CODE","1240012","Extracted"
"Wooded_area","CODE","1240022","Interpreted"
"Wooded_area","CODE","1240032","FCS-EOSD"
"Wooded_area","CODE","1240042","Land Cover, Circa 2000 - Vector"
And the result would resemble (except the symbols themselves):
I'd prefer a python based solution, via arcobjects+python if required, C# next, but anything that works, even partially or only conceptually, is welcome.
Answer
I was going about this the wrong way, and have since found a better approach: use coded attribute domains, added to the feature classes using gp.addsubtype. Then when the fc is dropped into a map it automatically uses a random symbol pallette with the appropiate labels spelled out. This is better than layer files because a) it will never get out of sync with the real data, and b) the friendly names (labels) are also visible in other places like Select by attributes.
Relevent code snippet (from full script).
reader = csv.DictReader(f)
for row in reader:
if row.get('fc_point'):
fc = row ['fc_point']
code = row ['fc_point_code']
name = row ['code_friendly_name']
gp.addsubtype(fc,code,name)
The csv table looks like:
"fc_point", "fc_point_code", "fc_line", "fc_line_code", "fc_poly", "fc_poly_code", "code_friendly_name"
,,,, "LX_2260009_2", "2260012", "Amusement park"
,,,, "IC_2360009_2", "2360012", "Auto wrecker"
"TR_1780009_0", "1780010",,,,, "Blocked passage"
No comments:
Post a Comment