Arcgis100之后版本坐标值转换成shp图层教程Word文档下载推荐.docx

上传人:b****2 文档编号:1520641 上传时间:2023-04-30 格式:DOCX 页数:11 大小:214.47KB
下载 相关 举报
Arcgis100之后版本坐标值转换成shp图层教程Word文档下载推荐.docx_第1页
第1页 / 共11页
Arcgis100之后版本坐标值转换成shp图层教程Word文档下载推荐.docx_第2页
第2页 / 共11页
Arcgis100之后版本坐标值转换成shp图层教程Word文档下载推荐.docx_第3页
第3页 / 共11页
Arcgis100之后版本坐标值转换成shp图层教程Word文档下载推荐.docx_第4页
第4页 / 共11页
Arcgis100之后版本坐标值转换成shp图层教程Word文档下载推荐.docx_第5页
第5页 / 共11页
Arcgis100之后版本坐标值转换成shp图层教程Word文档下载推荐.docx_第6页
第6页 / 共11页
Arcgis100之后版本坐标值转换成shp图层教程Word文档下载推荐.docx_第7页
第7页 / 共11页
Arcgis100之后版本坐标值转换成shp图层教程Word文档下载推荐.docx_第8页
第8页 / 共11页
Arcgis100之后版本坐标值转换成shp图层教程Word文档下载推荐.docx_第9页
第9页 / 共11页
Arcgis100之后版本坐标值转换成shp图层教程Word文档下载推荐.docx_第10页
第10页 / 共11页
Arcgis100之后版本坐标值转换成shp图层教程Word文档下载推荐.docx_第11页
第11页 / 共11页
亲,该文档总共11页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

Arcgis100之后版本坐标值转换成shp图层教程Word文档下载推荐.docx

《Arcgis100之后版本坐标值转换成shp图层教程Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《Arcgis100之后版本坐标值转换成shp图层教程Word文档下载推荐.docx(11页珍藏版)》请在冰点文库上搜索。

Arcgis100之后版本坐标值转换成shp图层教程Word文档下载推荐.docx

例如:

040545654.256532145697.325

3.另起行以end结束。

保存成txt格式的文件。

三、生产shp图层

1.打开刚才那个制作好的脚本工具CreateFeaturesFromTextFile

2.按照提示操作,坐标系统可以不填

3.点击Ok。

完成

注意事项:

编写的txt文件的坐标必须按照顺序编写,否则图形会出现紊乱(点文件除外)。

将一下文本粘贴到txt中,并保存成.py的文件。

'

----------------------------------------------------------------------------------

ToolName:

CreateFeaturesFromTextFile

SourceName:

CreateFeaturesFromTextFile.py

Version:

ArcGIS9.1

Author:

EnvironmentalSystemsResearchInstituteInc.

RequiredArgumuments:

AnInputTextFilecontainingfeaturecoordinates

AnInputCharacterdesignatingthedecimalseparatorusedinthetextfile.

Anoutputfeatureclass

OptionalArguments:

Aspatialreferencecanbespecified.Thiswillbethe

spatialreferenceoftheoutputfc.

Description:

Readsatextfilewithfeaturecoordinatesandcreatesafeatureclass

fromthecoordinates.

----------------------------------------------------------------------------------'

importstring,os,sys,locale,arcgisscripting

gp=arcgisscripting.create()

gp.overwriteoutput=1

msgErrorTooFewParams="

Notenoughparametersprovided."

msgUnknownDataType="

isnotavaliddatatype.Datatypemustbepoint,multipoint,polylineorpolygon."

msgErrorCreatingPoint="

Errorcreatingpoint%sonfeature%s"

#setsallthepointproperties

defcreatePoint(point,geometry):

try:

point.id=geometry[0]

point.x=geometry[1]

point.y=geometry[2]

#WhenemptyvaluesarewrittenoutfrompyWriteGeomToTextFile,theycomeas1.#QNAN

#Additionally,theuserneednotsupplythesevalues,soiftheyaren'

tinthelistdon'

taddthem

iflen(geometry)>

3:

ifgeometry[3].lower().find("

nan"

)==-1:

point.z=geometry[3]

4:

ifgeometry[4].lower().find("

point.m=geometry[4]

returnpoint

except:

raiseException,msgErrorCreatingPoint

try:

#gettheprovidedparameters

inputTxtFile=open(gp.getparameterastext(0))

fileSepChar=gp.getparameterastext

(1)

outputFC=gp.getparameterastext

(2)

#spatialreferenceisoptional

outputSR=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

#createthenewfeatureclass

gp.toolbox="

management"

gp.CreateFeatureclass(os.path.split(outputFC)[0],os.path.split(outputFC)[1],inDataType,"

#"

ENABLED"

outputSR)

#createanewfieldtoassuretheidofeachfeatureispreserved.

idfield="

File_ID"

gp.addfield(outputFC,idfield,"

LONG"

#getsomeinformationaboutthenewfeatureclassforlateruse.

outDesc=gp.describe(outputFC)

shapefield=outDesc.ShapeFieldName

#createthecursorandobjectsnecessaryforthegeometrycreation

rows=gp.insertcursor(outputFC)

pnt=gp.createobject("

pntarray=gp.createobject("

Array"

partarray=gp.createobject("

locale.setlocale(locale.LC_ALL,'

sepchar=locale.localeconv()['

decimal_point'

#loopthroughthetextfile.

featid=0

lineno=1

forlineininputTxtFile.readlines():

lineno+=1

#createanarrayfromeachlineintheinputtextfile

values=line.replace("

\n"

"

).replace("

\r"

).replace(fileSepChar,sepchar).split("

"

#forapointfeatureclasssimplypopulateapointobjectandinsertit.

ifinDataType=="

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=="

iflen(values)>

2:

pntarray.add(pnt)

elif(len(values)==2andlineno!

=2)orvalues[0].lower()=="

row.SetValue(shapefield,pntarray)

#storethefeatureidjustincasethereisanerror.helpstrackdowntheoffendinglineintheinputtextfile.

ifvalues[0].lower()!

row.SetValue(idfield,featid)

featid=int(values[0])

else:

pntarray.removeall()

elif(len(values)==2andlineno==2):

#forpolygonsandlines.polygonshaveabitoflogicforinteriorrings(donuts).

#linesusethesamelogicaspolygons(exceptfortheinteriorrings)

orinDataType=="

#takescareof

#addsthepointarraytothepartarrayandthenpartarraytothefeature

if(len(values)==2andfloat(values[1])==0andlineno!

partarray.add(pntarray)

row.SetValue(shapefield,partarray)

partarray.removeall()

#addspartsand/orinteriorringstothepartarray

elif(len(values)==2andfloat(values[1])>

0)orvalues[0].lower()=="

interiorring"

#addpointstothepointarray

eliflen(values)>

inputTxtFile.close()

delrows

delrow

exceptException,ErrorDesc:

#handletheerrorshere.ifthepointcreationfails,wanttokeeptrackofwhichpointfailed(easiertofixthe

#textfileifwedo)

ifErrorDesc[0]==msgErrorCreatingPoint:

ifinDataType.lower()=="

msgErrorCreatingPoint=msgErrorCreatingPoint%(values[0],values[0])

msgErrorCreatingPoint=msgErrorCreatingPoint%(values[0],featid)

gp.AddError(msgErrorCreatingPoint)

elifErrorDesc[0]!

gp.AddError(str(ErrorDesc))

gp.AddError(gp.getmessages

(2))

#makesuretocloseupthefileinputnomatterwhat.

ifinputTxtFile:

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 求职职场 > 简历

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2