|
POST
|
The way you have set up the dictionary it is going to overwrite all records read except the last record, as you have observed. This is expected behavior. To deal with 1:M relationships you have to determine if the values are a summary value like a sum or average, or if you want a list of values to iterate from the dictionary. So the example you should be looking at the "Using a Python Dictionary Built using a da SearchCursor to Replace a Summary Statistics Output Table" example in my Blog for an example of how to load a dictionary for a sum and count that can also find the average of the records. It sounds like you want a list of values to iterate so that you can draw down each until you reach your minimum value. So another for loop would be involved. Some untested code below shows the basic approach: import arcpy
# set your variables for the Allocation Claims feature class
updateFC_AllocClms = "SortedAllocationClaims"
fields_AllocClms = ["AllocClmNum","CorrAllocCreVal"]
# set your variables for the feature class with the joined Allocation Claims and Recipient Claims (spatial)
sourceFC_AllocClmsSpj = "AllocationClaimsSPJ"
fields_AllocClmsSpj = ["OBJECTID","AllocClmNum","RecClmNum","RecCreVal"]
# set the dictionary
Dict_AllocClmsSpj = {}
valueDict = {}
with arcpy.da.SearchCursor(sourceFC_AllocClmsSpj,fields_AllocClmsSpj) as searchRows:
for searchRow in searchRows:
keyValue = searchRow[1]
if not keyValue in Dict_AllocClmsSpj:
# assign a new keyValue entry to the dictionary storing a list
Dict_AllocClmsSpj[keyValue] = [searchRow[1:]]
else:
# dictionary keyValue exists so append to the list
Dict_AllocClmsSpj[keyValue].append( searchRow[1:])
# update the Sorted Allocation Claims FC with the new values for Allocation Credits ("CorrAllocCreVal")
with arcpy.da.UpdateCursor(updateFC_AllocClms, fields_AllocClms) as upRows:
for upRow in upRows:
KeyAllocationClaim = upRow[0] # key value is AllocClmNum
if KeyAllocationClaim in Dict_AllocClmsSpj: # if the KeyAllocationClaim is in the dictionary
for record in Dict_AllocClmsSpj[KeyAllocationClaim]:
if upRow[1] >= 15000: # and as long as credit value is >= to 15000
upRow[1] = upRow[1] - record[2] # subtract the Allocation Credit Value from the Recipient Credit Value in the Dict_AllocClmsSpj
upRows.updateRow(upRow)
... View more
09-12-2016
05:33 PM
|
2
|
1
|
5893
|
|
POST
|
I would look at dictionaries for all matching of tables and not use any embedded cursors or do any selectLayerByAttribute operations inside cursor loops which are slow. That approach will literally speed your code up by at least 10 times for each time you replace an embed a cursor or replace a SelectLayerByAttribute query in a cursor loop. I never use embedded search or update cursors or selectLayerByAttribute within a cursor loop anymore. All data record comparisons, selections and transfers between any two tables use a dictionary between the tables in my code. See my Blog on Turbo Charging Data Manipulation with Python Cursors and Dictionaries for the basics of the method. The code below is not going to read through your sourceFC table: if KeyRecipientClaim not in sourceFC: that code translates to: if KeyRecipientClaim not in "UpdatedRecipientClaims" : which ought to cause an error.
... View more
09-08-2016
03:26 PM
|
1
|
0
|
3691
|
|
POST
|
If this behavior is always triggered in an ArcMap Desktop edit session whenever you create a feature or modify its geometry, you can use Attribute Assistant to do this using the X_COORDINATE and Y_COORDINATE methods. You need to create an entry for each method and each target feature class in the dynamicValues table and add that table to your map, then make sure the Attribute Assistant add-in is turned on. You can get Attribute Assistant here by pressing the Download button.
... View more
09-06-2016
12:58 PM
|
1
|
0
|
3122
|
|
POST
|
Since I cannot examine the sketch properties I cannot say that the route is not the problem. Routes with the very smallest of imperfections can create an issue, and the problem is usually invisible until you zoom in extremely close. Even an apparent two point straight line can end up being a 3 point line that doubles back on itself. The fact that the point is virtually in line with the route shown and your tolerance must be fairly high, that could be the problem. Is that the situation for all of the points involved? In any case, you have to find the common pattern, since I assure you this is not a purely random issue. I have not seen this occur with the setting I use. To figure this out I would need to see all 6 examples and the sketch properties of the routes to come up with what is really happening between the route configuration and the point location relative to the route..
... View more
08-09-2016
08:14 PM
|
1
|
0
|
3174
|
|
POST
|
I have not observed that behavior and have created millions of events with this tool, so it is something in your Route geometry I bet. I would need to see an example of the Route and event. Are you sure your Route is not scrambled? If it is a complete loop route and built using the Create Routes tool, all vertice pairs will become scrambled and flip directions and measures like crazy, resulting in very random events and meaningless outputs from the other LR tools. A self-intersection in the Route that is very small (virtually invisible) might cause this behavior. Anyway, you have to zoom in very tight and look at your Route Sketch Properties to find out if the Route producing this result is multi-part, contains increasing and decreasing measures, etc. Probably the only real solution is to correct or simplify the geometry to ensure the side of the line touched does not flip.
... View more
08-09-2016
01:46 PM
|
1
|
0
|
3174
|
|
POST
|
If you have an Advanced license you can use the Feature To Polygon tool. It will take both the polygon and the line inputs and divide the polygons wherever the lines fully intersect one of the polygons. You can use the Identity tool with the output to transfer the attributes of the original polygons back into the cut polygons. Your polygons need to be topologically clean (no overlaps) for this to work well.
... View more
08-09-2016
09:11 AM
|
1
|
0
|
4483
|
|
POST
|
The results are again correct, since the Spatial Join intersect behavior does consider touching boundaries to be intersecting, since it has to in order to be able to Spatially Join lines or points to polygon features. If it excluded touching of shared boundaries then it could not deal with Spatially Joining lines and point features, only polygon features, but since it does not have the options to specify the output geometry like the Intersect tool does, it has to treat line and point intersections on shared boundaries as valid intersections. So while it is understandable that you do not want these results when both inputs are polygons, I have already explained that the result you got are consistent with the Spatial Join tool behavior for Intersect. Since the Spatial Join tool was never built to require that any of the inputs had to be polygons, let alone both of them, it was by design made to always treat the intersect rules of all shapes with all shapes (polygon, lines and points) as valid intersections. So this is what I meant in the last sentence of my post about needing to use a negative buffer even when the shapes are topologically correct every time you Spatially Join two polygon layers to avoid getting attributes where polygon edges touch. However, do not use the negative buffer option of the Spatial Join tool. The Buffer tool runs much faster than using the negative buffer option of the Spatial Join tool, so you should include the Buffer tool in your script before doing the Spatial Join so that one of your feature classes has a negative buffer applied first. Then you would Spatially Join one of your original feature classes to the new feature class you have created with negative buffers. Since your topology is good you can make the negative buffer very small as long as it is at least more than double your tolerance setting. If one of the feature classes has fewer shapes than the other it should be the feature class that you apply the negative buffer to, since you can apply the negative buffer to either of the polygons sets and the only consideration is which will create the negative buffers the fastest. I have a similar requirement for Building Permits and Tract boundaries, and I always have to apply a -10 foot buffer using the buffer tool because my topology is not that good, but even if it was perfect I would have to use a negative buffer to avoid counting all permits that aligned perfectly to the boundaries or corners of any two or more tracts that shared a boundary or a corner. I do the negative buffer for the tracts, since there are far fewer tracts than there are permits. I then join the count result back to the original tract shapes on a unique ID field and transfer the count, so that the shapes are not reduced in the final output.
... View more
07-29-2016
03:09 PM
|
3
|
1
|
3306
|
|
POST
|
Do this for the calculation: arcpy.CalculateField_management ("swXSectionPoint", "Point_Type", '"UNKNOWN"') Notice that the expression cannot be "UNKNOWN", it must be '"UNKNOWN"' (single quote, double quote, UNKNOWN, double quote, single quote). This assumes that swXSectionPoint is a layer recognized by the script and that Point_Type is a field in that layer. There is no bug and support will tell you to write the calculation expression the same as what I have written in this post.
... View more
07-27-2016
11:56 AM
|
0
|
0
|
3822
|
|
POST
|
In a script you have to quote the expression regardless of what the value inside it contains (field names, numbers and strings all have to be in quotes). So 'UNKNOWN' equates to an unknown value of UNKNOWN (no quotes) to the field calculator, which does not exist and causes an error. You want to sent "UNKNOWN" (a quoted string), so you have to put that in quotes in the script, i.e., ' "UNKNOWN" ' (works for VB Script or Python calculations) or " 'UNKNOWN' " (works only for Python calculations).
... View more
07-27-2016
10:26 AM
|
0
|
2
|
3822
|
|
POST
|
No, that is not the problem. It is that it must quote a quoted string, since the expression in the normal field calculator must be quoted. "UNKNOWN" is what you should enter in the field calculator outside of a script. Inside a script that quoted string needs to be quoted again to send it as a string value with quotes.
... View more
07-27-2016
10:18 AM
|
0
|
4
|
3822
|
|
POST
|
You forgot the quotes for the expression. It needs to be '"UNKNOWN"' Quotes are always the first thing to check whenever you do calculations, especially when they are run in a script.
... View more
07-27-2016
07:26 AM
|
0
|
0
|
3822
|
|
POST
|
There is only one more step if this is a file geodatabase and that is to create a file geodatabase. Otherwise there are no more steps, especially if this is a selected feature being exported. And the benefits are no truncated or useless 10 letter field names and domains can be preserved. I also have never been forced to send out an entire geodatabase or feature dataset if I don't want to, since I can either use Export or Feature Class to Feature Class to avoid that. In any case, for me personally I only would export to a shapefile if the other party was not using ArcGIS software or perhaps an older version of ArcGIS than 10.1, but not to a person that was using ArcGIS 10.1 or higher. Anyway, this particular example as described would not lead me to create a shapefile.
... View more
07-26-2016
07:26 AM
|
3
|
0
|
4178
|
|
BLOG
|
I have developed a tool for splitting address ranges and have attached it. Below is a description of how it works. The toolbar is tied to an Editor Extension that must be enabled in order for the tools to work. It is using the Python Editor extension which can slow performance when doing edit selections, so you generally should leave the extension off and only turn it on when you need to do address range splits or manipulations. To turn the extension on or off click on the Customize menu->Extensions… submenu and when the extension dialog opens check or uncheck the item outlined in red shown below: The tools on the toolbar only become enabled when you begin an Editor session. You need to select the polyline layer you want the tools to act on in the table of contents window (the layer name must be highlighted) The toolbar is shown below and has five groups of tools. The first tools flip line geometry without affecting address range values. The first two tools are the same as the Edit Vertices tool and the Flip tool for a single selected line you are familiar with in ArcMap. The third button uses the Flip Line tool which will flip all selected lines, but it requires an Advanced license to use it. The second set of tools swap address values between the different address range fields. The first 3 buttons swap dual address pairs. The six other buttons swap single address pairs. With these 9 buttons all swap combinations can be done either by a single button or combining two or three buttons. The next drop down is a list of field names that match the address range fields in your polylines. The tool should detect this if your layer uses one of the listed set of field names and select the one that matches. If it does not match you field names tell me what they are and I will add you address range field names to the list. You can manually type the names in, but I prefer to make the list cover all user configurations. The next two drop downs control the snap tolerance affecting whether or not a line will split and whether that split will occur on a vertex or just on a line edge, respectively. The units are in the native units of your layer. The last two tools split lines and address ranges. It is critical that your line geometry and ranges are aligned together properly before you use these tools. The first button is like the ArcMap Split tool where you must select a single line from the highlighted layer and click on the map to split the geometry and address ranges proportionally. The second button is like the Planarize tool and requires that you select two or more intersecting lines from the highlighted layer that will split the geometry and proportional ranges where they intersect each other. Let me know if this works for you or if you have any problems. There are some known limitations, particularly if you are editing SDE data.
... View more
07-22-2016
03:08 PM
|
1
|
0
|
1653
|
|
POST
|
Unfortunately VB Script cannot be used to get a map document title or anything else from the map document. That used to be possible when ArcMap supported VBA, which could use ArcObjects to access those properties, but all ArcObjects code was dropped once VB Script became the basis of the field calculator. Now only Python can be used to do anything related to mapping or Add Ins/Extensions built using Visual Studio and .Net/ArcObjects. You could try building a Python Add In Editor Extension which could listen for edit events and attempt to trigger the update with your calculation code, but the Python Editor Extension Add In does not really work well and is very limited and frustrating to work with, and the .Net Editor Extension is much better. The Python Add In Editor Extension is essentially unusable if you edit in SDE, it is really only somewhat OK if you edit shapefiles/fgdb/personal gdb data. Edits triggered by the Python Editor Extension cannot be undone by the user and the user either has to save all edits or stop the Edit session and lose all edits. Anyway, you have to give up on Attribute Assistant for the functionality you want. It is simply incapable of doing this.
... View more
07-22-2016
12:52 PM
|
0
|
0
|
2436
|
|
POST
|
I can use that workflow for files I develop at home and bring in to work. However, in some cases I may not be able to do that. Anyway, the success of what you tried with Illustrator would seem to isolate the problem to the freeware converter I tried, which apparently did not adhere to the emf standard expected by Pro, but did adhere to an emf standard that works with ArcMap Desktop. I think I will have to try some other freeware wmf to emf converters or find a freeware graphics program that is compatible with emf files for Pro and easy enough to work with in the place of the program I currently use that only outputs wmf files.
... View more
07-19-2016
09:14 AM
|
0
|
0
|
5495
|
| 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 |
Online
|
| Date Last Visited |
Saturday
|