|
POST
|
This is very easy to do using the .items() dictionary method. Consider: dict = {1:16, 2:17, 3:19, ...} key = 2 #this is your variable valueList = (16,17,18) # vals you are looking for in the keys. There's only one value per key right? dictItems = dict.items() for value in valueList: if (key, value) in dictItems: print str((key, value)) + " is in the dictionary!"
... View more
01-08-2015
10:19 AM
|
0
|
6
|
2608
|
|
POST
|
Okay - someone's probably made one of these already, but I'll stick it here incase I need it again.
... View more
10-30-2014
05:58 PM
|
0
|
0
|
3722
|
|
POST
|
Curtis, I agree with you. And I feel your pain...but we will march on! Hopefully someone on the ESRI Dev team notices this one... Too late for 10.3 though.
... View more
10-30-2014
05:48 PM
|
0
|
1
|
3722
|
|
POST
|
Yet in Python: >>> 'grid_code' == 'gridcode' == 'GRID_CODE' False
... View more
10-30-2014
05:05 PM
|
0
|
3
|
3722
|
|
POST
|
OK - Thought I was imagining stuff for a while but: In v10.2.2, the StreamToFeature tool still pumps out 'grid_code' field (or 'GRID_CODE' if using a shapefile. Thus. now with the advent of the 'gridcode' flavor in v10.2, the problem is actually worse now in that there are now three different flavors: 'gridcode', 'grid_code', and 'GRID_CODE' .... Right after I did a blanker find='grid_code' and replace='gridcode'. *&(^(^^%!!!!! I can't win... Note the StreamToFeature tool in v10.2 returns a schema of: For shapefile format: 'ARCID', 'GRID_CODE', 'FROM_NODE', 'TO_NODE' For FGDB format: 'arcid', 'grid_code', 'from_node', 'to_node'
... View more
10-30-2014
02:30 PM
|
0
|
5
|
3722
|
|
POST
|
Good point Curtis - I wasn't aware of that. As I recall, long ago it also used to be 'GRID_CODE' in caps... Maybe that flavor was for coverages.
... View more
10-29-2014
09:11 AM
|
0
|
0
|
3722
|
|
POST
|
Seems now in v10.2 the 'grid_code' field (field automatically generated when converting raster layers to vector layers) is now named 'gridcode' (no underscore). ...not that this ^%$#s up all my scripts or anything... Oh wait, it does!
... View more
10-28-2014
02:25 PM
|
0
|
9
|
6586
|
|
POST
|
Hi Richard, Well I guess it seems to work well now. Here's a somewhat recent example: https://community.esri.com/message/362783#362783 In that message I tried to goad someone from ESRI to give an explanation and/or assurance everything was a-okay now, but no takers.
... View more
09-02-2014
11:59 AM
|
0
|
0
|
1062
|
|
POST
|
Some comments: 1. os.walk does get a you a handle on the directory name that is being parsed, so you could look for if dirName[-4:] == ".gdb" and if found, set the workspace to it, and issue arcpy.listfeatureclasses(). However, if I were you I wouldn't waste time developing code in anything < than v10.1 (since there is so many cool new toys in v10.1 SP1 like .da cursors, and .da.walk). 2. How about just intersecting the extent rectangle of your clip layer vs. the extent rectangles of the FCs that are returned by *.walk? If there is no intersection, don't clip. This extent comparison is easier/faster to do in v10.1 BTW.
... View more
07-02-2014
03:27 PM
|
0
|
12
|
2387
|
|
POST
|
If you have v10.1+, you can use arcpy.da.walk: http://resources.arcgis.com/en/help/main/10.1/index.html#//018w00000023000000
... View more
07-02-2014
09:56 AM
|
0
|
0
|
2387
|
|
POST
|
I don't know of any literature. My approach has been to load the node data into Python dictionaries and then write code that traverse those dictionaries. Basically one dictionary is keyed by toNode values (either the TO_NODE value from the attribute table or end point x,y coordinate pairs)and each key then stores the OID(s) and fromNode(s). The other is keyed by fromNode and each key then stores the OID(s) and toNode(s). The technique then is to alternate through the keys in the dictionaries, getting a node, and then looking up the node that are attached (keeping track of the OIDs along the way), rinse and repeat.
... View more
07-01-2014
10:39 AM
|
0
|
0
|
917
|
|
POST
|
Each arc has a "first point" and "lastpoint" (aka FromNode and ToNode), which are properties easily retrievable by a search cursor or field calculator. Then the derived x,y coordinate pairs of the first and last points can then be used as unique identifiers to model flow/connectivity. Of course the StreamToFeature tool automatically populates topologically correct TO_NODE and FROM_NODE field values, so that's even more convenient.
... View more
06-30-2014
11:30 AM
|
0
|
0
|
917
|
|
POST
|
Would this "auto-relate" take place via the ArcMap (like you would want a button or script tool to select the records in table C, per your selected features in Feature class A), or in a stand alone script? Either way, this is very doable in Python using some search cursors... It might look something like: fc = r"C:\temp\test.gdb\my_fc"
fieldValueListA = [r[0] for r in arcpy.da.SearchCursor(fc, ["FIELD_A"])]
tblB = r"C:\temp\test.gdb\tbl_b"
fieldValueListB = [r[0] for r in arcpy.da.SearchCursor(tblB, ["FIELD_B"], "FIELD_A in (" + str(fieldValueListA)[1:-1] + ")")]
#....and so on
... View more
06-30-2014
09:45 AM
|
0
|
0
|
1046
|
|
POST
|
Ha - Didn't notice that the OP was almost 2 years old! Issue was probably fixed with 10.1 SP1 I bet.
... View more
06-24-2014
11:05 AM
|
0
|
0
|
647
|
|
POST
|
Scott - Your code executes fine for me in v10.1 SP1 (selection is made correctly). Are you sure that the SR you are trying to assign to your df extent polygon is okay? Is it defined? I have a layer in ArcMap TOC "County Bounadries", and this code executed correctly: mxd = arcpy.mapping.MapDocument("CURRENT")
df = mxd.activeDataFrame
polyObj = arcpy.Polygon(arcpy.Array([df.extent.lowerLeft, df.extent.lowerRight, df.extent.upperRight, df.extent.upperLeft]), df.spatialReference)
arcpy.SelectLayerByLocation_management("County Boundaries", "INTERSECT", polyObj)
... View more
06-24-2014
10:35 AM
|
0
|
0
|
647
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 08-29-2024 08:23 AM | |
| 1 | 08-29-2024 08:21 AM | |
| 1 | 02-13-2012 09:06 AM | |
| 2 | 10-05-2010 07:50 PM | |
| 1 | 02-08-2012 03:09 PM |
| Online Status |
Offline
|
| Date Last Visited |
08-30-2024
12:25 AM
|