|
POST
|
By providing early binding with arcpy (giving you drop-downs, code completion, etc), it locks us into case-sensitivity I get it, thanks for the explanation. I made a little .py module of my own a while back, and so I see your point. A small price to pay for code completion perhaps... I'm probably not as bad off as most (that want to completely update their gp code to use arcpy only) since I always copied the tool syntax out of the Help syntax example. Most of my problem code is in the methods and properties. .shapefieldname #v93 (camel case? no way! - I don't even GaF! I'll do it my way - Wo hoo!) .ShapeFieldName #v10 (uh oh, now case sensitive - I must obey ESRI synax - case by case!) Toolwise though, I have a lot of coworkers that have code like: gp.union(this + ";" + that, theOther) They are not so fortunate! Rewrite city for them! BTW: I know you've heard it a million times, but it sure would be cool to have an arcpy OMD that showed the 'correct' method/property case spellings in v10 (like the v9.0 - 9.3 ones). I use my GP OMD all the time as a cheat sheet (too bad I didn't always follow the case-spellings!). No one would care if there were > 1 pages (just as long as we can print/read them on 11 x 17). I guess code completion is sort of like a cheat sheet, but it is SO NICEto have everything you need on an 'old-fashioned' printed page sometimes.
... View more
11-18-2010
08:45 AM
|
0
|
0
|
2944
|
|
POST
|
Yes, Python has always been case sensitive. BUT The GP stuff has NEVER been case sensitive (at least prior to v10). Which is why so many of us build up GP code that won't work in v10 without tons of rewrites... shapeFieldName = gp.DeScRiBe(myFC).SHAPEfieldNAME #works great in v93 I am starting to really understand why all the ArcObjects people get so mad with every new major ArcGIS release... R.D. - I feel your pain. Not sure why ESRI makes all these "sweeping" changes (as in sweeps my existing code into the garbage can)! Here's a wish for an enlightened future of syntax stability...
... View more
11-18-2010
07:14 AM
|
0
|
0
|
2944
|
|
POST
|
Not sure about the Spatial Adjustment toolbar (I think an automated method is probably required here), but I should ask: Why do you need to copy the spatial data. I am guessing there is a good reason, but why not just use CopyFeatures() or something? Also, I'll point out that v10 does support import arcgisscripting gp = arcgisscripting.create() so you could use arcpy and gp functionality together in the same script... Do you ever revisit your older stuff and say, "What the #^$% was this guy thinking? Ha! Always, but I have found that ~80% of the time when this happens, I will start rewriting the code in a "better" way only to find that yes, there was a reason I did it that way in the 1st place, and the last 2 hours I spend "correcting" the code has been totally wasted! .getpart() is the method to iterate through the 'parts' of multipart shapes (which in my opinion are an abomination! I hate multipart shapes!!!). Maybe it's there for a good reason, but I don't have enough of your code to see.
... View more
11-18-2010
06:59 AM
|
0
|
0
|
2619
|
|
POST
|
Some real basic answers for you: Strengths: Industry/government standard. Superior analytical functionality Weakness: Relatively high co$t, somewhat buggy, and a somewhat steep learning curve for advanced functionality Ease of use: Good, depends on what you are trying to do... Intuitiveness: Good, but again depends on what you are trying to do... Level of functionality: Superior to anything else on the market What is it that you need a GIS to do, and what other options are you considering?
... View more
11-17-2010
04:16 PM
|
0
|
0
|
1406
|
|
POST
|
Are you referring to ArcGIS Desktop or ArcGIS Explorer? Don't have much experience with Explorer (from what I can tell it's pretty buggy - I'd rather use Google Earth and KML if all you need to do is look at things), but as for the former, my praise/criticism would be: ArcGIS Desktop is one of the (if not the) most complex and powerful pieces of software on the market today. Because it has so many bells and whistles, it sometimes difficult for ESRI to keep everything ringing a tweeting in harmony, while at the same time providing new functionality for new major releases (example: v9.3.1 to v10.0). Thorough beta testing (and fixing past bugs/issues in a timely fashion) is a continuing issue.
... View more
11-17-2010
01:52 PM
|
0
|
0
|
1406
|
|
POST
|
Or maybe even the recently implemented "GIS in General" forum (some interesting content there): http://forums.arcgis.com/forums/115-GIS-in-General Not sure the forum needs another "general" topic, but then again...:rolleyes: Go Python! (and Editing)!
... View more
11-17-2010
12:09 PM
|
0
|
0
|
1408
|
|
POST
|
Also, in your code, why not just: Crow.setValue( 'Shape', Arow.shape) Why do the getpart() step? Also, are you sure that your Shape field is actually called shape? #v10 code? (not sure if it'll work) shapeFieldName = arcpy.describe(myFC).shapefieldname Crow.setValue(shapeFieldName, Arow.shape)
... View more
11-17-2010
11:44 AM
|
0
|
0
|
2619
|
|
POST
|
I can't help you with v10, but if it ain't working there (in v10) it sounds like a bug. You should report it to esri. On a side: Pretty quickly I figuered out that due to a variety of bugs, v10 was not stable/compatible for much of my existing v9.3 and v9.2 Python code (this issue being yet another great example), so I guess that's why I haven't moved over there yet. I'll have to eventually though, and it won't be pretty... Excerpt of a v9.3 script that, among other things, gets a shapefield value (searchcursor) and inserts it into a new sorted table (insertcursor) - Works great in v9.3 #Process: Now write the sorted records to the new FC
message = "Sorting fields..."; showPyMessage()
searchRows = gp.searchcursor(inputLayer, "", "", "", fieldSortString[:-1])
searchRow = searchRows.next()
message = "Writing sorted records! Please wait..."; showPyMessage()
insertRows = gp.insertcursor(outputLayer)
recordCount = 0
inputLayerOidFieldName = dsc.oidfieldname
origOidPopulateSuccessFlag = True
while searchRow:
#Process: Every 1000 rows give a message about the progress of the cursors
recordCount = recordCount + 1
if divmod(recordCount,1000)[1] == 0:
message = "Writing row = " + str(i) + "..."; showPyMessage()
#Now read the old table and populate the new one
insertRow = insertRows.newrow()
for fieldName in inputLayerFieldList:
try: #you can't write the OID, length, area, etc. fields
if outShpDbfFlag == False:
insertRow.setvalue(fieldName, searchRow.getvalue(fieldName))
if originalOidFieldName not in ["","#"," "]:
try:
insertRow.setvalue(originalOidFieldName, searchRow.getvalue(inputLayerOidFieldName))
except:
origOidPopulateSuccessFlag = False
pass
else:
insertRow.setvalue(fieldName[0:10], searchRow.getvalue(fieldName))
if originalOidFieldName not in ["","#"," "]:
try:
insertRow.setvalue(originalOidFieldName[0:10], searchRow.getvalue(inputLayerOidFieldName))
except:
origOidPopulateSuccessFlag = False
pass
except:
pass
insertRows.insertrow(insertRow)
searchRow = searchRows.next()
... View more
11-17-2010
11:31 AM
|
0
|
0
|
2619
|
|
POST
|
I can't speak to 10 (too many bugs yet to move over), but I can verify that this sort of thing did work in v9.3. Here's some v93 code.
... View more
11-17-2010
11:20 AM
|
0
|
0
|
2619
|
|
POST
|
http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=An_overview_of_creating_script_tools
... View more
11-16-2010
11:33 AM
|
0
|
0
|
649
|
|
POST
|
In v9.3: gp.extent = "0 0 1000 5000" #or gp.extent = r"C:\temp\test.shp" #optional gp.mask = r"C:\temp\test.shp" gp.cellsize = "100" # optional gp.snapraster = someOtherGrid somaExp = "1" outputGrd= r"C:\temp\test" gp.SingleOutputMapAlgebra_sa (somaExp, outputGrd, "")
... View more
11-16-2010
08:22 AM
|
0
|
0
|
738
|
|
POST
|
In theory: the former... In effect, the latter... :rolleyes:
... View more
11-15-2010
02:13 PM
|
0
|
0
|
2374
|
|
POST
|
Verified: Changing the random seed integer using gp.randomgenerator() does indeed solve the issue. I will however begrudgingly point out that the v9.3.1 help for the CreateRandomPoints tool (both the "built in" help and the "up-to-date" online help topic http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?id=1783&pid=1777&topicname=Create_Random_Points_(Data_Management), make absolutely no mention of the gp.randomgenerator() environment setting affecting the tool! As of today (11/15/2010) the online v9.3.1 help topic states: The following environment settings affect this tool: Workspace and scratch workspace. No wonder both myself and the ESRI tech I reported the issue to missed it! I should point out that the v10.0 help now correctly includes "Random number generator" as an environment setting that affects the CreateRandomPoint tool.
... View more
11-15-2010
09:05 AM
|
0
|
0
|
2374
|
|
POST
|
Also, I bet you can drop the "\" stuff in the SQL. I think this confusing \ notation is a holdover formatting thing for shapefiles/dbf tables from v9.0 - 9.2, but not necessary in v9.3+ #so instead of this: arcpy.Select_analysis(locationstands, outfeatureclass, "\"identify\" = '%s'" % feature_label #try this: arcpy.Select_analysis(locationstands, outfeatureclass, "identify = '%s'" % feature_label)
... View more
11-10-2010
01:29 PM
|
0
|
0
|
1542
|
|
POST
|
Drew - thanks for the clarification. From the v10 help: If a tool using the random values (for example, Create Random Raster, Create Random Points, or Calculate Value) is run twice with the same seed, the output will be identical. Control over the seed allows you to reproduce your results. The python code of my process is rooteed firmly in v9.3, but glad to hear there is a solution in v10 - Awesome!
... View more
11-10-2010
12:02 PM
|
0
|
0
|
2374
|
| 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
|