|
POST
|
Combo Box: 1. The simplest way is to set the parameters "MultiValue" property to Yes, and then provide some optional parameters.... which involves manually typing them all in to the Toolbox GUI when you set up the script tool: http://resources.arcgis.com/en/help/main/10.1/index.html#/Setting_script_tool_parameters/00150000000n000000/ 2. Another way is to dynamically read the possible combo box field values from some existing table or some sort of script logic. This would be accomlished with a "tool validator class": http://resources.arcgis.com/en/help/main/10.1/index.html#/Customizing_script_tool_behavior/00150000000t000000/ 3. Yet another way (new in v10.1) is a "Python Toolbox", which I think has a different flavor of a "tool validator": http://resources.arcgis.com/en/help/main/10.1/index.html#/Creating_a_new_Python_toolbox/001500000034000000/. I havn't messed with that one yet.
... View more
09-19-2012
09:04 AM
|
0
|
0
|
6132
|
|
POST
|
Okay I get what you are doing... Here's what's wrong: If one of your query parameters is left blank, then you need to not execute that query. Blank parametrs are pased back to the script as a blank string. So for example if param3 and param4 are blank: param1 = "Dog" param2 = "3" param3 = "" param4 = "" Then in your query, when the query for param3 (a subset) is executed, basically you are saying "take my current selection, and from thoss records select the records where "MYFIELD = ''". Which correctly returns 0 records, becasue you don't have any subset records with '' (blank) values. What you need to do is if any of the query parameters is blank (i.e. ''), then don't execute that particular query. The logic of this may be a bit longwinded. something like: arcpy.SelectLayerByAttribute_management(lyr, "NEW_SELECTION", query) if unit != "": arcpy.SelectLayerByAttribute_management(lyr, "SUBSET_SELECTION", query1) if blk != "": arcpy.SelectLayerByAttribute_management(lyr, "SUBSET_SELECTION", query2) if lot != "": arcpy.SelectLayerByAttribute_management(lyr, "SUBSET_SELECTION", query3)
... View more
09-18-2012
01:29 PM
|
0
|
0
|
6132
|
|
POST
|
I guess my suggestion was to just make sure the queries are being executed correctly... For example, insert something like this after the SelectlayerByAttribute tools run: arcpy.AddMessage("Query selected " + str(arcpy.GetCount_management(lyr).getoutput(0) + " records...")
... View more
09-18-2012
12:38 PM
|
0
|
0
|
6132
|
|
POST
|
If nothing was selcted, what would you want the tool to do? Perhaps you could have something check if any records/features were selected? Like GetCount_mangement()
... View more
09-18-2012
10:51 AM
|
0
|
0
|
6132
|
|
POST
|
FYI: A ESRI nan is not the same as float('nan') or str(1e400*0) ...which I guess are other/older methods of evaluating nan values (http://stackoverflow.com/questions/944700/how-to-check-for-nan-in-python) So... >>> updateRow[updateRows.fields.index("HCB")] in [float('nan'), str(1e400*0)]
False but the math.isnan() works...
... View more
09-17-2012
03:07 PM
|
0
|
0
|
2176
|
|
POST
|
Found it math.isnan() as in >>> math.isnan(updateRow[updateRows.fields.index("HCB")]) True
... View more
09-17-2012
02:57 PM
|
0
|
0
|
2176
|
|
POST
|
I'm cursoring through a FGDB raster attribute table in v10.1... Some of the attribute values are "Null" (aka 1.#QNAN), but when when evaluated in a cursor, they appear as a value called nan, for example: >>> print updateRow[updateRows.fields.index("HCB")] nan Unfortunatly nan is not a string but a float value... which is what the HCB field type is. >>> type(updateRow[updateRows.fields.index("HCB")]) <type 'float'> And nan isn't the same as None >>> updateRow[updateRows.fields.index("HCB")] == None False Problem is, I need a way to test for these nan values and then evaluate them as 0's... Something like: hcbValue = updateRow[updateRows.fields.index("HCB")]) if hcbValue == None: hcbValue = 0 If these evaluated as None, then of course it would be easy... but they don't, so it aint. Anyone know how to do a conditional test for nan values???
... View more
09-17-2012
02:46 PM
|
0
|
2
|
2804
|
|
POST
|
Bummer... showGpMessage() is just a logging function - sends the gp messages to txt file. Might be frustrating, but adding time.sleep(1) between calls to AddField() might be your best option for now... At least you know it works...
... View more
09-13-2012
12:08 PM
|
0
|
0
|
2896
|
|
POST
|
Well that makes it complicated... Dumb question: Is there any change in behaviour if you leave off the default parameters in AddField? For example: arcpy.AddField_management(fc, "AssetObjectId", "LONG")
#instead of
arcpy.AddField_management(fc, "AssetObjectId", "LONG", "", "", "", "", "NULLABLE", "NON_REQUIRED", "") Is it possible to temporarily disable Forfront, and at least determine that doing so fixes the issue? Maybe your IT people will make an exception for you... mine did for me. FYI: I am running the following code in v10.1 SP0 (and actually running it as 16 seperate concurrent python.exe processesall at the same time using the subprocess module) and it is super stable. #Process: Adds the neccessary fields
arcpy.AddField_management(indxTileFC, "REMSOFT_ID", "LONG"); showGpMessage() #calcs this field in the post-process
arcpy.AddField_management(indxTileFC, "ACCBUFF", "SHORT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "ADMIN_NM", "TEXT", "", "", "20"); showGpMessage()
arcpy.AddField_management(indxTileFC, "COUNTY_NM", "TEXT", "", "", "20"); showGpMessage()
arcpy.AddField_management(indxTileFC, "CLASS_RPT", "TEXT", "", "", "8"); showGpMessage()
arcpy.AddField_management(indxTileFC, "CLASS_MODL", "TEXT", "", "", "8"); showGpMessage()
arcpy.AddField_management(indxTileFC, "DEFER_RSNS", "TEXT", "", "", "60"); showGpMessage()
arcpy.AddField_management(indxTileFC, "DEFER_YR", "SHORT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "DFR_YR_MDL", "SHORT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "DEM_ELV", "SHORT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "DEM_SLP", "SHORT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "DISTRCT_NM", "TEXT", "", "", "20"); showGpMessage()
arcpy.AddField_management(indxTileFC, "EAGLES", "SHORT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "FORESTED", "SHORT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "HCPLND_FLG", "SHORT"); showGpMessage() #added 20120827
arcpy.AddField_management(indxTileFC, "HCPUNIT_NM", "TEXT", "", "", "20"); showGpMessage()
arcpy.AddField_management(indxTileFC, "ITERATION", "TEXT", "", "", "18"); showGpMessage() #edit made for Rod to QC
arcpy.AddField_management(indxTileFC, "LANDCOV_CD", "SHORT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "LANDUSE_CD", "TEXT", "", "", "12"); showGpMessage()
arcpy.AddField_management(indxTileFC, "LCL_NW_ID", "LONG"); showGpMessage()
arcpy.AddField_management(indxTileFC, "LCL_PC_ID", "LONG"); showGpMessage()
arcpy.AddField_management(indxTileFC, "LCL_SPS_ID", "LONG"); showGpMessage()
arcpy.AddField_management(indxTileFC, "LCL_E_FLG", "SHORT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "LCL_F_FLG", "SHORT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "LCL_I_FLG", "SHORT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "LCL_S_FLG", "SHORT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "LCL_DF_YR", "SHORT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "LCL_RP_FLG", "SHORT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "LCL_UP_FLG", "SHORT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "LPU_CD", "SHORT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "LPU_NM", "TEXT", "", "", "30"); showGpMessage()
arcpy.AddField_management(indxTileFC, "LSMS_RIP", "TEXT", "", "", "12"); showGpMessage()
arcpy.AddField_management(indxTileFC, "LSMS_UP", "TEXT", "", "", "12"); showGpMessage()
arcpy.AddField_management(indxTileFC, "LYNX_OID", "LONG"); showGpMessage()
arcpy.AddField_management(indxTileFC, "MGMT_FUND", "TEXT", "", "", "4"); showGpMessage()
arcpy.AddField_management(indxTileFC, "MM_INT_OID", "LONG"); showGpMessage()
arcpy.AddField_management(indxTileFC, "MM_MA_OID", "LONG"); showGpMessage()
arcpy.AddField_management(indxTileFC, "MM_MA_NM", "TEXT", "", "", "50"); showGpMessage()
arcpy.AddField_management(indxTileFC, "MM_PLN_OID", "LONG"); showGpMessage()
arcpy.AddField_management(indxTileFC, "MM_PLN_LBL", "TEXT", "", "", "50"); showGpMessage()
arcpy.AddField_management(indxTileFC, "MM_PLN_STA", "TEXT", "", "", "18"); showGpMessage()
arcpy.AddField_management(indxTileFC, "MM_POL_OID", "LONG"); showGpMessage()
arcpy.AddField_management(indxTileFC, "MM_POL_LBL", "TEXT", "", "", "50"); showGpMessage()
arcpy.AddField_management(indxTileFC, "MM_POL_STA", "TEXT", "", "", "18"); showGpMessage()
arcpy.AddField_management(indxTileFC, "MM_SWA_OID", "LONG"); showGpMessage()
arcpy.AddField_management(indxTileFC, "MM_SWA_TNM", "TEXT", "", "", "50"); showGpMessage()
arcpy.AddField_management(indxTileFC, "MM_SWA_RSN", "TEXT", "", "", "75"); showGpMessage()
arcpy.AddField_management(indxTileFC, "NRF_DISP_O", "TEXT", "", "", "8"); showGpMessage()
arcpy.AddField_management(indxTileFC, "NSO_FH_OID", "LONG"); showGpMessage() #Future habitat areas
arcpy.AddField_management(indxTileFC, "NSO_KC_OID", "LONG"); showGpMessage() #Kilickitat Core
arcpy.AddField_management(indxTileFC, "NSO_KH_OID", "LONG"); showGpMessage() #Klickitat Habitat
arcpy.AddField_management(indxTileFC, "NSO_MGT_CD", "TEXT", "", "", "3"); showGpMessage()
arcpy.AddField_management(indxTileFC, "NSO_MGT_CS", "TEXT", "", "", "21"); showGpMessage()
arcpy.AddField_management(indxTileFC, "NSO_MGT_AR", "TEXT", "", "", "8"); showGpMessage()
arcpy.AddField_management(indxTileFC, "NSOMGT_OID", "LONG"); showGpMessage()
arcpy.AddField_management(indxTileFC, "NSO_NESTP", "TEXT", "", "", "4"); showGpMessage()
arcpy.AddField_management(indxTileFC, "O_CMZ_TY", "TEXT", "", "", "2"); showGpMessage() #OESF CMZ buffer type (i or e)
arcpy.AddField_management(indxTileFC, "O_CMZ_WTY", "SHORT"); showGpMessage() #OESF CMZ water type
arcpy.AddField_management(indxTileFC, "O_OC_DIST", "LONG"); showGpMessage() #OESF distance to ocean (saltwater)
arcpy.AddField_management(indxTileFC, "O_RB_DIST", "SHORT"); showGpMessage() #OESF riparian buffer distance
arcpy.AddField_management(indxTileFC, "O_RB_OID", "LONG"); showGpMessage() #OESF riparian buffer objectid
arcpy.AddField_management(indxTileFC, "O_RB_WTY", "SHORT"); showGpMessage() #OESF riparian buffer water type
arcpy.AddField_management(indxTileFC, "O_SWS_ID", "SHORT"); showGpMessage() #OESF subwatershed identified
arcpy.AddField_management(indxTileFC, "O_SWS_PCT", "FLOAT"); showGpMessage() #OESF percent of subwatershed in DNR's forested managment
arcpy.AddField_management(indxTileFC, "O_SWS_UAC", "FLOAT"); showGpMessage() #OESF subwatershed upland acres (no saltwater)
arcpy.AddField_management(indxTileFC, "O_UNST_SRC", "SHORT"); showGpMessage() #OESF unstable slope data source
arcpy.AddField_management(indxTileFC, "O_UNST_TY", "TEXT", "", "", "2"); showGpMessage() #OESF unstable slope type (i or e)
arcpy.AddField_management(indxTileFC, "O_UNST_WTY", "SHORT"); showGpMessage() #OESF unstable slope water type
arcpy.AddField_management(indxTileFC, "O_WET_TY", "TEXT", "", "", "2"); showGpMessage() #OESF wetland type (i or e)
arcpy.AddField_management(indxTileFC, "OWLS_1R", "LONG"); showGpMessage()
arcpy.AddField_management(indxTileFC, "OWLS_1R_E", "LONG"); showGpMessage()
arcpy.AddField_management(indxTileFC, "OWLS_M1", "SHORT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "OWLS_SW", "SHORT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "PARCEL_ID", "LONG"); showGpMessage()
arcpy.AddField_management(indxTileFC, "PEREGRINES", "SHORT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "PLS_OID", "LONG"); showGpMessage()
arcpy.AddField_management(indxTileFC, "PLS_SEC_NM", "TEXT", "", "", "20"); showGpMessage()
arcpy.AddField_management(indxTileFC, "PLS_TWNRNG", "TEXT", "", "", "8"); showGpMessage()
arcpy.AddField_management(indxTileFC, "REGION_NM", "TEXT", "", "", "20"); showGpMessage()
arcpy.AddField_management(indxTileFC, "RIU_CUR_ID", "LONG"); showGpMessage()
arcpy.AddField_management(indxTileFC, "RIU_MST_ID", "LONG"); showGpMessage()
arcpy.AddField_management(indxTileFC, "RMU_POLYID", "LONG"); showGpMessage()
arcpy.AddField_management(indxTileFC, "ROAD_BUFF", "SHORT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "ROAD_DIST", "LONG"); showGpMessage()
arcpy.AddField_management(indxTileFC, "ROS", "TEXT", "", "", "8"); showGpMessage()
arcpy.AddField_management(indxTileFC, "ROS_ZN_CD", "TEXT", "", "", "2"); showGpMessage()
arcpy.AddField_management(indxTileFC, "SHU_NM", "TEXT", "", "", "12"); showGpMessage() #added 20120905, csny490 - same as OWNGROUP field
arcpy.AddField_management(indxTileFC, "SLPSTB_AC", "FLOAT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "SOMU_CD", "LONG"); showGpMessage()
arcpy.AddField_management(indxTileFC, "SOMU_NM", "TEXT", "", "", "30"); showGpMessage()
arcpy.AddField_management(indxTileFC, "SOMU_PCT", "FLOAT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "SUB_CD", "TEXT", "", "", "8"); showGpMessage()
arcpy.AddField_management(indxTileFC, "SUB_NO", "LONG"); showGpMessage()
arcpy.AddField_management(indxTileFC, "SUB_PCT", "FLOAT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "SUB_UP_AC", "FLOAT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "SUR_OWN_CD", "SHORT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "SUR_OWN_NM", "TEXT", "", "", "50"); showGpMessage()
arcpy.AddField_management(indxTileFC, "TIM_OWN_CD", "SHORT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "TIM_OWN_NM", "TEXT", "", "", "50"); showGpMessage()
arcpy.AddField_management(indxTileFC, "WOGHI_INDX", "FLOAT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "WRIA_CD", "SHORT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "WRIA_NM", "TEXT", "", "", "30"); showGpMessage()
arcpy.AddField_management(indxTileFC, "XACT_TY", "TEXT", "", "", "2"); showGpMessage()
arcpy.AddField_management(indxTileFC, "XACT_OID", "LONG"); showGpMessage()
... View more
09-13-2012
10:46 AM
|
0
|
0
|
2896
|
|
POST
|
Work around idea: Manually build the FC schema how you want it, and store it somewhere.... And then reference that "template" FC in the arcpy.CreateFeatureclass_management() tool, thus negating the need to run the AddField() tool. Question: What virus scan software are you running on your workstation? I noticed this issue with Symantec, upon switching McAfee it went away.
... View more
09-13-2012
09:37 AM
|
0
|
0
|
3029
|
|
POST
|
Try this: arcpy.MakeFeatureLayer(fc, "lyr", "MY_FIELD in ('A','B')":
if int(arcpy.GetCount_management("fl").getOutput(0)) > 0:
arcpy.CalculateField_managment("fl", "MY_FIELD", "None", "PYTHON") or arcpy.MakeFeatureLayer(fc, "lyr", "MY_FIELD in ('A','B')":
if int(arcpy.GetCount_management("fl").getOutput(0)) > 0:
arcpy.CalculateField_managment("fl", "MY_FIELD", "NULL", "VB")
... View more
09-12-2012
10:19 AM
|
0
|
0
|
6849
|
|
POST
|
Wouldn't it be more efficient to just do: query = "SUBDIVISIO = '%s'" % (sub)
query1 = "UNIT_NUMBE = '%s'" % (unit)
query2 = "BLK_NUM = '%s'" % (blk)
arcpy.SelectLayerByAttribute_management(lyr, "NEW_SELECTION", query + " AND " + query1 + " AND " + query2) or better yet: arcpy.MakeFeatureLayer_management(lyr, "new_layer", query + " AND " + query1 + " AND " + query2)
... View more
09-12-2012
09:21 AM
|
0
|
0
|
1437
|
|
POST
|
Forgot to ask: Is there something unusual about your parent table or look up table? For example, is your look up table a GRID .vat, an ODBC table, Excel table, etc.? Posting more of your code would be helpful (use the # code tag button).
... View more
09-12-2012
08:06 AM
|
0
|
0
|
3438
|
|
POST
|
The Help topic is wrong in that regard. I cannot think of an instance when the join name would be an optional parameter. In fact the Help topic is pretty clear about the proper naming convention of the join name: http://resources.arcgis.com/en/help/main/10.1/index.html#//001700000066000000. Here is some of my own v10.1 Python code that uses the RemoveJoin tool: #Process: Populates the O_RB_DIST, O_RB_OID, and O_RB_WTY fields
oesfRipBuffFC = root + "\\layer_prep\\oesf_rip_buff.gdb\\oesf_rip_buff"
arcpy.MakeFeatureLayer_management(indxTileFC, indxTileFL, "FID_oesf_rip_buff > -1")
if int(arcpy.GetCount_management(indxTileFL).getOutput(0)) > 0:
arcpy.AddJoin_management(indxTileFL, "FID_oesf_rip_buff", oesfRipBuffFC, "OBJECTID", "KEEP_COMMON")
arcpy.CalculateField_management(indxTileFL, "O_RB_OID", "[oesf_rip_buff.LDO_OID]", "VB")
arcpy.CalculateField_management(indxTileFL, "O_RB_DIST", "[oesf_rip_buff.DISTANCE]", "VB")
arcpy.CalculateField_management(indxTileFL, "O_RB_WTY", "[oesf_rip_buff.SL_WTRTY_CD]", "VB")
arcpy.RemoveJoin_management(indxTileFL, "oesf_rip_buff")
... View more
09-12-2012
08:00 AM
|
0
|
0
|
3438
|
|
POST
|
You don't appear to be naming the join table you want to remove (which is required, and is the name of the join table). For example: fc = r"C:\temp.gdb\my_mc"
lut = r"C:\temp.gdb\my_lut"
arcpy.MakeFeatureLayer_managment(fc, "mickeymouse")
arcpy.AddJoin_mangement("mickeymouse", "ID", lut, "ID")
arcpy.RemoveJoin_management("mickeymouse", "my_lut")
... View more
09-11-2012
08:18 PM
|
0
|
0
|
3438
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 03-25-2014 12:57 PM | |
| 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 |
| Online Status |
Offline
|
| Date Last Visited |
08-30-2024
12:25 AM
|