Arcgis10.0之后版本坐標(biāo)值轉(zhuǎn)換成shp圖層教程_第1頁(yè)
Arcgis10.0之后版本坐標(biāo)值轉(zhuǎn)換成shp圖層教程_第2頁(yè)
Arcgis10.0之后版本坐標(biāo)值轉(zhuǎn)換成shp圖層教程_第3頁(yè)
Arcgis10.0之后版本坐標(biāo)值轉(zhuǎn)換成shp圖層教程_第4頁(yè)
Arcgis10.0之后版本坐標(biāo)值轉(zhuǎn)換成shp圖層教程_第5頁(yè)
已閱讀5頁(yè),還剩5頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡(jiǎn)介

通過(guò)坐標(biāo)數(shù)值生成點(diǎn)線面的shp圖層Arcgis10.0之后版本雖然交9.3增加了很多功能,但是卻不知何故少了一些常用的功能。本問(wèn)主要就比擬常用通過(guò)坐標(biāo)數(shù)值生成點(diǎn)線面的shp圖層做簡(jiǎn)單介紹。一、前期準(zhǔn)備1.將附件CreateFeaturesFromTextFile文件復(fù)制到任何一個(gè)固定的位置。2.翻開(kāi)Arcgis,新建toolbox3.按圖新建腳本工具C:\ProgramFiles\ArcGIS\Desktop10.1\ArcToolbox\Stylesheets\geoprocessing_help.xsl4.點(diǎn)擊下一步,ScriptFile選擇剛剛那個(gè)腳本文件“CreateFeaturesFromTextFile〞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開(kāi)頭,分別表示點(diǎn)線面。2.接下幾行是坐標(biāo)值,以“編號(hào)〔編號(hào)從0開(kāi)始〕X坐標(biāo)Y坐標(biāo)〞例如:040545654.256532145697.3253.另起行以end結(jié)束。保存成txt格式的文件。三、生產(chǎn)shp圖層1.翻開(kāi)剛剛那個(gè)制作好的腳本工具CreateFeaturesFromTextFile2.按照提示操作,坐標(biāo)系統(tǒng)可以不填3.點(diǎn)擊Ok。完成考前須知:編寫(xiě)的txt文件的坐標(biāo)必須按照順序編寫(xiě),否那么圖形會(huì)出現(xiàn)紊亂〔點(diǎn)文件除外〕。將一下文本粘貼到txt中,并保存成.py的文件。'''----------------------------------------------------------------------------------ToolName:CreateFeaturesFromTextFileSourceName:CreateFeaturesFromTextFile.pyVersion:ArcGIS9.1Author:EnvironmentalSystemsResearchInstituteInc.RequiredArgumuments:AnInputTextFilecontainingfeaturecoordinatesAnInputCharacterdesignatingthedecimalseparatorusedinthetextfile.AnoutputfeatureclassOptionalArguments:Aspatialreferencecanbespecified.Thiswillbethespatialreferenceoftheoutputfc.Description:Readsatextfilewithfeaturecoordinatesandcreatesafeatureclassfromthecoordinates.----------------------------------------------------------------------------------'''importstring,os,sys,locale,arcgisscriptinggp=arcgisscripting.create()gp.overwriteoutput=1msgErrorTooFewParams="Notenoughparametersprovided."msgUnknownDataType="isnotavaliddatatype.Datatypemustbepoint,multipoint,polylineorpolygon."msgErrorCreatingPoint="Errorcreatingpoint%sonfeature%s"#setsallthepointpropertiesdefcreatePoint(point,geometry):try:point.id=geometry[0]point.x=geometry[1]point.y=geometry[2]#WhenemptyvaluesarewrittenoutfrompyWriteGeomToTextFile,theycomeas1.#QNAN#Additionally,theuserneednotsupplythesevalues,soiftheyaren'tinthelistdon'taddthemiflen(geometry)>3:ifgeometry[3].lower().find("nan")==-1:point.z=geometry[3]iflen(geometry)>4:ifgeometry[4].lower().find("nan")==-1:point.m=geometry[4]returnpointexcept:raiseException,msgErrorCreatingPointtry:#gettheprovidedparametersinputTxtFile=open(gp.getparameterastext(0))fileSepChar=gp.getparameterastext(1)outputFC=gp.getparameterastext(2)#spatialreferenceisoptionaloutputSR=gp.getparameterastext(3)#makesurethetexttypespecifiedinthetextfileisvalid.inDataT=inputTxtFile.readline().strip().lower()d={'d':'point','ml':'multipoint','x':'polyline','m':'polygon'}inDataType=d[inDataT]dataTypes=["point","multipoint","polyline","polygon"]ifinDataType.lower()notindataTypes:msgUnknownDataType="%s%s"%(inDataType,msgUnknownDataType)raiseException,msgUnknownDataType#createthenewfeatureclassgp.toolbox="management"gp.CreateFeatureclass((outputFC)[0],(outputFC)[1],inDataType,"#","ENABLED","ENABLED",outputSR)#createanewfieldtoassuretheidofeachfeatureispreserved.idfield="File_ID"gp.addfield(outputFC,idfield,"LONG")#getsomeinformationaboutthenewfeatureclassforlateruse.outDesc=gp.describe(outputFC)shapefield=outDesc.ShapeFieldName#createthecursorandobjectsnecessaryforthegeometrycreationrows=gp.insertcursor(outputFC)pnt=gp.createobject("point")pntarray=gp.createobject("Array")partarray=gp.createobject("Array")locale.setlocale(locale.LC_ALL,'')sepchar=locale.localeconv()['decimal_point']#loopthroughthetextfile.featid=0lineno=1forlineininputTxtFile.readlines():lineno+=1#createanarrayfromeachlineintheinputtextfilevalues=line.replace("\n","").replace("\r","").replace(fileSepChar,sepchar).split("")#forapointfeatureclasssimplypopulateapointobjectandinsertit.ifinDataType=="point"andvalues[0].lower()!="end":row=rows.newrow()pnt=createPoint(pnt,values)row.SetValue(shapefield,pnt)row.SetValue(idfield,int(values[0]))rows.insertrow(row)#foramultipointthetextfileisorganizedabitdifferently.Groupsofpointsmustbeinsertedatthesametime.elifinDataType=="multipoint":iflen(values)>2:pnt=createPoint(pnt,values)pntarray.add(pnt)elif(len(values)==2andlineno!=2)orvalues[0].lower()=="end":row=rows.newrow()row.SetValue(shapefield,pntarray)#storethefeatureidjustincasethereisanerror.helpstrackdowntheoffendinglineintheinputtextfile.ifvalues[0].lower()!="end":row.SetValue(idfield,featid)featid=int(values[0])else:row.SetValue(idfield,featid)rows.insertrow(row)pntarray.removeall()elif(len(values)==2andlineno==2):featid=int(values[0])#forpolygonsandlines.polygonshaveabitoflogicforinteriorrings(donuts).#linesusethesamelogicaspolygons(exceptfortheinteriorrings)elifinDataType=="polygon"orinDataType=="polyline":#takescareof#addsthepointarraytothepartarrayandthenpartarraytothefeatureif(len(values)==2andfloat(values[1])==0andlineno!=2)orvalues[0].lower()=="end":partarray.add(pntarray)row=rows.newrow()row.SetValue(shapefield,partarray)#storethefeatureidjustincasethereisanerror.helpstrackdowntheoffendinglineintheinputtextfile.ifvalues[0].lower()!="end":row.SetValue(idfield,featid)featid=int(values[0])else:row.SetValue(idfield,featid)rows.insertrow(row)partarray.removeall()pntarray.removeall()#addspartsand/orinteriorringstothepartarrayelif(len(values)==2andfloat(values[1])>0)orvalues[0].lower()=="interiorring":partarray.add(pntarray)pntarray.removeall()#addpointstothepointarrayeliflen(values)>2:pnt=createPoint(pnt,values)pntarray.add(pnt)elif(len(values)==2

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(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ì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論