Hello,I have a multipoint feature class generated from LAS to Multipoint. In the data, there are a few erroneous points I'd like to delete. The area covered ranges in elevation from 50 to 250 feet above sea level. What I figured I could do is iterate through all the points and remove any that have a Z value below 0 or above 1000.
import arcgisscripting, os, sys, re
gp = arcgisscripting.create(9.3)
if len(sys.argv)< 2:
gp.AddError("Insufficient parameters.")
sys.exit(2)
ifc = sys.argv[1]
des = gp.Describe(ifc)
sfn = des.ShapeFieldName
oid = des.OIDFieldName
result = gp.GetCount_management(ifc)
cnt = int(result.GetOutput(0))
gp.AddMessage("%d features in feature class." % cnt)
cursor = gp.updatecursor(ifc)
row = cursor.next()
gp.SetProgressor("step", "Iterating through Multipoints...", 0, cnt, 1)
while row:
feat = row.GetValue(sfn)
partnum = 0
partcount = feat.PartCount
while partnum < partcount:
point = feat.GetPart(partnum)
if((point.z > 1000) or (point.z < 0)):
gp.AddWarning("Multipoint feature outside of threshold.")
gp.AddMessage("%d -> %d -> %s" % (row.GetValue(oid), partnum, str(point.z)))
feat.Remove(partnum)
# else:
# gp.AddMessage(str(partnum) + "->" + str(point.z))
partnum += 1
gp.SetProgressorPosition()
row = cursor.next()
The commented out section, if moved into the if((point.z > 1000) or (point.z < 0)): block will correctly identify the points outside my range. I just don't know how to remove the point in question as I iterate over the array of multipoint parts. I thought I could use the "remove" method on the feature array to remove that specific part, but "feat" does not have the remove method (ie feat.remove(partnum)). point.remove(0) doesn't work either. Do I have to reconstruct a multipart feature, omitting any offending points and then replace the record, or is there some way to remove vertices/multipoint parts as I'm walking through?Thanks in advance for your help.