|
POST
|
I have a help ticket open with Esri to try to get them to log this as a bug. I have demonstrated that just by including a field in the update cursor field list that is part of the label expression trigger for the feature linked annotation and updating a row inside an edit session that the annotation updates itself. This occurs even if all I do is open an edit session, open an update cursor and use updateRow on a row without using the update cursor to modify or read any of the field values in the row. So all update cursor updateRow events are treated by the Editor as though every Modify Record edit event included modifications to every field in the field list, even if no modifications of any kind were done. When the field list includes a trigger field for the feature linked annotation the field is always considered to have been modified by the Editor when the updateRow event is processed and the row's annotation is always rebuilt to replace any prior manual annotation edits. This is a severe bug or at least a behavior that requires a highly visible warning in the update cursor help so that users of feature linked annotation do not unknowingly use update cursors to trash months or years of manual annotation edits like I did. If I did not have a backup of the annotation this incident would have been an utter disaster.
... View more
09-12-2014
02:29 AM
|
0
|
0
|
3608
|
|
POST
|
I have been using code to transfer data from one source to another using a da update cursor. However, I got an unexpected and very upsetting behavior when I included a field in the update cursor field list that acts as a trigger to change the feature linked annotation when it is updated. This occurred on a versioned SDE feature class that requires the use of an edit operation to let the update cursor work. The field was only included in the update cursor's field list to provide a look up key to another table. No value changes or duplications were written to that Key field by the update cursor. The update cursor only read values from the trigger field. Updated values were only written to the other fields in the update cursor field list. Unfortunately, when I applied the updateRow action to the cursor for each row, the feature linked annotation had its TextValue update process triggered even though nothing had been written directly to the trigger field. I also noticed that when the update process triggered an annotation update that the update cursor sent the record through my record processing loop twice. Double processing of a record could have a severe impact on many cursor update operations. However, in this particular case it was only an issue because it slows down the update process. This behavior moved the annotation objects and overwrote annotation values that had been intentionally manually altered. This has corrupted my annotation feature class and I now am scrambling to get a backup restored. It never occurred to me that the field would act as a trigger for annotation just because it was included in the update cursor field list and read. Why is that behavior so different from the manual editing process, which only triggers an annotation update when the trigger field is altered or duplicated? I have modified the code to exclude all fields involved in the update of feature linked annotation, since I had another field that contained look up values related to the external table. By excluding all fields that can trigger annotation updates the update cursor does affect the annotation of the feature class. Also the records are processed just once by the cursor loop as well. I had also used similar code on the same feature class before and only when the trigger field was in the update field list did the cursor trigger the annotation to update. However, what if I had no alternative field availalbe and had to use the trigger field for the look up value? Disabling the feature linked update behavior seems to be the only solution in that case, I just wish I had known about this behavior before reconciling all of my versions. Is this behavior adequately documented? I don't recall reading or hearing about it. Here is the code in case anyone thinks I must have actually written updated values to the trigger field. The field that can trigger the feature linked annotation to update itself is called STNAME.
import arcpy
import os
from time import strftime
sourceFC = r"C:\Users\RFAIRHUR\AppData\Roaming\ESRI\Desktop10.2\ArcCatalog\Trans Connection to SQL Server.sde\MasterStreetName"
updateFC = r"C:\Users\RFAIRHUR\AppData\Roaming\ESRI\Desktop10.2\ArcCatalog\Trans Connection to SQL Server.sde\GDB_TRANS.TRANS.TRANSPORTATION_MAINT\CENTERLINE"
print "Make Feature Layer: " + strftime("%Y-%m-%d %H:%M:%S")
arcpy.MakeFeatureLayer_management(updateFC, "CENTERLINE_Layer")
arcpy.SelectLayerByAttribute_management("CENTERLINE_Layer", "NEW_SELECTION", "FULL_NAME_MIXED_CASE IS NULL")
records = int(arcpy.GetCount_management("CENTERLINE_Layer").getOutput(0))
while records >= 1:
print str(arcpy.GetCount_management("CENTERLINE_Layer")) + " Records Selected: " + strftime("%Y-%m-%d %H:%M:%S")
updateFC = "CENTERLINE_Layer"
workspace = r"C:\Users\RFAIRHUR\AppData\Roaming\ESRI\Desktop10.2\ArcCatalog\Trans Connection to SQL Server.sde"
sourceFieldsList = ["FULLNAME_ALL_CAPS", "FULLNAME"]
updateFieldsList = ["STNAME", "FULL_NAME_MIXED_CASE"]
valueDict = {r[0]:(r[1:]) for r in arcpy.da.SearchCursor(sourceFC, sourceFieldsList)}
edit = arcpy.da.Editor(workspace)
edit.startEditing(False, True)
edit.startOperation()
i = 0
with arcpy.da.UpdateCursor(updateFC, updateFieldsList) as updateRows:
for updateRow in updateRows:
i += 1
if i % 101 == 0:
break
keyValue = updateRow[0]
if keyValue in valueDict:
for n in range (1,len(sourceFieldsList)):
updateRow = valueDict[keyValue][n-1]
updateRows.updateRow(updateRow)
del valueDict
edit.stopOperation()
edit.stopEditing(True)
arcpy.SelectLayerByAttribute_management("CENTERLINE_Layer", "NEW_SELECTION", "FULL_NAME_MIXED_CASE IS NULL")
records = int(arcpy.GetCount_management("CENTERLINE_Layer").getOutput(0))
print "Finished All Records: " + strftime("%Y-%m-%d %H:%M:%S")
... View more
09-11-2014
01:23 PM
|
2
|
8
|
6539
|
|
POST
|
The Mark as Helpful option is hidden in the Actions drop down menu. That is even less obvious than the old forum's buttons on the right side of each post that all new users overlooked. This option should be more obviously exposed if it is the new basis of MVP rankings. Are Likes considered? Likes are the only thing I see anyone do consistently here and the only thing I could easily see that I could apply to each post.
... View more
09-11-2014
12:40 PM
|
0
|
0
|
3197
|
|
POST
|
I switched the correct answer to yours, although I would say all of the answers I have seen are correct. It only lets me mark one, but since yours included the code I can paste into my script and was posted first, I switched the answer to yours. (I gave all of them Like points).
... View more
09-11-2014
12:01 PM
|
1
|
3
|
3197
|
|
POST
|
Thanks. I had read that many months ago, but forgotten. I did consult the help for Get Count when I wrote the code, but obviously I only glanced through it and overlooked that it was returning an object and not a number.
... View more
09-11-2014
11:58 AM
|
0
|
0
|
3197
|
|
POST
|
You cannot do this will shapefiles, but with a file geodatabase you can use the Address Data Management tools available at this website (The Open button contains the download). These tools includes a feature construction tool that allows you to draw a new line in an edit session that will split any existing lines where they are intersected along with making proportional splits to the address ranges. It also comes with Attribute Assistant which can do many automated updates in an edit session, such as maintain a length field that is in units other than the feature units and or query intersecting features like Cities and ZIP code boundaries for information during an edit session. This should be in your maintenance toolset for address management. However, no tool does correct proportional editing of address ranges in a batch process. This would be a challenging script to write, primarily because it is hard to control the order of the many segments a line can be divided into so that you can correctly extract the range portions belonging to each segment. The math is not that hard if you know the original line length and could get the segments belonging to the original line to always be in an order where the TO end of the last line you processed was the FROM end of the next line If the lines had M values based on length, then such a script might be possible to write, because the M values can be written to fields that could maintain the correct sort of the segments. All you need then need is the original FROM and TO measure of the original line written to fields before doing the split and the current measures of the line to derive the address range portions. I have done that process with Route Events.
... View more
09-11-2014
11:53 AM
|
0
|
0
|
2768
|
|
POST
|
I have tried this code and it is producing an infinite loop that repeatedly prints "0 Records Selected". I know that the query is resulting in 0 records being selected. Why is the value returned from the GetCount_management function that reports as 0 considered be greater than or equal to 1?
import arcpy
import os
from time import strftime
updateFC = r"C:\Users\RFAIRHUR\AppData\Roaming\ESRI\Desktop10.2\ArcCatalog\Trans Connection to SQL Server.sde\GDB_TRANS.TRANS.TRANSPORTATION_MAINT\CENTERLINE"
print "Make Feature Layer: " + strftime("%Y-%m-%d %H:%M:%S")
arcpy.MakeFeatureLayer_management(updateFC, "CENTERLINE_Layer")
arcpy.SelectLayerByAttribute_management("CENTERLINE_Layer", "NEW_SELECTION", "OBJECTID = -1")
records = arcpy.GetCount_management("CENTERLINE_Layer")
while (records >= 1):
print str(arcpy.GetCount_management("CENTERLINE_Layer")) + " Records Selected: " + strftime("%Y-%m-%d %H:%M:%S")
arcpy.SelectLayerByAttribute_management("CENTERLINE_Layer", "NEW_SELECTION", "OBJECTID = -1")
records = arcpy.GetCount_management("CENTERLINE_Layer")
print "Finished All Records: " + strftime("%Y-%m-%d %H:%M:%S")
This alteration to the code works without producing an infinite loop.
import arcpy
import os
from time import strftime
records = 0
while (records >= 1):
print str(records) + " Records Selected: " + strftime("%Y-%m-%d %H:%M:%S")
## print str(arcpy.GetCount_management("CENTERLINE_Layer")) + " Records Selected: " + strftime("%Y-%m-%d %H:%M:%S")
## arcpy.SelectLayerByAttribute_management("CENTERLINE_Layer", "NEW_SELECTION", "OBJECTID = -1")
## records = arcpy.GetCount_management("CENTERLINE_Layer")
print "Finished All Records: " + strftime("%Y-%m-%d %H:%M:%S")
... View more
09-11-2014
11:17 AM
|
0
|
9
|
3789
|
|
POST
|
Here is the majority of the solution using a geoprocessing approach without scripting. It requires an Advanced license to use all of the tools listed here. A script may be able to bypass the need for so many tools, but the basic steps to get from a set of lines to a divided buffer should more or less follow this process. I do know that the first step is to get a buffer shape that will form the overall outline to be segmented. That shape will dissolve all lines together without any attributes dividing the segments. I would use Flat ends. See the resulting exterior boundary of the buffer shown in the picture at the bottom (interior lines are created in the rest of this process): It is that buffer which must be divided at the joints and the resulting divided set of polygons must be attributed by the original divided lines. Next I need the intersection point at every line junction where the attributes change and there are separate lines. Preferably unnecessary pseudo nodes have been eliminated. I would use the Intersect tool with the POINT option on the segmented lines to extract those points. This does not create a box at 4 way intersections, it creates an X, which is the only way to have polygons that only cover one line. A box would have to be created a different way and a manual choice would have to be made to assign only one line's attribute set. Next I added two double fields for the X and Y coordinates of the intersection points and a text field with a concatenation of the points. Then I do a Summary Statistics with the XY concatenation as the unique case value and the MIN_X and MIN Y coordinate summary to get an XY Event table of the points. Make that table into an XY Event layer. Create a fairly small buffer around these XY Event Layer intersection points. I used 20 feet and kept the X_Y_LINK, FREQUENCY, X_COORD and Y_COORD fields. Then I used the Features to Lines tool to convert the outer circular buffer boundaries around the intersections to lines as a SHAPEFILE You cannot output to a file geodatabase because it will use true curve arcs which won't work for the steps that follow.. Dissolve these arcs keeping the X_Y_LINK, FREQUENCY, X_COORD and Y_COORD fields to rejoin overlapping buffer outlines that are split up by the Features to Lines tool back to their circular shape. Next extract the end point of the circular lines to find the position where the circle will split that does not touch the original lines using the Feature Vertices to Point tool with the START option. Now I can intersect these circular lines with the original lines and use the POINTS option to get all positions on the circle cut by the original lines. I can then use the Split Line at Points tool on the circular lines with these latest points where the circle is cut by the intersecting original lines. I used a search tolerance of about .01 Now select all of the points that were at the start of the circle. Do a Search by Location to Remove from the Current Selection all points that are within about 1 foot of the points that cut up the circle. This may miss some very small arcs where a line and the circle start are close together, which may need to be cleaned up manually after the next step. The remaining circle ends should select the cut up lines on the circle outline to find the pair that should merge together that are not intersected by an original line. Dissolve these lines keeping the X_Y_LINK, FREQUENCY, X_COORD and Y_COORD fields and use the Unsplit lines option to create a new feature class. You may delete these arcs from the cut up circle outlines. Now clean up any small arcs where the start of the circle was close, but not on an original line manually. For the remaining arcs that were not touched by a circle starting point use the Feature Vertices to Points tool with the MID option on the remaining circle portions. Do the same with the Dissolved circle portions and append the two point feature classes together. This will only work correctly if the circular arcs are in a shapefile and not a file geodatabase. Add an X_TO and a Y_TO double field to these latest bearing points and calculate the coordinates of these new points into them. Use the XY To Line tool to make the X_COORD and Y_COORD the start of the line and the X_TO and Y_TO the end of the line. Convert the original buffers of the dissolved lines to lines using the Features to Line Tool. Copy these buffer outline into the Bearing lines feature class. Save the edit. Now use the Extend tool and extend double or triple the distance of the original buffer and use the Extend to Extensions rule. Examine the result for anomalies involving arcs that are greater than 180 degrees or intersection points within the buffer of each other. Use the Features to Polygons to convert the extended lines to polygons. Use the bearing lines to select polygons that actually enclose lines, the reverse the selection and delete the polygons from the buffer holes. Use the Spatial Join tool to transfer the attributes of the original lines to the points that divided the intersection circles. .Use these points to Spatial Join attributes to the polygons. The end result looks like the picture below: If certain roads were supposed to take away the triangular areas and you wanted a box intersection, a separate process would have to be developed by only buffering those roads with their attributes and cutting the intersection again and reassigning the triangular pieces to that line segment. The circle would only divide on those lines to form the bearing cut angles that would divide the box. However, without a way to classify the road that takes priority at the intersection, I cannot think of a way to get the box effect easily Wither way attributes would not divide the buffer on a through road at the intersections., but the lines segment end points would divide the circle and create the cuts at the center of the intersection genearly in line with the cross street.
... View more
09-10-2014
02:21 PM
|
2
|
7
|
10328
|
|
POST
|
For anyone wanting to create emf files, I have found that PowerPoint is the easiest editor to work with that outputs a clean emf file. Illustrator is hard to set up to avoid unwanted background elements in the emf file. Pasting an image into PowerPoint is easy to do by just pressing the paste button after doing a screen capture (Print Scrn button). I use the freeform drawing shape from the Drawing group on the Home tab to create a closed polygon. I also use the Fill Shape and Shape Outline drawing tools on the Home tab to adjust the color of the shape to solid black. When the shape is selected I can use the Drawing Tools Format tab for the Rotate tools (rotation of mirrored flips) to adjust the orientation of the shape to make the house front face north and create its mirrored layout. I have changed my Model Number values to put the tract first followed by the model. This makes symbols sort together in the symbology tab, which makes them easier to work with.
... View more
09-08-2014
08:56 AM
|
1
|
0
|
3282
|