# Deleting nearly identical points in one dimention

I have extracted values from a raster in table form, done some calculations and plotted these points as XY data, in which I hope to use to create a line. However due to the original layout of the raster, I occasionally get a chatter effect. I would like to be able to delete the points where ONLY the X-coord values is within 0.7m of another x-cord value.

I have tried the Integrate tool, however it seems to take into account the Y coordinate as well. I have tried to smooth the line without luck as well.

I have no idea how to approach this problem. UPDATE After running the code below in on the line feature class I got the following result, it basically skipped over all the duplicate points, which serves the purpose of what I needed. I don't know why the last point was dropped. Old line is in black, the new line is in red. A more elegant approach would create and use a midpoint between each pair of the close points.

• If you have an Advanced license, you could use Genereate Near Table to find which features to delete. Just ignore the Y fields in the output. – Paul Apr 29 '16 at 18:57

This is classical field calculator task.

Take 1st point. Add it to empty list.

Get next point and compare it to last point in list. Add to list if it meet condition.

Convert list to polyline using

return arcpy.Polyline(arcpy.Array(thelist))

Take expression from Update Z values on a line feature and modify it slightly

UPDATE

Let's hope I understand what you want correctly.

Input: Output from field calculator expression (see below) applied on Shape field: Closer zoom to points labelled by their X coordinates ``````def plineM(shp, maxD):
part=shp.getPart(0);n=len(part)
aList=[]
for i in xrange(1,n-1):
p1=part.getObject(i-1)
p2=part.getObject(i)
p3=part.getObject(i+1)
if (p2.X-p1.X)<maxD or (p3.X-p2.X)<maxD:continue
aList.append(p2)
p0=part.getObject(0);p1=aList
if (p1.X - p0.X)>maxD: aList=[p0]+aList[:]
p1=part.getObject(n-1);p1=aList[-1]
if p1.X-p0.X>maxD: aList.append(p1)
return arcpy.Polyline(arcpy.Array(aList))
``````

# --------------------------

``````plineM( !Shape!,50 )
``````

Logic:

• Get consecutive 3 points along the line.
• If each of the pairs of ‘X distance’ is greater than limit (50 in above example), add middle point to a list of points to be converted into polyline.
• Thanks, I'm a bit of an arcPy dummy, how would you iterate through the list, just pulling the similar points?, how would you clear the list for comparing the next two points? – E. Ballent May 3 '16 at 17:34
• Thanks for your answer, please see my update. What field should I be trying to calculate? – E. Ballent May 4 '16 at 20:58
• You have to run it on line feature class, not on original points – FelixIP May 4 '16 at 21:06

I could not use The integrate tool to eliminate the duplicate points because the y co-ordinate was very different. However if I were to calculate the Y-co-ordinate to be nearly the same (multiply by 0.01), I can use the integrate tool and then re-calculate the Y-coordinate to the proper location. It is by far not the most elegant solution, but it does get the job done. Model This is the result: 