1

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.enter image description here

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.enter image description here

A more elegant approach would create and use a midpoint between each pair of the close points.

1
  • 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
    Commented Apr 29, 2016 at 18:57

2 Answers 2

1

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:

enter image description here

Output from field calculator expression (see below) applied on Shape field:

enter image description here

Closer zoom to points labelled by their X coordinates

enter image description here

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[0]
  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.
3
  • 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
    Commented May 3, 2016 at 17:34
  • Thanks for your answer, please see my update. What field should I be trying to calculate?
    – E. Ballent
    Commented May 4, 2016 at 20:58
  • You have to run it on line feature class, not on original points
    – FelixIP
    Commented May 4, 2016 at 21:06
0

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. Modelenter image description here

This is the result: enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.