else:
partnum = 0
partcount = feat.partcount
while partnum < partcount:
part = feat.getpart(partnum)
if partflag:
outLine ="{"+outLine
else :
outLine =outLine+"{"
pnt = part.next()
if flag:
tmp1=outLine[:-1]
outLine =tmp1+"];"
flag=False
while pnt:
outLine =outLine+ str(pnt.x) + "," + str(pnt.y) + "," + str(pnt.z) + "," + str(pnt.m)+";"
pnt = part.next()
if not pnt:
pnt = part.next()
if pnt:
if flag:
tmp3=outLine[:-1]
outLine=tmp3+"];"
flag=True
outLine=outLine+"["+str(pnt.x) + "," + str(pnt.y) + "," + str(pnt.z) + "," + str(pnt.m)+";"
pnt = part.next()
if flag:
flag=False
tmp2=outLine[:-1]
outLine =tmp2+"];"
else:
tmp5=outLine[:-1]
outLine =tmp5+"}"
if partflag:
tmp4=outLine[:-1]
outLine =tmp4+"}"
partflag=False
partnum += 1
outLine=outLine[:-1]+"}"
inRow.SetValue(tmp,outLine)
inRows.UpdateRow(inRow)
outLine=''
inRow = inRows.next()
del inRow
del inRows
except Exception, ErrorDesc:
gp.AddError(ErrorDesc[0])
gp.AddError(gp.getmessages(2))
2.通过变更操作修改其中的坐标点信息,然后更新图形
import arcgisscripting
import fileinput
import os
import string
gp = arcgisscripting.create(9.3)
infile = sys.argv[1]
tmp=sys.argv[2]
# Create update cursor for feature class
inDesc = gp.describe(infile)
rows = gp.UpdateCursor(infile)
row = rows.Next()
gp.AddMessage(inDesc.ShapeType.lower())
flag=False
while row:
lineArray = gp.CreateObject("Array")
partArray=gp.CreateObject("Array")
featureVertexArray = gp.CreateObject("Array")
if inDesc.ShapeType.lower() == "polygon":
txt=str(row.GetValue(tmp))
strlist=string.split(txt,'}')
temstr=''
for value in strlist:
arr=string.split(value,';')
for pntstr in arr:
if len(pntstr)>1:
if pntstr[0:1]=='{':
temstr=pntstr[1:]
elif pntstr[0:1]=='[':
temstr=pntstr[1:]
elif pntstr[-1]==']':
temstr=pntstr[:-1]
flag=True
else:
temstr=pntstr
a=string.split(temstr,',')
pnt = gp.createobject("Point")
if len(a)==4:
pnt.x=string.atof(a[0])
pnt.y=string.atof(a[1])
pnt.z=string.atof(a[2])
pnt.m=string.atof(a[3])
lineArray.add(pnt)
gp.AddMessage(pnt.x)
gp.AddMessage(pnt.y)
if flag==True:
flag=False
featureVertexArray.add(lineArray)
lineArray.removeAll()
gp.AddMessage("newpart")
featureVertexArray.add(lineArray)
lineArray.removeAll()
polyGeom = gp.createobject("geometry", "polygon", featureVertexArray)
row.Shape=polyGeom
rows.UpdateRow(row)
row = rows.Next()
elif inDesc.ShapeType.lower() == "point":
pnt = gp.CreateObject("Point")
txt=str(row.GetValue(tmp))
arrp=string.split(txt,",")
x=arrp[0]
m=arrp[3]
pnt.x=string.atof(x[1:])
pnt.y=string.atof(arrp[1])
pnt.z=string.atof(arrp[2])
pnt.m=string.atof(m[:-1])
row.Shape=pnt
rows.UpdateRow(row)
row = rows.Next()
elif inDesc.ShapeType.lower() == "multipoint":
txt=str(row.GetValue(tmp))
strlist=string.split(txt,'}')
temstr=''
for value in strlist:
arr=string.split(value,';')
for pntstr in arr:
if pntstr[0:1]=='{':
temstr=pntstr[1:]
else:
temstr=pntstr
a=string.split(temstr,',')
pnt = gp.createobject("Point")
if len(a)==4:
pnt.x=string.atof(a[0])
pnt.y=string.atof(a[1])
pnt.z=string.atof(a[2])
pnt.m=string.atof(a[3])
lineArray.add(pnt)
gp.AddMessage(pnt.x)
gp.AddMessage(pnt.y)
gp.AddMessage("newpart")
row.Shape=lineArray
rows.UpdateRow(row)
row = rows.Next()
elif inDesc.ShapeType.lower() == "polyline":
txt=str(row.GetValue(tmp))
strlist=string.split(txt,'}')
temstr=''
for value in strlist:
arr=string.split(value,';')
for pntstr in arr:
if pntstr[0:1]=='{':
temstr=pntstr[1:]
else:
temstr=pntstr
a=string.split(temstr,',')
pnt = gp.createobject("Point")
if len(a)==4:
pnt.x=string.atof(a[0])
pnt.y=string.atof(a[1])
pnt.z=string.atof(a[2])
pnt.m=string.atof(a[3])
lineArray.add(pnt)
gp.AddMessage(pnt.x)
gp.AddMessage(pnt.y)
gp.AddMessage("newpart")
featureVertexArray.add(lineArray)
lineArray.removeAll()
polyGeomline = gp.createobject("geometry", "polyline", featureVertexArray)
row.Shape=polyGeomline
rows.UpdateRow(row)
row = rows.Next()
# Delete cursor and row objects to remove locks on the data
del row
del rows