|
POST
|
I think you may want ListLayers(df), not ListLayers(mxd).
... View more
02-10-2015
01:04 PM
|
0
|
2
|
1730
|
|
POST
|
Maybe post a screenshot of part of your attribute table.
... View more
02-10-2015
12:58 PM
|
0
|
0
|
622
|
|
POST
|
I don't think python would be casting numeric data types to strings. That doesn't make sense.
... View more
02-10-2015
12:53 PM
|
0
|
1
|
3008
|
|
POST
|
Well, without going through everything, you could try testing if len(row[1]) < 1. You could also try printing row[1] in the loop. see what values it's finding. Or enclose row[1] is None in (), or even try Null instead of None, although I don't expect that to work. If nothing else, these methods might give you some clue as to what's going on.
... View more
01-15-2015
07:55 AM
|
0
|
0
|
5674
|
|
POST
|
I don't use ModelBuilder, but python runs as a script; that is, a line of code doesn't run until the previous line is done (unless maybe you get into threading and whatnot). I believe in ModelBuilder you can right click on your modules and export to a python snippet. This should give you an idea of what to script, although you may need to tweak it a bit. There's also a sleep function you could call in between applying the sumbology and exporting to kmz, but don't know if that's available in ModelBuilder.
... View more
01-02-2015
12:52 PM
|
0
|
3
|
1383
|
|
POST
|
Well, the easiest way would be to go to those coordinates on the map and add a point. One of the tools on the Tools toolbar is Go To XY: There's also the Add XY Coordinates tool. Either way, you'll need the new coordinates in the same coordinate system as your shapefile,
... View more
12-18-2014
08:56 AM
|
0
|
0
|
852
|
|
POST
|
Not sure I understand your question correctly. You don't have location type data at the district level, so you can't show it like that. You could perform a statistical analysis - average, sum, count, etc. - of your local data aggregated at the district level, which I'd put in a third shapefile or feature class, but you can't do it directly. You may also have to do some apportioning if local areas can be in more than one district. Or am I misunderstanding your question?
... View more
12-17-2014
06:59 AM
|
0
|
0
|
1014
|
|
POST
|
If you want 0 if either Test1 or Test2 = 'FAIL', and 1 if both = 'PASS", try this: def Final(t1, t2):
if t1 == 'FAIL' or t2 == 'FAIL':
val = 0
elif t1 == 'PASS' and t2 == 'PASS':
val = 1
else:
val = 2 # this allows you to check if t1 or t2 had some other value, (except for the first case, at least one = 'FAIL')
return val
... View more
12-11-2014
12:48 PM
|
1
|
1
|
4305
|
|
POST
|
Is the field you're calculating a date type field or text? Either way, you can use these types of code snippets in Field Calculator, but you may want/need the Advanced codeblock to set up a def returning your value.
... View more
12-10-2014
12:18 PM
|
2
|
1
|
7018
|
|
POST
|
Yes, that's what it would mean, except I can see it's there. Printing the keys and values prints the correct sequences. Anyway, I got it to work by changing alias = dictflds[fld.name] to alias = dictflds.get(fld.name, 'None'). No idea why the first method didn't work if the second does, but I've spent enough time on this. Thanks for the help, appreciate it.
... View more
12-10-2014
05:48 AM
|
1
|
0
|
2222
|
|
POST
|
Thanks Joshua. I changed the name of the dictionary to dictflds. The error I get if I try to access the value outside of the try block is KeyError: u'B01001e1', and the error when in the try block reads Line 45, B01001e1, where the line number is wherever I first try to access the dictionary value and B01001e1 is a valid field name. It's not that particular value that's a problem; the error occurs for every field. I've tried enclosing it in str(), setting it to a variable both when accessing it and setting the key, no luck. If I just print fld.name, works fine. Full code (minus header comments) below. import arcpy, os
from arcpy import env
env.workspace = r'K:\Projects\Other Depts\Planning\Lori_Census\Census.gdb'
def main():
metatable = 'BG_Metadata_2012'
metaflds = ('Short_Name', 'Full_Name')
est = '--(Estimate)'
moe = 'Margin of Error'
dictflds = {}
# Get dictionary of short names and corresponding full names from metadata
# table, skipping moe fields and removing whitespace and estimate text from
# full name.
with arcpy.da.SearchCursor(metatable, metaflds) as rows:
for row in rows:
if not moe in row[1]:
fn = row[1].replace(' ', '')
fn = fn.replace(est, '')
dictflds[row[1]] = fn
for k, v in dictflds.iteritems()
print(' : '.join([k, v]) # works fine
# Get list of tables to add alias to
tbls = arcpy.ListTables()
for tbl in tbls:
tblflds = arcpy.ListFields(tbl)
for fld in tblflds:
try:
print(fld.name) # works fine
alias = dictflds[fld.name] # exception raised here
print(alias)
print(' : '.join[tbl, fld.name, alias])
arcpy.AlterField_management(tbl, fld, new_field_alias=alias)
except Exception as e:
import traceback
import sys
tb = sys.exc_info()[2]
print('Oh no!')
print("Line {0}".format(tb.tb_lineno))
print(e.message) # this prints the fld.name value
if __name__ == '__main__':
main()
... View more
12-08-2014
11:26 AM
|
0
|
2
|
2222
|
|
POST
|
In the code below, line 14, 'alias = dict[fld.name]', always throws an exception. I don't see why; printing out fld.name works just fine. Also, the exception message is the field name printing correctly. Printing the dictionary keys and values also works fine. The ultimate goal is to get a string to set as the field alias using AlterField. Thanks. with arcpy.da.SearchCursor(metatable, metaflds) as rows:
for row in rows:
if not moe in row[1]:
fn = row[1].replace(' ', '')
fn = fn.replace(est, '')
dict[row[0]] = fn
# Get list of tables to add alias to
tbls = arcpy.ListTables()
for tbl in tbls:
tblflds = arcpy.ListFields(tbl)
for fld in tblflds:
try:
alias = dict[fld.name] # exception raised here
print(alias)
except Exception as e:
import traceback
import sys
tb = sys.exc_info()[2]
print('Oh no!')
print("Line {0}".format(tb.tb_lineno))
print(e.message)
... View more
12-08-2014
10:10 AM
|
0
|
4
|
3936
|
|
POST
|
It's hard to say without seeing your code, but what pops out is it appears you're using the gpscripting code on Arc 10.1, when you should be using arcpy. I don't know what those last two lines are in English, so can't say much beyond that. Post the relevant code, be easier for folks here to debug.
... View more
12-08-2014
10:05 AM
|
0
|
0
|
1671
|
|
POST
|
Thanks. I may use this myself. I did write a script to delete the 'Margin of Error' fields. Not relevant for our uses, and they double the number of fields. My data wasn't joined to the polygon file, though, when I downloaded it. Relationship classes are there, but not actually working.
... View more
12-05-2014
10:08 AM
|
0
|
0
|
713
|
| Title | Kudos | Posted |
|---|---|---|
| 6 | 08-22-2019 07:41 AM | |
| 1 | 05-05-2014 04:30 AM | |
| 1 | 08-15-2018 06:23 AM | |
| 3 | 08-06-2018 07:31 AM | |
| 1 | 03-30-2012 08:38 AM |
| Online Status |
Offline
|
| Date Last Visited |
12-12-2021
01:00 PM
|