ebook img

Python Scripting for ArcGIS PDF

118 Pages·2011·2.05 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Python Scripting for ArcGIS

Python Scripting for ArcGIS Paul Zandbergen Deppartment of Geoggrapphyy University of New Mexico OOuuttlliinnee ooff TTooppiiccss • Introdduction – Examples, Python and ArcGIS, Python versions • FFuunnddaammeennttaallss ooff ggeeoopprroocceessssiinngg iinn AArrccGGIISS • Python language fundamentals – Where to run Python code – Data types: numbers, strings, lists – Functions and modules – Controllingg workflow • ArcPy: Geoprocessing using Python – Using tools, functions, classes – Describbing ddata, llisting ddata, workking withh llists • Creating custom tools – Scrippt tools,, tool pparameters • Resources WWoorrkksshhoopp MMaatteerriiaallss PPoosstteedd ppoosstteedd uunnttiill OOccttoobbeerr 2244 hhttp:////www.paullzanddbbergen.com//workkshhops FFoorrtthhccoommiinngg BBooookk • Python Scripting for ArcGIS • EEssrrii PPrreessss • Sometime in 2012 • Updated for ArcGIS 10.1 • Sample exercises posted (for 10.0) Introduction PPrriioorr KKnnoowwlleeddggee aanndd EExxppeerriieennccee • Using ArcGIS 9.3 or 10.0? – Workshopp is for 10.0 • Prior Python experience? – I’m not assumingg anyy • OOthher programmiing experiience?? – I’m not assuming any EExxaammppllee 11 • Script to copy all shapefiles in a folder into a geodatabase import arcpy from arcpy import env env.overwriteOutput = True env.workkspace = ""c://workkshhop//ex0011"" fclist = arcpy.ListFeatureClasses() for fc in fclist: fcdesc = arcppyy.Describe((fc)) arcpy.CopyFeatures_management(fc, "c:/workshop/ex01/study.mdb/" + fcdesc.basename) EExxaammppllee 22 • Script tool to generate a k‐nearest neighbor table • Runs an existing ArcGIS tool multiple times, writes the result import arcpy from arcpy import env env.overwriitteouttputt = TTrue infc = arcpy.GetParameterAsText(0) output = arcpy.GetParameterAsText(1) kk == aarrccppyy.GGeettPPaarraammeetteerr((22)) n = 1 f = open(output, "w") wwhhiillee nn <<= kk:: result = arcpy.CalculateDistanceBand_stats(infc, n) f.write(str(n) + " " + str(result[1])+ "\n") nn = nn ++ 11 f.close() EExxaammppllee 33 • Script tool to run Huff model • Sophisticated analysis not available in ArcGIS EExxaammppllee 33

Description:
Python is the preferred scripting language for ArcGIS Don't install your own version of Python machine – however, a clean install of Python2.6.5.
See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.