|
POST
|
Here is some code that does a similar thing... been working great for years... fieldInfo = ""
fieldList = gp.listfields(layerPath)
for field in fieldList:
if field.name == "PARCEL_SYST_ID":
fieldInfo = fieldInfo + field.Name + " " + "PARCEL_ID" + " VISIBLE;"
elif field.name == "SURFACE_TRUST_CD":
fieldInfo = fieldInfo + field.Name + " " + "SUR_OWN_CD" + " VISIBLE;"
elif field.name == "SURFACE_TRUST_NM":
fieldInfo = fieldInfo + field.Name + " " + "SUR_OWN_NM" + " VISIBLE;"
elif field.name == "TIMBER_TRUST_CD":
fieldInfo = fieldInfo + field.Name + " " + "TIM_OWN_CD" + " VISIBLE;"
elif field.name == "TIMBER_TRUST_NM":
fieldInfo = fieldInfo + field.Name + " " + "TIM_OWN_NM" + " VISIBLE;"
else:
fieldInfo = fieldInfo + field.Name + " " + field.Name + " HIDDEN;"
gp.MakeFeatureLayer_management(layerPath, "feature_layer", "", "", fieldInfo[:-1]); showGpMessage()
gp.MultipartToSinglepart_management("feature_layer", fgdbPath + "\\" + layerName); showGpMessage()
... View more
06-29-2011
08:24 AM
|
0
|
0
|
4141
|
|
POST
|
Not too suprised this isn't working in Python. Try using the gp.AssignDefaultToField_management() tool again directly in the script, otherwise, maybe just hardcode the default values in the insert cursor?
... View more
06-29-2011
08:17 AM
|
0
|
0
|
724
|
|
POST
|
See: http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//000800000005000000.htm Note in the Python examples, you shouldn't have to put those weird "/"s in the SQL statements. Wish ESRI would clean up their code examples in the documentation... Your expression could be written as: "MTFCC = 'H3010'"
... View more
06-27-2011
08:59 AM
|
0
|
0
|
533
|
|
POST
|
I kinda hinted at this before, but the code block parameter for the CalculateField tool is notoriously difficult (especially if you start trying to put dictionaries and what not into the code). See: http://forums.esri.com/Thread.asp?c=93&f=1729&t=262236#806786 I would offer that perhaps your best bets would be: 1. Rewrite your process entirely in Python, and use an update cursor instead of the codeblock. There is a little learning curve, but trust me, the sooner the better! MB is a waste of time if you are trying to do more colex stuff like conditional expressions and looping. 2. If you really want to stay on the ModelBuilder path, instead of the codeblock, use a series of MakeFeatureLayer tools (each applying the correct SQL - example: TIME = '5 minutes; ), and then the appropriately matching CalculateField tool - example: TF = '5min'. Granted option #2 is not as efficient as a codeblock or update cursor in terms of updating the table, but in terms of "real time" (time it takes to actually get the damn thing to work), it will by far be the best option. Sorry I don't have a silver bullet for the code block syntax, but I learned long ago to not put complex code into that thing since the formatting was so difficult to get correct.
... View more
06-24-2011
10:43 AM
|
0
|
0
|
619
|
|
POST
|
Geometry Objects in v10: http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//002z0000001z000000.htm I think Kim originally was suggesting (per an understanding of what the .dll was doing), that perhaps the entire workflow could be accomplished entirely in arcpy, and the inefficiency of reading and writing the data with cursors could be eliminated. Perhaps the function of the .dll could be replicated in Spatial Analyst (assuming you have a license!).
... View more
06-24-2011
08:52 AM
|
0
|
0
|
495
|
|
POST
|
Only other idea is to create a controler script to call seperate subscripts that: 1. Run your process 2. Delete the temp results Use os.spawnv or subprocess to lauch the subprocess scripts.
... View more
06-23-2011
02:49 PM
|
0
|
0
|
2790
|
|
POST
|
I don't see anything in that code that would cause a lock - it must be happening in the criptic part. Do you ever use the MakeRasterLayer tool? If so, make sure you delete the raster layer using the Delete_managment tool. Once I had a heck of a time deleteing a FGDB that was created in a script (when the script was done, I wanted to delete the FGDB - simple, right?). Turned out that, for some random reason, this one time, the MakeFeatureLayer tool somehow put a lock on the FC that that it was basing the layer off of. Once I deleted the feature layer, I could then delete the FGDB. Look through your code and see what variables/ESRI objects refer tothe grid, and delete them. This could be things like the describe object, result objects, cursors,feature layesr, table views, list objects, etc.
... View more
06-23-2011
02:43 PM
|
0
|
0
|
2790
|
|
POST
|
get tied up in a process with PyScripter What process(es) are you performing? Could it be that you are running a cursor or something on the grid attribute tables and forgetting to delete the cursor objects (and therefore the locks are persisting)? It would help if you posted your code. Normally, the grids should delete just fine. I have many a script that loops, does all sorts of fancy stuff, and then cleans up the temp processing grids upon each iteration. There must be something specific you are doing (or not doing) that prevents deleteing the grids.
... View more
06-23-2011
12:59 PM
|
0
|
0
|
2790
|
|
POST
|
Try using the arcpy.Delete_managment() tool rather than os.remove.
... View more
06-23-2011
12:21 PM
|
0
|
0
|
2790
|
|
POST
|
"where attribute x is a valid string value (not null, not an empty space, not a placeholder value, etc.) and attribute y is not a valid string value (null, an empty space, etc.)." I think this is how I would write it (you shouldn't need all the square barackets and /s): "(X IS NOT NULL OR X not in (""," ")) AND (Y IS NULL OR Y in ("", " "))" Note this is already in string format ready to plop into the MakeFeatureLayer tool.
... View more
06-21-2011
09:00 AM
|
0
|
0
|
677
|
|
POST
|
http://sourceforge.net/projects/pywin32/files/pywin32/ I believe you want build 210 (for v2.5.1 that comes with ArcGIS v9.3.1).
... View more
06-21-2011
08:49 AM
|
0
|
0
|
1909
|
|
POST
|
Looks like cool stuff - thanks for sharing the link. Hmmm... I wonder what functionality will be sacrificed for having "fast cursors". Only time will tell...
... View more
06-20-2011
10:50 AM
|
0
|
0
|
505
|
|
POST
|
#START SHORT RANT Why is it that ESRI chooses to not port certain existing functionality from earlier version of their software to newer versions? Spatial Analyst/Grid Examples: -------------------------------------- 1. dot notation 2. docell 3. ability to run concurrent SA processes Why not, as a first priority, port all the existing functionality, concentrate on making it better/faster, and then come up with new additional tools/functionality as a second priority??? From a user's point of view, it is very frustrating having to submit an "enhancement request" for functionality that had existed for decades, but then mysteriously disappears... Yarr! #END SHORT RANT
... View more
06-20-2011
08:15 AM
|
0
|
0
|
2451
|
|
POST
|
one lost connection to the server (now is back connected, and continue with the process) You might be referring a license server here, but... One of the largest performance enhancements you can make with any ArcGIS tool is to processes the data using your local hard drive(s). That is, don't try to run these processes from data stored on a network. Also, I assume you ran the Fill tool on your input DEM (before you made your flow directions grid), correct?
... View more
06-20-2011
07:53 AM
|
1
|
0
|
5394
|
|
POST
|
Probably too many cooks in the kitchen here, but: In python, there is a difference between "=" and "==". The former is for assigning values, the latter is for comparing values. Also, there is no nead to "return" the TF variable in every if/elif statement - just return it once at the end after all teh conditional expresions have been evaluated. BTW: Save yourself some time in the long run: Ditch ModelBuilder and go Python. The sooner the better. But, in the mean time I do believe this should work, and if it doesn't, you should be closer to having the code iwork than you were before... def getTIME(TF):
time = str(%Time Frame%) #Note: I assume this line is some sort of model build integration thing - I don't really know what it's for though?
if time == "5 Minutes":
TF = "5min"
elif time == "30 minutes":
TF = "30min"
elif time == "1 hour":
TF = "1hr"
elif time == "6 Hours":
TF = "6hr"
elif time == "12 Hours":
TF = "12hr"
elif time == "1 Day":
TF = "1dy"
elif time == "3 Days":
TF = "3dy"
elif time == "5 Days":
TF = "5dy"
elif time == "1 Week":
TF = "1wk"
elif time == "2 Weeks":
TF = "2wk"
elif time == "1 Month":
TF = "1mo"
elif time == "3 Months":
TF = "3mo"
elif time == "6 Months":
TF = "6mo"
elif time == "1 Year":
TF = "1yr"
else:
TF = "SOL!"
return TF
... View more
06-17-2011
01:37 PM
|
0
|
0
|
5271
|
| 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
|