arcgis10中文幫助-專業(yè)庫-地理處理8使用Python進行地理處理_第1頁
arcgis10中文幫助-專業(yè)庫-地理處理8使用Python進行地理處理_第2頁
arcgis10中文幫助-專業(yè)庫-地理處理8使用Python進行地理處理_第3頁
arcgis10中文幫助-專業(yè)庫-地理處理8使用Python進行地理處理_第4頁
arcgis10中文幫助-專業(yè)庫-地理處理8使用Python進行地理處理_第5頁
已閱讀5頁,還剩48頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

1、什么是Python?Page 3 of 59什么是Python?Python胖不受剛K.跨平臺的開激斜樫誦古它功繼大且簡因ifiiM到了廣泛兇用和支材整了篇仃關(guān)Python的評細們©請加ythocorg.ArcGIS 9.0補入Python此心Python供地理處理用門選擇的屏本語古捋得U不斷21展每個戰(zhàn)本鄰進一步堆事Python仇£從爾北您捉供更姜的功能以及更f沐 更友好的Python休檢.ESRI已將Python克全第入ArcGIS中井椅其比為可#1足JM1用戶肚區(qū)冊求的訴古.下面儀介IB Python的部分優(yōu)身*學(xué)習(xí)尊常適含初學(xué)右也特別適介匸家使川可伸編稈陵島適于大乜

2、頊H或小書的一次性秤序(淳為W4O阿林M»Tf?訓(xùn)政入(便ArcGIS吋I即本化)憶定成熟用戶HKWW人Python Lili伸到ArcGIS中成為f ttMJ進Ij filK分析數(shù)能轉(zhuǎn)氐 數(shù)劌管理和地詔1*1動化的諂魚 Wlftj/fWJ提&匸作效率.了解 Python以卜包會的仃息并不址Python的諂古參考.KANIIK用于說明如何編丐地理處用M的示例和念來介Wi集此Python諂汰和行為.事広繼汶您纟汀汕IZ的PythonIGC進步了解此飪介紹的怙也.対Python 理議便用以«乍習(xí)Python: (Learning Python)(fl 右:Mark Lu

3、tz 和 David Ascher. H;版樸.:O* Reilly & Associates '和 4Python 心(Core Python Programming) (fl ?I: Wesley JChun,出曬 Prentice Hall)這兩本書般::;h丨卜容I.不重4L還有很多其他竹佻也介紹了 Python及其具體用堆M葫書會定期岀版.Wit以探允町用的內(nèi)容Python I - ' Eig供了 Python的左整文檔俁內(nèi)春很制朗LSttlftl向開發(fā)人員的.還竹 個人型的Python 金線社區(qū)具中包含恨多住線資探.念可通過Python b頁訪創(chuàng)這隨資漱Py

4、thon敦程如果您R Python :«初學(xué)冇.我們HI方您許習(xí)此處列出的一此外冊軟畀 Pythzm 3 E Python文檔本身的 那分. “Y F UWJ Python為編程經(jīng)驗令限的人七捉供教用 Pythm"匕介W Python的i麗犬和ifi義.針對程序員的Python教程此處所列的外部敦RL契曲向以前學(xué)習(xí)過找他嬪程ift古<PerL Visual Basic. C)的人員. python >>g Python文件本專的 部分 :l J . : / PythonH<jK他編FJ諂詬經(jīng)蟄的人 I WWMIV.相關(guān)主題'么工 ArcPy

5、!么足 Python W:;?'彳 Pythor w.股良原h(huán) « 1995-2010 CmM惘網(wǎng)點叔比基本Python詞匯本文IK介mm 便用python laffiftfl-帝助苗豪拿擁的此訶ii術(shù)語UMPythonPython M Guido van Rossum (f匕“紀八十年代1991年和II的 神開源誠軒ifi/f.它Jtt®集戍ArcGIS 9.0 中.從此以弟便或為用戶創(chuàng)建地匸作渝的佇選.Python了不斷壯大的多元化用戶If體的支持具備簡衲馬i*iff濃清斷 支持動布定持點并且貝有大駅標時和須三力片PythonWinPythonWin址 削泛便用

6、的$1對Python的勿二力W.ndov/s «U 對認通過ArcGIS &真介質(zhì)進h &:»ArcPyArcGIS 10采用了 ArcPy (通當祚為ArcPy M點包).為用戶網(wǎng)了便用Python誦市卿"Yi地理處丹I R (括擴IWI塊)的 機會并從供了多伸有用的MM.以用F處科和詢同GBMI站點包足Python術(shù)語.八了Python! 咋.使用Python和ArcPy可以開發(fā)出數(shù)債無|«的叩用于處舛地理數(shù)期的實用用序.ArcPy怏塊復(fù)塊為通常包六聞數(shù)和熨的Python文f|n 駅劉快塊支目Ar"v何M塊(azcpy nu

7、ippinq). Spatial Analyst WUj(arcpy sa) ftlGOStatiStical Analyst 1(arcpy ga)ArcPy 央類的-.'J-tfM設(shè)計益陽為如何創(chuàng)址"鈞促供権架.為類則可用來創(chuàng)建対象即遹玄所稱的實例.ArcPy矣illSpabalReference fl: Extent 通常用作地理處州1”快心;雞的詁這氣多8(會便出丈ArcPy朋數(shù)貳故址用于執(zhí)行菜用待定任務(wù)并健鑄納入更大的FJ序的C定義功能.4 ArrPy申斷的地馳憶雎1只旳吐誡敢悵1 '闌數(shù)是細8!址W!【R» I HZ*ArrPy 堆支If Pyt

8、hon MwaM »IMtMMlMM.存將&冷加稱.AlKfjK他許t冇用的何本任務(wù).立的 Python W +Python腳*是可以IM?的py文件.獨立Python W本址#py文件對通過卜:tftfifflll序(如PythonWin)或在Windows費itt$?煌8中戲由.py文付Python W* Python聞本H足已添111到地丹處理EHffi的Python 本.添加為腳本11石便對以像他用K他I H 樣便用此詢本EI HH 以從mJ以A PythonModelBuilder PttJIh Jn| 以從氏他IW本和W4 UVP調(diào)川.Python Ml I Ar

9、cGIS 10 f ft#的嗽入N Python -<C嵌川.Python Wil港過閔9口用八叫以快堆地在ArcGIS內(nèi)部使用Python.從而以交互方式運行地WftffII和功健以及充分利用其他Python «塊 和那.此甜口還為用戶學(xué)習(xí)Python ft供了個途檢.Python ®l inf用于執(zhí)行”行Python RW井令梅由此件戍的泓U輸;II到HI借助比由II悠町以対ifi法進行試如處WJfHW. 并可以苻大申膵木范外對您的想法進行檢檢相關(guān)主題Python 怏止d 二 什么足Python? 1995-2010 Esn.Python快速瀏覽python 鐘爲

10、用的.J ArcGIS地理處理中川作BUM ; , ttlJIJ Python中用/ ArcGIS找fl的ArcPy第點包對詭樹地理功能週過 ArcPy町訪何地理處用I.典和比他由乂 類和樓塊.俛用它門可快速輕松地創(chuàng)建簡單或奴余L作汰ft用以ArcPy怕寫的ArcGIS應(yīng)用程序和解本的優(yōu)勢在于可以訪H/ift用由種不M佈域的GIS專也人員和稈序員開發(fā)的大H Python K塊.使用 Python 的ArcPy的另個i足.Python ft 種通用的#i秤誦古.于習(xí)和便用.通和功態(tài)輸入運種塢用誦古用門可以在交可兀環(huán)境中快連地創(chuàng)址禺本原乜并進行測試何時這種徧種語古功能愛大.可嬪芍大書用用料序.敵來

11、說.ArcPy WIJL環(huán)如 確SL類和H塊退仃組織Running a toolThis next examph shoves how to execute the Buffer tool. As the tool executes, th# messages will appear by default on the right side of the Python window in the help section arcpy. Bufferanalysxstc:/data/Portland, gdb streets*, *c:/data/Portland. gdb steetsbuff

12、er*. *500 METERS*)Here is another example of running tools This example uses tools in the data management and conversion toolboxes A field is added to the input streets feature class, the field is calculated, and the feature class is then loaded into an ArcSDE enterpnse geodatabase;import arcpy! arc

13、py. AddFxeldmanageaent(*c:/data Portland gdb/streets*, "LENGTHJ4ILES: *TEXT*arcpy. CalculateField_aanage=ent(*c: . data. Portland.gdb/streets*t "LENGTH.HILES". *!shape, lengthteiles!*, "PYTH0N_9.: arcpy FeatureClavsToF©atareClss_conv 匕 s】on("c:,data,Portland gdb streets

14、*, * Database Connections MySDE. sde Port Itzrc Eore about us:g tools in PythonGetting results from a toolWhen a geoprocessing tool is executed, the results of the tool are returned in a re«ul object Typically, this object is the path to the uulpul dtfpruduuvd ur updtftvd by th lwl In ulhvi jow

15、, it rny uufitin uthwr v«lu« lyp«/ uuh & nunibvi ur Bwlvri If output for a tool is a multivalue parameter, the values can be returned as a list within a list.The following code examples show how return values are captured and what their values could be:Return the path of the outpu

16、t feature class The result can be used as input to another funebon result = urcpy. Buffer_analysi«(*nvers*t *nverBuf*t *50 METERS*) print resultC:PortlandPortland_OR. gdbriverBufarcpy. Clip_analytif(*ftreeta*. result, «trteti_50m_of-riv*rs*)Return the number of features.result = arcpy. Get

17、Count_ianagement(*streets_50n_of_rivers"? print result. getOutput(0)51Return a list of default spatial grid indexes for a feature class.>>> result = arcpy. CalculaxeDefaultGrxdlndexaanagesent (streetsSOaofnvers*) »> for 1 m range (0. result. outputCount): print result. getOutpu

18、t(i)5602000Using environment settingsGeoprocessing environment settings can be thought of as additional parameters that affect a tool's results They differ from normal tool parameters in that they are set separately from the tool and are interrogated and used by tools when they are run. Environm

19、ent settings such as an of interest, the coordinatQ system th© output datzset, and the cwll size of a nev/ raster dataset can all be specified and honored by the toolsEnvironmnt settings are available from the class as properties These properties can be used to retrieve the current environment

20、values and set them. Below are examples of how to use nvironment values:Set the workspace environment»> arepy tnv. workspace = *c:/data/Port land, gdb*-»> arcpy.*500 METERS*)Set the spatial grid index to the return value of a tool.>arepy. *nv. spatialGridl = <rcpy. CalculateDef

21、<ultSpatialGridInd«x_s<nagen:ent (streets*). getOutput <0)Get the current raster cell size setting and make sure it is a specific size for standard output.if arcpy. env. cellSize != 30: arcpy. env. cellSize = 30Lwarc mor© dbout useq 電cvi廠onrnwnt s電tticqs in PythonUsing functionsA

22、function is a defined bit of functionality that does a specific task and can be incorporated into a larger program In addibon to tools, ArcPy expeses a number of functions to better support geoprocessing workflows Functions can be used to list certain datasets, retrieve a dataset's properties, c

23、heck for existence of data, validate a table name before adding it to a geodatabase, or perform many other useful scripting tasksThe example code below shows getting the properties of data and checking out an extension:import arcpy呂 prints Trueprint arcpy. Exists(*c: data Portland, gdb streets*)2 pr

24、ints19S3_ Stat ePl an e_0regon_Nor thFIPS3601_Fe e tsr = arcpy. D色scribeCc:data Portland, gdb/streets*). spatialReference print sr. namec prints Avilablprint arcpy. CheckExtension(* spatlai*)arcpy. CheckOutExtension(*spatial*)arc more about us riq Gucutioas in nythoaUsing classesArcPy classes, such

25、as the SpmteRefeyrw "d Exter.t classes, are often used as shortcuts to complete geoprocessing tool parameters that would otherwise have a more complicated string equivalent A class is analogous to an architectural blueprint The blueprint provides the framework for how to create something Classe

26、s be used to create objects; this is often referred to as an instanceimport ixcpyprjFilt = *c:/projections North America Equidistant Conic, prj* spatialR«f = arcpy. SpatxalR«f«rtnct<prjFilt)Learn more about usmq classes in Pythonfile:/E:tenipS-1 -5-21-1417001333-299502267-682003330

27、-500temp-hhF46D.htm2011-3-19什么是Python?Page 5 of 59Working with modulesArcPy includes modules covering other areas of ArcGIS ArcPy is supported by a series of modules including a mapping Eodule(axcpy.mapping), a Spatial Analyst module (.zcpy. and a Geostatistiual Analyst rnodulw (mrcpy.g0)For example

28、/ the tools of the arcpy. sa module use tools in th# Spatial Analyst toolbox but are configured to support Map Algebra Thus, executing arcpy. sa. Slope is thArcGIS 10采用/ ArcPy這是一種Python站點包它涵蓋并進-步加鍛了 ArcGIS 9.2中所采用的arcgisscripting模塊的功徒.ArcPy提供f-ftHJ F 幵發(fā)Python 的功徒的動念斤境.同時捉供毎個殆如模塊和類的代砂左成和集成文檔.ft用以ArcP

29、y "寫的ArcGIS hV用袴序和畀本的優(yōu)務(wù)在沢 可以訪何片便用由來M種不帆恤域的GIS專牝人員和程序員開發(fā)的大St Python N塊.使用 Python 的ArcPy的另個1 ClftWtt. Python足 種通用的集程誦吉習(xí)和便用通HWff和動?xùn)|輸入這種編程誦言用戶可以在交互式環(huán)境中快速 堆創(chuàng)it禺木脈乜并透廿測試同時這種編押誦擊功施獨大.可嬪芍人書用用種斥.卻 Iaporting arcpy#import arcpy4 Set the workspace environment and run Clip_analysisarcpy. env. workspace = &q

30、uot;C: /Data/Tongass*arcpy. Clip_analysis (*standb l*t ' clipcov*, *standby_clip-, *1. 25*)打?qū)階rcPy ZVi.可以ittrW ArcGIS安裝的杯準I的所4_' R.轉(zhuǎn)譏1厘粽玄比丨塑塢知1II箱地理編碼1只箱找件譽冷丨陋E細【II箱空叭計仿所I吐導(dǎo)入模塊犠塊為通常包含函弟,Python Zft<j *列楔塊2持ArcPy包*18樓塊(“cpv.naSnJ Spatial Analyst鑽塊(“cpv . “)和Geostabstiel Analyst Q (arcpy. g

31、a).t?導(dǎo)入荒T恨峽.誠性川導(dǎo)入復(fù)峽8* Iaport all of arcpyimport arcpy. xappmg*iM. Python還貝時很多其他值心l«塊和第 方慣塊如果還SttAl Python的恢心o.和”戟塊.町以便用郴0的導(dǎo)入方式i Iaport arcpy, os and sysarcpy03«ys在很步悄.下用戶同便用筆個H 石便如果只ffi塊的 部分.吋以使用 Mi-HvomM右卜制中.rw矣<env所仆地理處理殲境).現(xiàn)A無需以arcpy.env W彤式訪何耳境而町以WHW(t為”* Iaport env from arcpy and s

32、et the workspace environment 二froa arcpy import envenv. workspace = *c:/datai9 % III H W&K. 伽川戶可ttXS注血 如何對蟆塊或役塊的部分進竹杯識以使畀加更八叭女性以及對于廿選J負來說氏認名壽町能過長在上述任怖 況八 均可從便川from-i«porft->s的形式.GL詢的小例啊町 卜面的示例中也將導(dǎo)入env類.f!會折足ENV作為env類的 same as executing the Slope tool from the Spatial Analyst toolbox.相關(guān)主題

33、f I 么是 Python 1"木 Python i. 199S-2010 Esn.MWft KH.import import import導(dǎo)入ArcPy* Isport env from arcpy as EXV and set the workspace environment froa arcpy import env as ENVENV. workspace = Python tt初只UMRJM在ArcGIS 題I貝«KiD “效IK譯理I具-I.ftffi. 犧換II:具Iff和-分析1 JI” 1:具箱)中的IJl通過將I足義1粉導(dǎo)Aft ArcPy iA ?,

34、(!.在Python Wl1«p. i>f以像5樹任何別t I JI樣苗何由個人.9 .力或組織創(chuàng)址的.保存左fl定義I .具幅中的I定義1 H.卜例中.便用J' ImportToolbox rtft,以便便用Python的何fl定義I:具箱中包含的I HIM箱匚即銓以azcFy.< I H K»> <別名形式訪剛自定義工具.>arcpy Iiq)ortToolbox (*c: / mj*tool«/geoe:etrytools. tbx*)> arepy. CreateRegul<rPolygons_geoaet

35、ry (通討ArcPyZj果個I.H時.ttXA所金的I II- ,是必境后 < arcpy.< I貝名祚 >名由f-ArcPy ««« I. MM名*何和執(zhí)行正確 的ii岡此.十導(dǎo)入n定義丨H«i時別笛買兒匝耍一種很好的做決足.始終定義門定義不過.如果未定義I Hffi別名.町設(shè)咒一個締時別名. ttKft為ImportToolbox朋故的第二個琴數(shù).>>arcpy. IisportToolbox (*c:/ mytools/geosetrytools. tbx*. aytools *) >arcpy. Create

36、RegularPolygonsmytools (添加和刪除服務(wù)器工H箱也可使川二吋?!倍?。丄box將地訊處理KMAD9JWM境中.無論 Internet HUJjIlJfeff處理服務(wù).嵌務(wù)攀名啄籾1分隅.J、Y h K地理紅刃馭務(wù)的評宗久足.添加地ffttffHS務(wù)的示例ift法c:/data*可以使川WHAA導(dǎo)入.tijfflft塊,* Import tht sapping module froo arcpy as MAP and create a MapDocumen:* object:Sfroa arcpy import zapping as MAPsxd = MAP. MapDocu

37、cent (*C: saps basexap mxd*>其他版本的導(dǎo)入撫作使川froa-xmpor-as-的形式.柚塊的內(nèi)弁將被血接導(dǎo)入到命名空何中.這衣小川門隨心對以血接便用所仃這些內(nèi)臥 向無需為它們 MUhs Isiport tnv from arcpy as and s«t the workspace nvironatnt! 8froa arcpy isport tnv as vorkspace = *c:/data*但足.便川It方法存在些只矗具側(cè)11同名稱的其他對瓠 製AL模塊WttKA另外在便川人型機塊時命名空施冋會竇得異常IB擠和舍乩町以此 住卜例中.管理楓塊和分

38、析怏塊祁村帙"入為這腳個役塊«JUj -ttiW I JI如果現(xiàn)生蘭試便HJ -ttM- Ub那么實際便用的會足 哪種“拔LH?答案址人話但是此fiiM能導(dǎo)致任閱/腳本時出現(xiàn)小備定或4以閱設(shè)的的況.8 Ioport tht sanag«m«nt and analysis codults froa arcpy as i ofroa arcpy import suinag«ni«nt ,拿froa arcpy isport analysis as j » Which Clip is it?j 8! Clip("集些&#

39、171;l況卜.£zoa-x»por-吋以尬化代碼.例如.ttWfl ArcGIS空間分析擴JMI塊的塊的情況卜'“後塊的優(yōu)勢Z叫以A仃中散企£個類和甫數(shù)以1成綸也刨格対彖卩 許町:以卜阿個實例那爲菱J擴膩怏塊*込仃file:/E:tenipS-1 -5-21-1417001333-299502267-682003330-500temp-hhF46D.htm2011-3-19什么是Python?Page 7 of 59* Isport arcpy and the sa a&oduleimport arcpyfroa arcpy inrport sa

40、arcpy.CheckOutExtension(*spatial*)s Get input parametersQinRast er 1 = arcpy. GetPaxaaeterAsText (0) mRaster2 = arcpy. GetPaxameterAsText (1) mRaster3 = arcpy. GetPaxaaeterAsText (2)outRaster = (sa. Raster (inRaster 1) + (sa. Raster (inR>ster2) (sa. Raster (mRaster3)路徑和導(dǎo)入便用導(dǎo)入iM旬時.Python椅在以下位瓷中并按以

41、卜W)査找匹配諛名稱的候塊,1. 在PYTHONPATH系役環(huán)境農(nóng)礒中折定的路衿2. 饑標冷 Python 文ft 夬(*101 文C1 咲、c: python«xlib« c : python2xLib«xt«-packago Tf)3任1和2屮找劉的任爲.pth文ft中僑指定的酹用釘關(guān)這方”|的詳細怙息.詢琴閱以卜內(nèi)”:httD:/docsD'/thonorq/icstzll/index.htrrl獰modifyinqpythor>ssearchpath切SJ詢木安淡Python 26.期此用字便用ArcGIS 100產(chǎn)&的安衆(zhòng)

42、冷序來安裝該安裝稈睜還會將文ft X從匸op=0.p=h或Server 10 .ph) 111 $4 pyhon26Lxb sxce-packagea lP -此文件中包含的兩行內(nèi)容為系統(tǒng)的ArcGIS安裝Fd序的arcpy和bin文件夾的踣能在 Python 26版中耍成功導(dǎo)入ArcPy石耍這兩個路衿.便用牙入沼句時.PythonPYTHONPATH環(huán)址變3米"找袒塊文件此哽“將設(shè)丹為 甌列II錄.?類示:如果牙入ArxPy的探件牙致以下仃種!i克將無汰找到所得權(quán)06導(dǎo)入UBJG未找到名林為"cpy的帳塊導(dǎo)入信論 未找到名林為arcgisscnptmg的樓塊要解決此何世.

43、劇史川Windows ffS管現(xiàn)曇 覽至pyrhonZ6Lib9ie-package9文件央.然厲添加 城縞新DeskoplO.ph丈件.此文件曲包含以卜兩存內(nèi)弁(ftlSJ1/實兀不花請將H9JA為您的系飲滋 ft):c: Program Files ArcGISDesktoplO. 0arcpyc: Program Files ArcGISDesktoplO. 0bin相關(guān)主題'么 t ArxPv!磁K刖" 1995-2010 Esh.使用Python添加Tl箱* Iaport a geoprocessing serviceimport arcpy* To add a t

44、oolbox froe a Internet server, provide the url and toolbox name* delisited by a seai-colonarcpy. Iiqx>rtToolbox(*http:/. Iabl3 axcgis services;Buf ferByVaiv)二 Iaport a local geoprocessing serviceimport arcpy-To add a toolbox froe a local server, provide the server and toolbox name2 delimited by a

45、 seai-colonarcpy.InportToolbox(*labl3;BufferByVal*)相關(guān)主題 ImportToolbox版出M « 1995-2010 Ew. IVIHiPiftKH.通過Python使用工具毎個JAI!處理LHWJWf flibMiil的歲救這此令救為Ul覺仇執(zhí)盯所需附Iti義一個應(yīng)事個nWUi的輸入$數(shù)區(qū)叫CUK集 敝用生成新的 出數(shù)期»KAW幾個M個TUI參故冇個唯名稱併裔救州的類型如宴娥類.?nn«或梅格力向誅參故定文圧輸入值還足輸出位必i&農(nóng)不必須為多救處仇血還足$«(為吋選.在U本中tt/IJ l.H

46、M必須正確設(shè)豪工具的歩數(shù)(ft以便住運fj腳木時IJWJ以執(zhí)竹.蒔個1貝的文檔部明確定文了其參數(shù)和屬性提供一AW4的參數(shù)值腐,I. 具準備好1MJ.夕敵將被拒定為字符床或時猱.字符串址啡一杯識參敵他的簡單文木.如散卅蠻的路輪或關(guān)詵7人事數(shù)數(shù)部町以簡他7符m的形穴折定對火此ytk (如空刖F考.可便用対氟.面不址7勧加.在下何的代眄不例中為級沖 I只宦義了輸入和怡 請注童只名祥修附其I貝iff的別名.在諫示例中.兩個字捋串饗用于定義輸入和turnatt以便對1只的調(diào)用更f?WF.import arcpyroads = *c:/StJohns/data, gdb roads*output = ci

47、/StJohns data. gdb/roads_Buffer*4 Run Buffer using the variables set above and pass the recaming parameters4 m as stringsarcpy. Bufferanalysistroads, output, distance*, *FILL*, "ROUND", *NONE*) fl Flfn的代碼示例VCreatHztweClass I II便用tt町選半標尿-琴故的宇何少占對*執(zhí)行.咿何夕考對*ft? SpatvIRghr""類創(chuàng)址.ttC U

48、從松 屯文件中加找.file:/E:tempSl W1417001333-299502267-682003330-500temphhF46D.htm2011-3-19什么是Python?Page 9 of 59import arcpyinputWorkspace = *c:/tempv outputNase = *rivera. shp*4 Create a spatial reference objectspatialRef = arcpy. SpatialReferenceO4 Use a projection file to define the apatial reference* s

49、 properties9spatialRef. createFromFile(*c: program files. arcgis/DesktoplO. O/Coordinate Systems ' Projected Coordinate Sys t eas/Cont ment al/Nox t h America North America Equidistant Conic, prj*)» Run CreateFeatureclass using the spatial reference objectUarcpy. CrMt*F«atur«ela*s

50、_manageEent (mputWorkspact, outputXame,POLYLINE*, : : spatialRtf)工具組織處SEA以兩種不同n.織.ffih Uli<j以ArcPy <!的槍數(shù)的彤大擬供.fl!也可以MHEIE的鐵塊川川盡它flflft中的人多數(shù)示蹄tAVLtfi» ArcPy ft仇的詼散但藥種方法IM樣仔效.便用 種方法取決個人算好和WiffPJ慣任卜何的不例中便用兩ttZrtt顯不GtCountIJLimport trcpyxnFeatures = *c:/temp rivers, shp*n Tools can be accesse

51、d as functions on the arcpy =odule, and 二 from aodules matching the toolbox name.Marcpy. GetCount_manageaent (inFeatures)arcpy. nunagex-ent. GetCount (inFeatures)通ii橫塊使用I II時.您"時可標刃欖塊的方式.以便8本貝盯更好的可讀性.杞這種怖況卜可以使川from - import - 的形九* Clean up street centerlines that were digitized without having s

52、et二 proper snapping environmentsj Mimport arcpyfroa arcpy import edit as EDITfroa arcpy iizport management as DMstreets = "c:丿 datazstreets. gdb Mjorrds*streetsCopy = *c:. output/Output. gdb streetBackup*DM. CopyFeaturea(streets, streetsBackup)EDIT. TriaLme(streets, *10 Feet "KEEP_SHORT&qu

53、ot;)EDIT. ExtendLme(streets, *15 Feet EXTENSION*)為適應(yīng)地圖代故”-( -Mfi- I ll的處理力成“所伺譏這些lJUlfitilil “cpy.“磺塊in川 不以ArcPy甬數(shù)的彤式捉01 從工具獲取結(jié)果"ltr為第果ArcPy 返河I II的楡II血結(jié)來對彖的優(yōu)點兄吋以?AIM*網(wǎng)怎械祠嗥廠i 2樹V訶恥逆請*頤畀舉泳 藝吆範仞殺A粽曲知?卜面的爪例說明r如何合塊處理1.J”;扶収結(jié)果対猱的輸出.import arcpyarcpy. env.space = *D:/St_Johns. data, gdb"* Geopro

54、cessing tools return a result object of the derived* output datasetresult - arcpy. CopyFeatxires_manageaent (*roads*, "urbanroads*)2 A print stateaent will display the string s representation of the output.9print results To get the output value, the result object has a getOutput methodresultVtl

55、ue = result. getOutput(0)匚注韋:信51!對誓的"togput方濃幻6冋 個Unicode 7符小來農(nóng)不仟“輸?shù)拿缇蹖μ绞\frifitoGetCount覺供祀卩的記A CalculaUDefaultClusttrTohrance (緞供插撲療片(TO Z類的 Ml Bl.點考股広點耍稱(ft轉(zhuǎn)換為所需類乜需険便用內(nèi)齊Python廉敢(如ino A floaO)從 Unicodeimport trcpyfroa arcpy import envimport typesenv. vorkspace = "c:/StJohns data.gdb*s Ma

56、ny geoprocessing tools return a result object of the derived = output dataset A print statement will display the string * representation of the output.result = arcpy. GetCountmanageaent(*roads*) resultValue = result. getOutput(0)c The result object's getOutput rethod returns values as a c unicod

57、e string To convert to a different Python type, use c built-in Python functions: «tr(), int ()t longO, float 0 口 count = int(resultValue) print count printTyp<Tj*pt(count)結(jié)JMI性隸方法u性和方法ift明ouputCount返何純出救II eaaageCounc返阿ifl息數(shù)II.aax3e*«xiy返MftX產(chǎn)整性.理創(chuàng)的嚴鏡性町以為0 (來產(chǎn)生的叨吿 1 (產(chǎn)生了*當) A 2 (產(chǎn)生 了 WH

58、JO .xesulID返何唯絡(luò)JR ID.UAil:fl #的狀U 0- «t£ 1 捉交 2-iE在等待 3iE在執(zhí)行 4成功 5 火敢 6 超時 7iE在取泊 8 取河 9 iE/UM 除 10IH除cancel 0務(wù)器1:的什非題何給宦的輪尼甜是記錄集或格數(shù)掘?qū)澫驢4返河RecordSet或RasterData tjlfc.gezXapIxageURL (ParaecerLisr* Height> Xid?hf Reaolution)茯取詒定綸出的地圖訊竹彫«!s2age (index)返阿待定泊息ge»52ages (se-eziy>萎返河的0 ifl息1 警告.2 - tflW.如宋木忻定(ft姻返糾所右 Jfl您類申Quorum(ind

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論