版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
通过坐标数值生成点线面的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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026中国疾病预防控制中心(中国预防医学科学院)政策规划研究室招聘备考题库及一套答案详解
- 2026四川绵阳万江眼科医院招聘备考题库附答案详解(培优)
- 2026广东江门市中心医院博士后研究人员招聘备考题库含答案详解(巩固)
- 2026广东深圳市儿童医院招聘4人备考题库及答案详解1套
- 武汉地铁集团有限公司2026届春季校园招聘备考题库及参考答案详解
- 2026四川绵阳市盐亭国有投资管理有限公司招聘管理岗位和业务岗位10人备考题库参考答案详解
- 2026江苏徐州物资市场有限公司招聘6人备考题库附答案详解(精练)
- 2026年福建泉州经济技术开发区官桥园区开发建设有限公司招聘5名工作人员备考题库及1套参考答案详解
- 2026贵州贵阳市国信公证处招聘见习人员1人备考题库含答案详解(研优卷)
- 2026中国无籽葡萄干市场营销策略与消费需求预测报告
- 5.2广西基本概况与主要文旅资源《地方导游基础知识》教学课件
- 项目任务活动挖掘有价值客户课时
- 人教A版高中数学选择性必修第二册全册各章节课时练习题含答案解析(第四章数列、第五章一元函数的导数及其应用)
- 2023学年完整公开课版横断面测量
- 2022年04月新疆石河子大学医学院第二轮教师招聘0笔试参考题库答案解析版
- GB/T 37361-2019漆膜厚度的测定超声波测厚仪法
- GB 22134-2008火灾自动报警系统组件兼容性要求
- 带状疱疹针灸治疗学课件
- 老年髋部骨折患者围术期麻醉管理课件
- 中国古代文学史模拟试卷
- 厂用电设备安装方案
评论
0/150
提交评论