POST
|
Unfortunately, join and update cursor won't work. I wrote the following function to get around AddJoin_management and CalculateField_management. CalculateField_management kept failing on 100k record datasets. def JoinAndUpdateField(fcTblPrimary, strJoinFldPrimary, fcTblForeign, strJoinFldForeign, strUpdateFldPrimary, strUpdateFldForeign, methodToProcess=None): """ Joins two tables or feature classes or combination and updates one field from another with optional passed method to update the value further. The same result can be gotten with arcpy AddJoin_management and CalculateField_management, but CalculateField_management kept failing on 100k record datasets. Parameters ---------- fcTblPrimary : str Full path to a fc or table e.g. c:/proj/data.gdb/datasetA or c:/proj/USER@VECTOR.sde/datasetB or Database Connections/USER@VECTOR.sde/datasetC strJoinFldPrimary : str Field of primary table to join on fcTblForeign : str Full path to a fc or table to join to strJoinFldForeign : str Field of secondary table to join on strUpdateFldPrimary : str Field to update strUpdateFldForeign : str Field to get value from for the update methodToProcess : method Optional Method to process the strUpdateFldForeign field before updating """ dictValues = dict ([(key, val) for key, val in arcpy.da.SearchCursor (fcTblForeign, [strJoinFldForeign, strUpdateFldForeign])]) boolUseMethod = False if methodToProcess: boolUseMethod = True with arcpy.da.UpdateCursor(fcTblPrimary, [strJoinFldPrimary,strUpdateFldPrimary]) as cursor: for row in cursor: try: if boolUseMethod: row[1] = methodToProcess(dictValues[row[0]]) else: row[1] = dictValues[row[0]] except KeyError: pass cursor.updateRow(row) del cursor del dictValues
... View more
09-19-2017
02:41 PM
|
0
|
0
|
303
|
POST
|
Further information from anonymous rogue GIS person, Background: I had domains created by old user accounts and couldn't delete. I setup an Oracle trace and deleted a test domain to see which SDE tables were affected. The trace showed the SDE tables SDE.GDB_ITEMS and sde_xml_doc1 being deleted from. Find your domains, using queries like above. Here is the online help reference for your type of database: Example: Finding domain owners using SQL—Help | ArcGIS Desktop . I recommend adding the GDB_ITEMS OBJECTID and DEFINITION column to the query. The DEFINITION column will be the key for deleting in the table sde_xml_doc1. One thing is that the xml magic query for the owner column may not work. For example in Oracle, we don't have the arcgis extproc setup (it's the dll or so file to access shape columns...something like that). You should know which domains to delete even without the owner. Query for Oracle without the OWNER: select a.OBJECTID, a.name "DOMAIN_NAME", b.name "TYPE", a.definition FROM SDE.GDB_ITEMS a INNER JOIN SDE.GDB_ITEMTYPES b ON a.Type = b.UUID WHERE b.Name IN ('Coded Value Domain', 'Range Domain'); OBJECTID DOMAIN_NAME TYPE DEFINITION -------------------------------------------------------------------------------- 1921 test_domain Coded Value Domain 181 So if you would like to risk corrupting the delicate web of SDE, make sure all tables/feature classes are no longer referencing the domain or deleted. Then something like this: DELETE FROM SDE.GDB_ITEMS WHERE OBJECTID = 1921; DELETE FROM SDE.sde_xml_doc1 WHERE SDE_XML_ID = 181; Commit; Embedded xml domains -- worst idea ever Esri!!!
... View more
07-21-2017
03:35 PM
|
5
|
0
|
2078
|
POST
|
Just FYI, I can't create and delete 3 insert cursors squentially without getting the following error. (Sequentially meaning that I'm creating and deleting the cursor before creating the next one). RuntimeError: workspace already in transaction mode Upon creating the third cursor and attempting to insertRow(), I get the error. It doesn't matter if I'm in the editing session or not. I can comment out any one of the 3 cursor insert blocks and the other 2 will work. Using a with clause or cursor = ..., doesn't matter with arcpy.da.InsertCursor('Points_Geom', ["PointID", 'SHAPE@XY']) as cursor:
cursor.insertRow((123458, (4364181.91, 263840.13))) or cursor = arcpy.da.InsertCursor('Points_Geom', ["PointID", 'SHAPE@XY'])
cursor.insertRow((123458, (4364181.91, 263840.13)))
del cursor
... View more
12-09-2013
08:45 AM
|
0
|
0
|
1324
|