




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、通過坐標(biāo)數(shù)值生成點(diǎn)線面的shp圖層Arcgis10.0之后版本雖然交9.3增加了很多功能,但是卻不知何故少了一些常用的功能。本問主要就比較常用通過坐標(biāo)數(shù)值生成點(diǎn)線面的shp圖層做簡單介紹。一、前期準(zhǔn)備1.將附件CreateFeaturesFromTextFile文件復(fù)制到任何一個(gè)固定的位置。2.打開Arcgis,新建toolbox3.按圖新建腳本工具 C:Program FilesArcGISDesktop10.1ArcToolboxStylesheetsgeoprocessing_help.xsl4.點(diǎn)擊下一步,Script File選擇剛才那個(gè)腳本文件“CreateFeaturesFrom
2、TextFile”5.設(shè)置參數(shù)其中,“坐標(biāo)值規(guī)定“中的Default的值為12345678.12345“輸出shp文件”中的Direction改為output“坐標(biāo)系統(tǒng)“的type改為optional6.點(diǎn)擊finished二、制作帶有坐標(biāo)的文本文件。1.這個(gè)文件第一行以d,x,m開頭,分別表示點(diǎn)線面。2.接下幾行是坐標(biāo)值,以“編號(hào)(編號(hào)從0開始) X坐標(biāo) Y坐標(biāo)”例如:0 40545654.256 532145697.3253.另起行以end結(jié)束。保存成txt格式的文件。三、生產(chǎn)shp圖層1.打開剛才那個(gè)制作好的腳本工具CreateFeaturesFromTextFile2. 按照提示操作,
3、坐標(biāo)系統(tǒng)可以不填3.點(diǎn)擊Ok。完成注意事項(xiàng):編寫的txt文件的坐標(biāo)必須按照順序編寫,否則圖形會(huì)出現(xiàn)紊亂(點(diǎn)文件除外)。將一下文本粘貼到txt中,并保存成.py的文件。'''- Tool Name: CreateFeaturesFromTextFile Source Name: CreateFeaturesFromTextFile.py Version: ArcGIS 9.1 Author: Environmental Systems Research Institute Inc. Required Argumuments: An Input Text File cont
4、aining feature coordinates An Input Character designating the decimal separator used in the text file. An output feature class Optional Arguments: A spatial reference can be specified. This will be the spatial reference of the output fc. Description: Reads a text file with feature coordinates and cr
5、eates a feature class from the coordinates.-'''import string, os, sys, locale, arcgisscriptinggp = arcgisscripting.create()gp.overwriteoutput = 1msgErrorTooFewParams = "Not enough parameters provided."msgUnknownDataType = " is not a valid datatype. Datatype must be point,
6、multipoint, polyline or polygon."msgErrorCreatingPoint = "Error creating point %s on feature %s"# sets all the point propertiesdef createPoint(point, geometry): try: point.id = geometry0 point.x = geometry1 point.y = geometry2 # When empty values are written out from pyWriteGeomToText
7、File, they come as 1.#QNAN # Additionally, the user need not supply these values, so if they aren't in the list don't add them if len(geometry) > 3: if geometry3.lower().find("nan") = -1: point.z = geometry3 if len(geometry) > 4: if geometry4.lower().find("nan") = -
8、1: point.m = geometry4 return point except: raise Exception, msgErrorCreatingPointtry: # get the provided parameters inputTxtFile = open(gp.getparameterastext(0) fileSepChar = gp.getparameterastext(1) outputFC = gp.getparameterastext(2) # spatial reference is optional outputSR = gp.getparameterastex
9、t(3) # make sure the text type specified in the text file is valid. inDataT = inputTxtFile.readline().strip().lower() d = 'd':'point','ml':'multipoint','x':'polyline','m':'polygon' inDataType = dinDataT dataTypes = "point", &q
10、uot;multipoint", "polyline", "polygon" if inDataType.lower() not in dataTypes: msgUnknownDataType = "%s%s" % (inDataType, msgUnknownDataType) raise Exception, msgUnknownDataType # create the new featureclass gp.toolbox = "management" gp.CreateFeatureclass
11、(outputFC)0, (outputFC)1, inDataType, "#", "ENABLED", "ENABLED", outputSR) # create a new field to assure the id of each feature is preserved. idfield = "File_ID" gp.addfield(outputFC, idfield, "LONG") # get some information about the new featureclas
12、s for later use. outDesc = gp.describe(outputFC) shapefield = outDesc.ShapeFieldName # create the cursor and objects necessary for the geometry creation rows = gp.insertcursor(outputFC) pnt = gp.createobject("point") pntarray = gp.createobject("Array") partarray = gp.createobject
13、("Array") locale.setlocale(locale.LC_ALL, '') sepchar = locale.localeconv()'decimal_point' # loop through the text file. featid = 0 lineno = 1 for line in inputTxtFile.readlines(): lineno += 1 # create an array from each line in the input text file values = line.replace(&qu
14、ot;n", "").replace("r", "").replace(fileSepChar, sepchar).split(" ") # for a point feature class simply populate a point object and insert it. if inDataType = "point" and values0.lower() != "end": row = rows.newrow() pnt = createPoint(
15、pnt, values) row.SetValue(shapefield, pnt) row.SetValue(idfield, int(values0) rows.insertrow(row) # for a multipoint the text file is organized a bit differently. Groups of points must be inserted at the same time. elif inDataType = "multipoint": if len(values) > 2: pnt = createPoint(pn
16、t, values) pntarray.add(pnt) elif (len(values) = 2 and lineno != 2) or values0.lower() = "end": row = rows.newrow() row.SetValue(shapefield, pntarray) # store the feature id just in case there is an error. helps track down the offending line in the input text file. if values0.lower() != &q
17、uot;end": row.SetValue(idfield, featid) featid = int(values0) else: row.SetValue(idfield, featid) rows.insertrow(row) pntarray.removeall() elif (len(values) = 2 and lineno = 2): featid = int(values0) # for polygons and lines. polygons have a bit of logic for interior rings (donuts). # lines use
18、 the same logic as polygons (except for the interior rings) elif inDataType = "polygon" or inDataType = "polyline": #takes care of #adds the point array to the part array and then part array to the feature if (len(values) = 2 and float(values1) = 0 and lineno != 2) or values0.low
19、er() = "end": partarray.add(pntarray) row = rows.newrow() row.SetValue(shapefield, partarray) # store the feature id just in case there is an error. helps track down the offending line in the input text file. if values0.lower() != "end": row.SetValue(idfield, featid) featid = int
20、(values0) else: row.SetValue(idfield, featid) rows.insertrow(row) partarray.removeall() pntarray.removeall() #adds parts and/or interior rings to the part array elif (len(values) = 2 and float(values1) > 0) or values0.lower() = "interiorring": partarray.add(pntarray) pntarray.removeall() #add points to the point array elif len(values) > 2: pnt = createPoint(pnt, values) pntarray.add(pnt) elif (len(values) = 2
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 小學(xué)英語課件
- 2025年云南省初中地理中考真題及答案
- 餐飲企業(yè)員工勞動(dòng)合同簽訂與競業(yè)限制合同
- 機(jī)場物業(yè)設(shè)施使用權(quán)租賃協(xié)議
- 拆遷工程進(jìn)度與質(zhì)量居間合同
- 防災(zāi)減災(zāi)安裝工程保險(xiǎn)合同
- 跨區(qū)域采購管理與流程實(shí)施合作協(xié)議
- 車輛維修保養(yǎng)中心質(zhì)押擔(dān)保合同
- 人體生理知識(shí)考試試卷含尿液形成消化等考點(diǎn)
- 2024-2025學(xué)年山東省煙臺(tái)市高一下學(xué)期期中地理試題及答案
- 員工工資表范本
- 過戶摩托車委托書
- 小學(xué)五年級(jí)下、六年級(jí)上年級(jí)數(shù)學(xué)口算天天練20以內(nèi)分?jǐn)?shù)加減乘除法隨機(jī)1000道-第1套
- 序篇 不忘初心 作品鑒賞 不忘初心 課件-2023-2024學(xué)年高中音樂人音版(2019)必修音樂鑒賞
- 16J916-1住宅排氣道一
- 四年級(jí)下冊(cè)數(shù)學(xué)期末測試試卷附完整答案【各地真題】
- JJG 971-2019液位計(jì)檢定規(guī)程
- 云南省楚雄州2022-2023學(xué)年高一下學(xué)期期末考試化學(xué)試題(解析版)
- 自動(dòng)售貨機(jī)投放方案
- 規(guī)范預(yù)防接種知情告知課件
- 2023陜西省中考英語真題試卷和答案
評(píng)論
0/150
提交評(píng)論