![Arcgis10.0之后版本坐标值转换成shp图层教程_第1页](http://file4.renrendoc.com/view/138484078dfe36c73e42ecb895600af2/138484078dfe36c73e42ecb895600af21.gif)
![Arcgis10.0之后版本坐标值转换成shp图层教程_第2页](http://file4.renrendoc.com/view/138484078dfe36c73e42ecb895600af2/138484078dfe36c73e42ecb895600af22.gif)
![Arcgis10.0之后版本坐标值转换成shp图层教程_第3页](http://file4.renrendoc.com/view/138484078dfe36c73e42ecb895600af2/138484078dfe36c73e42ecb895600af23.gif)
![Arcgis10.0之后版本坐标值转换成shp图层教程_第4页](http://file4.renrendoc.com/view/138484078dfe36c73e42ecb895600af2/138484078dfe36c73e42ecb895600af24.gif)
![Arcgis10.0之后版本坐标值转换成shp图层教程_第5页](http://file4.renrendoc.com/view/138484078dfe36c73e42ecb895600af2/138484078dfe36c73e42ecb895600af25.gif)
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
通过坐标数值生成点线面的shp图层Arcgis10.0之后版本虽然交9.3增加了很多功能,但是却不知何故少了一些常用的功能。本问主要就比拟常用通过坐标数值生成点线面的shp图层做简单介绍。一、前期准备1.将附件CreateFeaturesFromTextFile文件复制到任何一个固定的位置。2.翻开Arcgis,新建toolbox3.按图新建脚本工具C:\ProgramFiles\ArcGIS\Desktop10.1\ArcToolbox\Stylesheets\geoprocessing_help.xsl4.点击下一步,ScriptFile选择刚刚那个脚本文件“CreateFeaturesFromTextFile〞5.设置参数其中,“坐标值规定“中的Default的值为12345678.12345“输出shp文件〞中的Direction改为output“坐标系统“的type改为optional6.点击finished二、制作带有坐标的文本文件。1.这个文件第一行以d,x,m开头,分别表示点线面。2.接下几行是坐标值,以“编号〔编号从0开始〕X坐标Y坐标〞例如:040545654.256532145697.3253.另起行以end结束。保存成txt格式的文件。三、生产shp图层1.翻开刚刚那个制作好的脚本工具CreateFeaturesFromTextFile2.按照提示操作,坐标系统可以不填3.点击Ok。完成考前须知:编写的txt文件的坐标必须按照顺序编写,否那么图形会出现紊乱〔点文件除外〕。将一下文本粘贴到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. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- TBS-Corey-lactone-aldehyde-生命科学试剂-MCE-2452
- Anti-Mouse-CD3E-Antibody-1E11-D-生命科学试剂-MCE-1878
- 8-Amino-7-oxononanoic-acid-hydrochloride-生命科学试剂-MCE-9983
- 3-O-Methylguanosine-5-O-triphosphate-sodium-3-O-Methyl-GTP-sodium-生命科学试剂-MCE-9300
- 二零二五年度大数据分析技术顾问聘请协议
- 二零二五年度游乐园场地租赁与儿童游乐设施安全标准制定合同
- 二零二五年度房屋贷款房屋买卖合同范本(含家具)
- 施工现场管理制度化
- 施工方案对篮球场材料的要求与选择
- 高净值人群海外税务筹划与财富保护策略
- 2025年高考物理复习压轴题:电磁感应综合问题(原卷版)
- 雨棚钢结构施工组织设计正式版
- 医院重点监控药品管理制度
- 2024尼尔森IQ中国本土快消企业调研报告
- 2024年印度辣椒行业状况及未来发展趋势报告
- 骨科医院感染控制操作流程
- 中药的临床合理应用
- 铸铝焊接工艺
- (正式版)HGT 6313-2024 化工园区智慧化评价导则
- 《社区康复》课件-第六章 骨关节疾病、损伤患者的社区康复实践
- 南通市2024届高三第二次调研测试(二模)地理试卷(含官方答案)
评论
0/150
提交评论