版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、通過坐標數值生成點線面的shp圖層Arcgis10.0之后版本雖然交9.3增加了很多功能,但是卻不知何故少了一些常用的功能。本問主要就比較常用通過坐標數值生成點線面的shp圖層做簡單介紹。一、前期準備1.將附件CreateFeaturesFromTextFile文件復制到任何一個固定的位置。2.打開Arcgis,新建toolbox3.按圖新建腳本工具 C:Program FilesArcGISDesktop10.1ArcToolboxStylesheetsgeoprocessing_help.xsl4.點擊下一步,Script File選擇剛才那個腳本文件“CreateFeaturesFrom
2、TextFile”5.設置參數其中,“坐標值規(guī)定“中的Default的值為12345678.12345“輸出shp文件”中的Direction改為output“坐標系統(tǒng)“的type改為optional6.點擊finished二、制作帶有坐標的文本文件。1.這個文件第一行以d,x,m開頭,分別表示點線面。2.接下幾行是坐標值,以“編號(編號從0開始) X坐標 Y坐標”例如:0 40545654.256 532145697.3253.另起行以end結束。保存成txt格式的文件。三、生產shp圖層1.打開剛才那個制作好的腳本工具CreateFeaturesFromTextFile2. 按照提示操作,
3、坐標系統(tǒng)可以不填3.點擊Ok。完成注意事項:編寫的txt文件的坐標必須按照順序編寫,否則圖形會出現紊亂(點文件除外)。將一下文本粘貼到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等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2024年軟件開發(fā)知識產權服務合同范本
- 住宅買賣委托代理合同
- 施工場地文明施工責任書
- 【初中地理】第二章地圖基礎診斷卷 2024-2025學年人教版地理七年級上冊
- 人才發(fā)展合作方案協(xié)議
- 藝術家工作室合伙協(xié)議書樣本
- 專業(yè)庭院綠化施工合同示范
- 小產權房買賣合同匯編
- 2024年財務會計保密協(xié)議
- 投資公司勞務合同范本
- 江蘇省南通市2023-2024學年七上期中數學試題(解析版)
- 體育大單元教學計劃(18課時)
- 讓小車運動起來說課稿
- 2023-2024學年北京朝陽區(qū)高三(上)期中數學試題和答案
- 工程招投標管理與實踐作業(yè)指導書
- ISO 22003-1:2022《食品安全-第 1 部分:食品安全管理體系 審核與認證機構要求》中文版(機翻)
- 2024年消防月主題活動方案啟動及全員消防安全知識培訓
- 高職組“智能財稅”賽項國賽賽題2022
- 期中考試卷(試題)-2024-2025學年蘇教版二年級數學上冊
- 2024年全國企業(yè)員工全面質量管理知識競賽題庫(含答案)(共132題)
- 社會工作者《社會工作綜合能力(中級)》試題(附答案)
評論
0/150
提交評論