|
POST
|
The starting point for learning about using arcpy cursors and python dictionaries is my Turbo Charging Data Manipulation with Python Cursors and Dictionaries Blog. You also will need to search on the Python forum for examples of iterating through directory and layer lists. Getting a grasp on the Python syntax of For loops will enable you to make Python cycle through all of your data for you.. Making an honest attempt at trying to write code for your particular problem and then posting to the Python forum when you get stuck is a good way to learn Python. There are several people here who are willing to help and point out coding errors and solutions, as long as you are making the effort to solve the problem for yourself.
... View more
08-09-2017
03:17 PM
|
2
|
1
|
2501
|
|
BLOG
|
During the past 6 months I have used the Multi-Field key to Single-Field Key tool to solve all kinds of problems that previously could not be resolved by ArcMap. For example, I have used it to detect variant components in a set of 8 fields that make up a contact name and address. I have managed to eliminate approximately 500K unique address variants which consolidated 2.3 million unique contact records to 1.8 million, and by continuing to use this tool I expect to eliminate over 100K more before my conversion Go Live date. The tool did case insensitive matching directly between fields with different capitalization formats without any need to standardize to a single capitalization format. It also matched sets of values that included Null values in some or all of the fields, so that in effect Null was treated as a real value that can be matched, which has always been a problem for me with standard joins. This tool is far better than the Make Query Table tool, because, unlike the Make Query Table tool, my tool does not impose any restrictions on editing, calculating, and refreshing of the data whether it is joined or not and my tool supports all join types, not just an inner join like the Make Query Table tool. My tool also performs much, much better than the Make Query Table tool on large data sets. I also frequently find myself using this tool rather than a standard join and select by attribute query on indexed fields across the join, because my tool performs 20 times better and saves me literally hours of wait time. I believe this tool should be part of the core ArcMap toolbox (with improvements by Esri to make it fully conform to all of their tool standards, of course). I strongly encourage you to try this tool if you deal with any composite field relationships between your feature classes and tables that you would like to behave like a standard single field relationship. And I would appreciate your feedback.
... View more
08-09-2017
02:28 PM
|
0
|
0
|
2386
|
|
POST
|
The calculation you want to do can be done if you apply the following steps: 1. If your ObjectID sort does not match the sequential order of the trip, use the Sort tool to create a replacement feature class that matches the sequence of the trip point order. If you must maintain the original feature class, first add a Long field to the original feature class and calculate the original non-ordered ObjectIDs into that field so they will be preserved in a new feature class, and then create a new feature class using the Sort tool. 2. Now that your ObjectIDs are sorted, add a Long field and calculate the ObjectID values plus 1 into the field ([OBJECTID] + 1). 3. Create a copy of the feature class with feature class to feature class tool. 4. Join the original ObjectID of the first sorted feature class to the ObjectID +1 field in the copy. 5. Calculate the fields you want to using formulas that use the differences between the record you are calculating and the record joined to it, which will be the previous point in the trip sequence. 6. To make the joined feature class point to the point after the records you are calculating, recalculate the ObjectID+1 field in the copy to be OBjectID - 1. Now your join links the records you are calculating to the data of the point that follows it. 7. Perform the calculations you need that need data from the point after the point records you are calculating. 8. Break the join. If you can replace the original feature class or your original feature class was already sorted correctly, you are done. If you need to transfer the data back to the original non-ordered point feature class, do a Join on the original ObjectID to the field in the sorted feature class that holds the static copy of that ObjectID and do calculations to transfer the data from the joined records into the original and then you will be done. Note: Using cursors and dictionaries is much faster than using the field calculator if you have a large number of points in your trips and many fields that need to be calculated, since a cursor can operate on all of the fields in a single pass, while the field calculator will repeatedly have to do a complete pass on all of the points for each and every field you need to calculate, and join calculations are slower than loading and reading a dictionary to do the point matching and data transfer.
... View more
08-04-2017
03:47 PM
|
1
|
4
|
2501
|
|
POST
|
I use Attribute Assistant to automate updates on data that is registered as versioned and that that is part of a Topology all the time and it works. However, aside from the topology, all of my feature classes are simple feature classes, not complex feature classes like Network Datasets or Geometric Networks. Anyway, I think there must be something more specific to your set up needs that is causing problems. Also, in what ways does Attribute Assistant not work for you?
... View more
08-03-2017
12:15 PM
|
0
|
1
|
8152
|
|
BLOG
|
I am not sure that a dictionary will improve the performance of code from the second post you referenced at all. In that post you are not trying to match an existing row. You're just transferring the data in every row without matching anything. So the random access capability of the dictionary is not being used and you can't eliminate any of the steps from the suggested code by incorporating a dictionary. I would agree with the comment that says you should avoid inserting to the geodatabase OID, area, and length fields. I would also not insert to a GlobalID field if you have one. There also a check for whether or not a field is editable. If SDE is involved more code to start and stop an edit session is required, and performance will drop. So what is the end goal of your question? A tool? If so, check out my alternative to the Append tool that is included in my Multi-Field to Single Field tool in this Blog. It deals with the non-editable fields issue and allows records to be transferred between two stand-alone tables, from a feature class to a standalone table, and between features classes with the same geometry type. However, I can't recall if I made it compatible with SDE or not. I think I did, but if not let me know. I have never tested the code with a geometric network. I primarily optimized them for simple feature classes and file geodatabases.
... View more
08-01-2017
03:49 PM
|
1
|
0
|
33911
|
|
IDEA
|
I am a user or Route Event Layers in ArcGIS Desktop, and have been testing their behavior in ArcGIS Pro 1.2. ArcGIS Pro allows me to create Route Event Layers, and allows me to do most functions that I can do in ArcGIS desktop. However, when I use the Create Relate tool in ArcGIS Pro and attempt to use the relate to display the associated records in the event layer table like I can in Desktop, the records that are returned in ArcGIS Pro are just the Route feature records that are associated with the events, not the actual event layer records, Please make the relate behavior for Route Event layers act the same as it does in ArcGIS desktop.
... View more
07-28-2017
07:14 PM
|
1
|
3
|
1957
|
|
BLOG
|
I would need more info about the inputs to the tool and the options you were using for the tool parameters. Was the IncludeNull option set to true? Did you try it set to false? Does your input layer contain any features with Null geometry? The portion of the code that is reporting an error came from Bruce, so I have not really debugged it much or necessarily tried to run all of the potential parameter options.
... View more
07-18-2017
07:25 AM
|
0
|
0
|
12945
|
|
POST
|
I actually rebuilt the function as a Python toolbox and used an insert cursor instead of Append. It should be found along with another tool I created in the first attachment (the 10.3+ version, not the 10.2 version) to this Blog post. I think it still has the refresh issue, but it does not have the inmemory table append issue. It works to append features between feature classes with the same feature type, feature class attributes into standalone table rows, and standalone table rows to standalone table rows for all matching fields, whether the target is the same as the source or different from the source. I use the other tool in the toolbox more, which creates a single long field key to represent a multiple field composite key in a pair of tables so that they can be joined or related based on matches from the multi-field relationship.
... View more
07-18-2017
07:17 AM
|
0
|
0
|
1119
|
|
POST
|
The proper procedure is wrong in step 1. You should start an edit session on the target feature class, not on the source shapefile. You can select features from any workspace as the set of features to copy with the copy button, but you can only paste to shapefiles/feature classes in the workspace/geodatabase target that you have started editing. In addition, both the source and target shapefile(s)/feature class(es) must be checked/visible in the Table of Contents and both layers' features must be selectable. Also, if the target feature class is in sde you must have edit privileges for that layer granted by the sde administrator, and you need to know whether the sde feature class is versioned or unversioned and match that setting in the Editor options before you start editing. You should also avoid placing a definition query on the target feature class. Other requirements include that you should only have selected features from one shapefile/feature class which has the same geometry type as the target shapefile/feature class.
... View more
05-07-2017
05:03 PM
|
1
|
0
|
2354
|
|
POST
|
Typically when code only works with hard coded values it is because the code either does not interpret the users choice in the same way as the hard coded values, or the user has the freedom to choose options that are not anticipated and handled by the code. Where would you insert the hard coded values? Anyway, I have no time for the forums anymore outside of my weekends, so I cannot do anything until then.
... View more
04-18-2017
07:50 AM
|
0
|
0
|
3123
|
|
BLOG
|
The error is occurring in a function Bruce wrote that is called multiple times from several methods with a variety of inputs, so I would have to set a bunch of print statements in the code to determine which part of the code is actually running when the error occurs. I would have to have your actual data to troubleshoot this error, since it has never occurred with any data I have used with the tool. Also you would have to show me the inputs to the tool you are using. Is your data using a projected coordinate system? It should be when using this tool.
... View more
04-05-2017
07:23 AM
|
0
|
0
|
12945
|
|
BLOG
|
Just to be sure I have verified that my original code as posted in the Blog still works when pasted into my original layer. So the likely lines that have a problem are those that have been changed to match your data: Line 3, Line 9, Line 12, Line 34, Line 43, Line 47 and Line 51. I would probably try isolating lines 1-30 from the remainder to see if lines 3, 9 and 12 can be verified. Then I would probably try commenting out lines 43 through 51 to see if line 34 caused any problem. Then if that passed I would verify the expression after removing the comment from line 43, then lines 44 through 49 and finally lines 50 and 51.
... View more
04-04-2017
12:55 PM
|
1
|
0
|
18247
|
|
BLOG
|
Did you fix the misspelled field name in line 3? I just noticed that I typed it as POOLYID5 when it should have been POLYID5. If that doesn't fix it, try pasting it in sections and verifying the expression for each. For example lines 1 through 30 should work without an error if you add this line (properly indented of course) after it: return [POLYID5] You need to isolate which line is triggering the error. Are you sure you put in the correct full path and file name of the related table in line 9?
... View more
04-04-2017
11:00 AM
|
0
|
0
|
18247
|
|
BLOG
|
The code below should work to create a basic label once you change the relateFC path in line 9 to match the actual directory path (including geodatabase name with extension like .gdb if applicable) and table name (including any file extension like .dbf if applicable) of your TBLSCHOO table. Let me know if you get any errors. # Initialize a global dictionary for a related feature class/table
relateDict = {}
def FindLabel ( [POOLYID5] ):
# declare the dictionary global so it can be built once and used for all labels
global relateDict
# only populate the dictionary if it has no keys
if len(relateDict) == 0:
# Provide the path and table name to the relate feature class/table
relateFC = r"C:\PathName\TBLSCHOO.dbf"
# create a field list with the relate field first (POLYID),
# followed by sort field(s) (SCHOOLID), then label field(s) (CROSS_STREET)
relateFieldsList = ["POLYID", "SCHOOL_ID", "NAME", "LO_GRID", "HI_GRID"]
# process a da search cursor to transfer the data to the dictionary
with arcpy.da.SearchCursor(relateFC, relateFieldsList) as relateRows:
for relateRow in relateRows:
# store the key value in a variable so the relate value
# is only read from the row once, improving speed
relateKey = relateRow[0]
# if the relate key of the current row isn't found
# create the key and make it's value a list of a list of field values
if not relateKey in relateDict:
# [searchRow[1:]] is a list containing
# a list of the field values after the key.
relateDict[relateKey] = [relateRow[1:]]
else:
# if the relate key is already in the dictionary
# append the next list of field values to the
# existing list associated with the key
relateDict[relateKey].append(relateRow[1:])
# delete the cursor, and row to make sure all locks release
del relateRows, relateRow
# store the current label feature's relate key field value
# so that it is only read once, improving speed
labelKey = [POLYID5]
# start building a label expression.
# My label has a bold key value header in a larger font
expression = '<FNT name="Arial" size="12"><BOL>{}</BOL></FNT>'.format(labelKey)
# determine if the label key is in the dictionary
if labelKey in relateDict:
# sort the list of the list of fields
sortedList = sorted(relateDict[labelKey])
# add a record count to the label header in bold regular font
expression += '\n<FNT name="Arial" size="10"><BOL>School Count = {}</BOL></FNT>'.format(len(sortedList))
# process the sorted list
for fieldValues in sortedList:
# append related data to the label expression
expression += '\n{0} - {1} - {2} - {3}'.format(fieldValues[0], fieldValues[1], fieldValues[2], fieldValues[3])
# clean up the list variables after completing the for loop
del sortedList, fieldValues
else:
expression += '\n<FNT name="Arial" size="10"><BOL>School Count = 0</BOL></FNT>'
# return the label expression to display
return expression
... View more
04-01-2017
09:18 AM
|
0
|
0
|
18247
|
|
BLOG
|
Joe: I probably can help you adapt the code. I will need to know what feature class and table is involved, what field or fields relate the two together, and what fields you want to appear in the label from the feature class and the related table. I would assist you to create a label that uses the basic label style shown in Example 1 as a starting point. After that, I can give general pointers on how to implement a more sophisticated label style, but implementing that style would be your responsibility.
... View more
03-31-2017
07:35 AM
|
2
|
0
|
18247
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 03-24-2026 11:37 PM | |
| 1 | 03-24-2026 08:01 PM | |
| 6 | 02-23-2026 08:34 AM | |
| 1 | 03-31-2025 03:25 PM | |
| 1 | 03-28-2025 06:54 PM |
| Online Status |
Offline
|
| Date Last Visited |
Thursday
|