Python Delete point in a distance of x metersSelect maximum number of points more than x meters apartWhere clause problems when all parts are user input variablesCalculating distances between points two feature datasetsLoop and perform loop in order depending on attributeHow to do a Loop with a condition in Model Builder?Finding and snapping nearest point to polyline/pointCreate points based on location of known points in a layerImprove my arcpy script for simple queryingGet nearest line to point with v.distance in QGISStratified random point sampling in PythonCreating Near Table between points in one layer that share an attribute with points in another layer?

Alternative to sending password over mail?

Can a vampire attack twice with their claws using Multiattack?

How do I deal with an unproductive colleague in a small company?

How does quantile regression compare to logistic regression with the variable split at the quantile?

What's the point of deactivating Num Lock on login screens?

High voltage LED indicator 40-1000 VDC without additional power supply

Why "Having chlorophyll without photosynthesis is actually very dangerous" and "like living with a bomb"?

A newer friend of my brother's gave him a load of baseball cards that are supposedly extremely valuable. Is this a scam?

When a company launches a new product do they "come out" with a new product or do they "come up" with a new product?

Perform and show arithmetic with LuaLaTeX

Why is 150k or 200k jobs considered good when there's 300k+ births a month?

Important Resources for Dark Age Civilizations?

Convert two switches to a dual stack, and add outlet - possible here?

What does it mean to describe someone as a butt steak?

Maximum likelihood parameters deviate from posterior distributions

Definite integral giving negative value as a result?

How old can references or sources in a thesis be?

Does detail obscure or enhance action?

Is it possible to do 50 km distance without any previous training?

What are these boxed doors outside store fronts in New York?

How can I prevent hyper evolved versions of regular creatures from wiping out their cousins?

Is it tax fraud for an individual to declare non-taxable revenue as taxable income? (US tax laws)

tikz convert color string to hex value

Intersection point of 2 lines defined by 2 points each



Python Delete point in a distance of x meters


Select maximum number of points more than x meters apartWhere clause problems when all parts are user input variablesCalculating distances between points two feature datasetsLoop and perform loop in order depending on attributeHow to do a Loop with a condition in Model Builder?Finding and snapping nearest point to polyline/pointCreate points based on location of known points in a layerImprove my arcpy script for simple queryingGet nearest line to point with v.distance in QGISStratified random point sampling in PythonCreating Near Table between points in one layer that share an attribute with points in another layer?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I took this code from this source Select maximum number of points more than x meters apart



It seems to work for other users, but for me it's an endless loop. I do not understand why, though the code makes sense. The code itself gives me the result I want to get.



Can you help me out of this endless loop:



import arcpy, sys

feature = arcpy.GetParameterAsText(0)
distance = 500

arcpy.gp.overwriteOutput = True

#running NEAR analysis - every point gets attribute of a distance to the nearest point
#in same feature class
arcpy.AddMessage("running first near analysis")
arcpy.Near_analysis(feature, feature)

arcpy.AddMessage("inserting cursor")
cur = arcpy.UpdateCursor(feature)
row = cur.next()

arcpy.AddMessage("starting loop")

i=0
while row:
i+=1
#fids list will store list of deleted points so if any other point will have
#deleted one as the nearest and distance < 150 will not get deleted as this
#distance is no longer true
fids = []
while row:
if row.NEAR_DIST < distance:
try:
#it seems I didn't know if .. in .. at the time ;) such a fun to dig
#this script up! index throws an exception if element is not in the
#list
fids.index(row.NEAR_FID)
arcpy.AddMessage("OBJECTID = " + str(row.OBJECTID) + " is listed!")
except:
arcpy.AddMessage("deleting OBJECTID = " + str(row.OBJECTID))
fids.append(row.FID)
cur.deleteRow(row)
d = 1
row = cur.next()
del cur, row, fids
try:
#this idiotic test is to break the loop when no points will have
#NEAR_DIST < 150, shameful - I know!
if d == 1:
pass
except:
sys.exit()
d = 0
arcpy.AddMessage("loop iteration " + str(i))

#and again we go..
arcpy.Near_analysis(feature, feature)
cur = arcpy.UpdateCursor(feature)
row = cur.next()


The functional CODE:



import arcpy, sys

feature = arcpy.GetParameterAsText(0)

def nearRoutine():
#calculate the distances using the current dataset
arcpy.Near_analysis(feature, feature)

#iterate through any features which are within the distance
cur = arcpy.UpdateCursor(feature, '"NEAR_DIST" < 500')
row1 = cur.next()
while row1:

#this point is within the distance of its neighbor, so delete it
cur.deleteRow(row1)

#now re-run this routine on the new dataset
del row1, cur
cur = arcpy.UpdateCursor(feature, '"NEAR_DIST" < 500')
row1 = cur.next()
nearRoutine

#call the recursive routine. It will get progressively faster to run as it will loop through fewer points each time
nearRoutine()


Thanks @Stephen Lead










share|improve this question
























  • I really dislike how people use the while loop in arcpy and pyqgis to loop features. It is almost never needed and is error prone. Not your fault as you just copied it. Just a mini rant

    – Nathan W
    Aug 1 '13 at 13:43












  • I agree, @NathanW. It doesn't seem as intuitive to me what is going on. You don't need to use .next() in a for loop, and you have a built in counter with enumerate().

    – Paul
    Aug 1 '13 at 14:56

















0















I took this code from this source Select maximum number of points more than x meters apart



It seems to work for other users, but for me it's an endless loop. I do not understand why, though the code makes sense. The code itself gives me the result I want to get.



Can you help me out of this endless loop:



import arcpy, sys

feature = arcpy.GetParameterAsText(0)
distance = 500

arcpy.gp.overwriteOutput = True

#running NEAR analysis - every point gets attribute of a distance to the nearest point
#in same feature class
arcpy.AddMessage("running first near analysis")
arcpy.Near_analysis(feature, feature)

arcpy.AddMessage("inserting cursor")
cur = arcpy.UpdateCursor(feature)
row = cur.next()

arcpy.AddMessage("starting loop")

i=0
while row:
i+=1
#fids list will store list of deleted points so if any other point will have
#deleted one as the nearest and distance < 150 will not get deleted as this
#distance is no longer true
fids = []
while row:
if row.NEAR_DIST < distance:
try:
#it seems I didn't know if .. in .. at the time ;) such a fun to dig
#this script up! index throws an exception if element is not in the
#list
fids.index(row.NEAR_FID)
arcpy.AddMessage("OBJECTID = " + str(row.OBJECTID) + " is listed!")
except:
arcpy.AddMessage("deleting OBJECTID = " + str(row.OBJECTID))
fids.append(row.FID)
cur.deleteRow(row)
d = 1
row = cur.next()
del cur, row, fids
try:
#this idiotic test is to break the loop when no points will have
#NEAR_DIST < 150, shameful - I know!
if d == 1:
pass
except:
sys.exit()
d = 0
arcpy.AddMessage("loop iteration " + str(i))

#and again we go..
arcpy.Near_analysis(feature, feature)
cur = arcpy.UpdateCursor(feature)
row = cur.next()


The functional CODE:



import arcpy, sys

feature = arcpy.GetParameterAsText(0)

def nearRoutine():
#calculate the distances using the current dataset
arcpy.Near_analysis(feature, feature)

#iterate through any features which are within the distance
cur = arcpy.UpdateCursor(feature, '"NEAR_DIST" < 500')
row1 = cur.next()
while row1:

#this point is within the distance of its neighbor, so delete it
cur.deleteRow(row1)

#now re-run this routine on the new dataset
del row1, cur
cur = arcpy.UpdateCursor(feature, '"NEAR_DIST" < 500')
row1 = cur.next()
nearRoutine

#call the recursive routine. It will get progressively faster to run as it will loop through fewer points each time
nearRoutine()


Thanks @Stephen Lead










share|improve this question
























  • I really dislike how people use the while loop in arcpy and pyqgis to loop features. It is almost never needed and is error prone. Not your fault as you just copied it. Just a mini rant

    – Nathan W
    Aug 1 '13 at 13:43












  • I agree, @NathanW. It doesn't seem as intuitive to me what is going on. You don't need to use .next() in a for loop, and you have a built in counter with enumerate().

    – Paul
    Aug 1 '13 at 14:56













0












0








0








I took this code from this source Select maximum number of points more than x meters apart



It seems to work for other users, but for me it's an endless loop. I do not understand why, though the code makes sense. The code itself gives me the result I want to get.



Can you help me out of this endless loop:



import arcpy, sys

feature = arcpy.GetParameterAsText(0)
distance = 500

arcpy.gp.overwriteOutput = True

#running NEAR analysis - every point gets attribute of a distance to the nearest point
#in same feature class
arcpy.AddMessage("running first near analysis")
arcpy.Near_analysis(feature, feature)

arcpy.AddMessage("inserting cursor")
cur = arcpy.UpdateCursor(feature)
row = cur.next()

arcpy.AddMessage("starting loop")

i=0
while row:
i+=1
#fids list will store list of deleted points so if any other point will have
#deleted one as the nearest and distance < 150 will not get deleted as this
#distance is no longer true
fids = []
while row:
if row.NEAR_DIST < distance:
try:
#it seems I didn't know if .. in .. at the time ;) such a fun to dig
#this script up! index throws an exception if element is not in the
#list
fids.index(row.NEAR_FID)
arcpy.AddMessage("OBJECTID = " + str(row.OBJECTID) + " is listed!")
except:
arcpy.AddMessage("deleting OBJECTID = " + str(row.OBJECTID))
fids.append(row.FID)
cur.deleteRow(row)
d = 1
row = cur.next()
del cur, row, fids
try:
#this idiotic test is to break the loop when no points will have
#NEAR_DIST < 150, shameful - I know!
if d == 1:
pass
except:
sys.exit()
d = 0
arcpy.AddMessage("loop iteration " + str(i))

#and again we go..
arcpy.Near_analysis(feature, feature)
cur = arcpy.UpdateCursor(feature)
row = cur.next()


The functional CODE:



import arcpy, sys

feature = arcpy.GetParameterAsText(0)

def nearRoutine():
#calculate the distances using the current dataset
arcpy.Near_analysis(feature, feature)

#iterate through any features which are within the distance
cur = arcpy.UpdateCursor(feature, '"NEAR_DIST" < 500')
row1 = cur.next()
while row1:

#this point is within the distance of its neighbor, so delete it
cur.deleteRow(row1)

#now re-run this routine on the new dataset
del row1, cur
cur = arcpy.UpdateCursor(feature, '"NEAR_DIST" < 500')
row1 = cur.next()
nearRoutine

#call the recursive routine. It will get progressively faster to run as it will loop through fewer points each time
nearRoutine()


Thanks @Stephen Lead










share|improve this question
















I took this code from this source Select maximum number of points more than x meters apart



It seems to work for other users, but for me it's an endless loop. I do not understand why, though the code makes sense. The code itself gives me the result I want to get.



Can you help me out of this endless loop:



import arcpy, sys

feature = arcpy.GetParameterAsText(0)
distance = 500

arcpy.gp.overwriteOutput = True

#running NEAR analysis - every point gets attribute of a distance to the nearest point
#in same feature class
arcpy.AddMessage("running first near analysis")
arcpy.Near_analysis(feature, feature)

arcpy.AddMessage("inserting cursor")
cur = arcpy.UpdateCursor(feature)
row = cur.next()

arcpy.AddMessage("starting loop")

i=0
while row:
i+=1
#fids list will store list of deleted points so if any other point will have
#deleted one as the nearest and distance < 150 will not get deleted as this
#distance is no longer true
fids = []
while row:
if row.NEAR_DIST < distance:
try:
#it seems I didn't know if .. in .. at the time ;) such a fun to dig
#this script up! index throws an exception if element is not in the
#list
fids.index(row.NEAR_FID)
arcpy.AddMessage("OBJECTID = " + str(row.OBJECTID) + " is listed!")
except:
arcpy.AddMessage("deleting OBJECTID = " + str(row.OBJECTID))
fids.append(row.FID)
cur.deleteRow(row)
d = 1
row = cur.next()
del cur, row, fids
try:
#this idiotic test is to break the loop when no points will have
#NEAR_DIST < 150, shameful - I know!
if d == 1:
pass
except:
sys.exit()
d = 0
arcpy.AddMessage("loop iteration " + str(i))

#and again we go..
arcpy.Near_analysis(feature, feature)
cur = arcpy.UpdateCursor(feature)
row = cur.next()


The functional CODE:



import arcpy, sys

feature = arcpy.GetParameterAsText(0)

def nearRoutine():
#calculate the distances using the current dataset
arcpy.Near_analysis(feature, feature)

#iterate through any features which are within the distance
cur = arcpy.UpdateCursor(feature, '"NEAR_DIST" < 500')
row1 = cur.next()
while row1:

#this point is within the distance of its neighbor, so delete it
cur.deleteRow(row1)

#now re-run this routine on the new dataset
del row1, cur
cur = arcpy.UpdateCursor(feature, '"NEAR_DIST" < 500')
row1 = cur.next()
nearRoutine

#call the recursive routine. It will get progressively faster to run as it will loop through fewer points each time
nearRoutine()


Thanks @Stephen Lead







python arcmap arcpy point loop






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 2 at 13:38









Hornbydd

27.1k32957




27.1k32957










asked Aug 1 '13 at 13:38









user19717user19717

204




204












  • I really dislike how people use the while loop in arcpy and pyqgis to loop features. It is almost never needed and is error prone. Not your fault as you just copied it. Just a mini rant

    – Nathan W
    Aug 1 '13 at 13:43












  • I agree, @NathanW. It doesn't seem as intuitive to me what is going on. You don't need to use .next() in a for loop, and you have a built in counter with enumerate().

    – Paul
    Aug 1 '13 at 14:56

















  • I really dislike how people use the while loop in arcpy and pyqgis to loop features. It is almost never needed and is error prone. Not your fault as you just copied it. Just a mini rant

    – Nathan W
    Aug 1 '13 at 13:43












  • I agree, @NathanW. It doesn't seem as intuitive to me what is going on. You don't need to use .next() in a for loop, and you have a built in counter with enumerate().

    – Paul
    Aug 1 '13 at 14:56
















I really dislike how people use the while loop in arcpy and pyqgis to loop features. It is almost never needed and is error prone. Not your fault as you just copied it. Just a mini rant

– Nathan W
Aug 1 '13 at 13:43






I really dislike how people use the while loop in arcpy and pyqgis to loop features. It is almost never needed and is error prone. Not your fault as you just copied it. Just a mini rant

– Nathan W
Aug 1 '13 at 13:43














I agree, @NathanW. It doesn't seem as intuitive to me what is going on. You don't need to use .next() in a for loop, and you have a built in counter with enumerate().

– Paul
Aug 1 '13 at 14:56





I agree, @NathanW. It doesn't seem as intuitive to me what is going on. You don't need to use .next() in a for loop, and you have a built in counter with enumerate().

– Paul
Aug 1 '13 at 14:56










3 Answers
3






active

oldest

votes


















0














Disclaimer - I haven't actually tried to run your code, and have only skimmed it briefly.



But it looks like you have two while row loops. Try using two unrelated cursors, eg row1, row2



EDIT: here is an approach which uses a recursive script to perform the NEAR. Each time you delete a point, the NEAR function is called again. (I don't have access to an ArcInfo license so I can't actually test it, so perhaps treat this as pseudo-code):



import arcpy, sys

feature = arcpy.GetParameterAsText(0)
distance = 500

def nearRoutine():
#calculate the distances using the current dataset
arcpy.Near_analysis(feature, feature)

#iterate through any features which are within the distance
cur = arcpy.UpdateCursor(feature, NEAR_DIST < distance)
row = cur.next()
while row:

#this point is within the distance of its neighbor, so delete it
cur.deleteRow(row)

#now re-run this routine on the new dataset
del row, cur
nearRoutine

#call the recursive routine. It will get progressively faster to run as it will loop through fewer points each time
nearRoutine()





share|improve this answer

























  • I was thinking that and because feature never gets redefined so it's doing the same thing over and over

    – Nathan W
    Aug 1 '13 at 13:53






  • 1





    Also, you're deleting the row during the Except clause. It's generally a bad idea to manipulate an array while you're traversing it, since it messes up the indexing (eg, cursor.next is no longer the "next" feature you're expecting)

    – Stephen Lead
    Aug 1 '13 at 13:55











  • I'm sorry I have a very low level programming so your possible solutions are real headache for me. However I believe that the entities that update because when I power the end of the program, it deleted all the fields exactly as I wanted

    – user19717
    Aug 1 '13 at 15:23


















0














Another approach is to use the Simplify Line command. This will remove all extraneous vertices within a given distance, aka "delete point in a distance of x meters"



Esri have already done the hard work of writing this function so you might as well use it...






share|improve this answer






























    0














    import math
    #calculate distance in 2 D
    def distance(a,b) :
    return math.sqrt(pow((a[0]-b[0]),2) + pow((a[1]-b[1]),2) )

    #
    def clean_array2d(array,limit) :
    result = array
    i = 0
    while(i < len(array)) :
    j = 0
    while(j < len(result)) :
    if j != i :
    dist = distance(array[i], result[j])
    if dist < limit :
    result.pop(j)
    j = j + 1
    i = i + 1

    return result
    dist = 10
    arr = [(974, 34), (975, 34), (976, 34)]

    print(clean(arr,dist)) #[(976, 34)]





    share|improve this answer










    New contributor




    The Machine is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.




















      Your Answer








      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "79"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f67633%2fpython-delete-point-in-a-distance-of-x-meters%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      Disclaimer - I haven't actually tried to run your code, and have only skimmed it briefly.



      But it looks like you have two while row loops. Try using two unrelated cursors, eg row1, row2



      EDIT: here is an approach which uses a recursive script to perform the NEAR. Each time you delete a point, the NEAR function is called again. (I don't have access to an ArcInfo license so I can't actually test it, so perhaps treat this as pseudo-code):



      import arcpy, sys

      feature = arcpy.GetParameterAsText(0)
      distance = 500

      def nearRoutine():
      #calculate the distances using the current dataset
      arcpy.Near_analysis(feature, feature)

      #iterate through any features which are within the distance
      cur = arcpy.UpdateCursor(feature, NEAR_DIST < distance)
      row = cur.next()
      while row:

      #this point is within the distance of its neighbor, so delete it
      cur.deleteRow(row)

      #now re-run this routine on the new dataset
      del row, cur
      nearRoutine

      #call the recursive routine. It will get progressively faster to run as it will loop through fewer points each time
      nearRoutine()





      share|improve this answer

























      • I was thinking that and because feature never gets redefined so it's doing the same thing over and over

        – Nathan W
        Aug 1 '13 at 13:53






      • 1





        Also, you're deleting the row during the Except clause. It's generally a bad idea to manipulate an array while you're traversing it, since it messes up the indexing (eg, cursor.next is no longer the "next" feature you're expecting)

        – Stephen Lead
        Aug 1 '13 at 13:55











      • I'm sorry I have a very low level programming so your possible solutions are real headache for me. However I believe that the entities that update because when I power the end of the program, it deleted all the fields exactly as I wanted

        – user19717
        Aug 1 '13 at 15:23















      0














      Disclaimer - I haven't actually tried to run your code, and have only skimmed it briefly.



      But it looks like you have two while row loops. Try using two unrelated cursors, eg row1, row2



      EDIT: here is an approach which uses a recursive script to perform the NEAR. Each time you delete a point, the NEAR function is called again. (I don't have access to an ArcInfo license so I can't actually test it, so perhaps treat this as pseudo-code):



      import arcpy, sys

      feature = arcpy.GetParameterAsText(0)
      distance = 500

      def nearRoutine():
      #calculate the distances using the current dataset
      arcpy.Near_analysis(feature, feature)

      #iterate through any features which are within the distance
      cur = arcpy.UpdateCursor(feature, NEAR_DIST < distance)
      row = cur.next()
      while row:

      #this point is within the distance of its neighbor, so delete it
      cur.deleteRow(row)

      #now re-run this routine on the new dataset
      del row, cur
      nearRoutine

      #call the recursive routine. It will get progressively faster to run as it will loop through fewer points each time
      nearRoutine()





      share|improve this answer

























      • I was thinking that and because feature never gets redefined so it's doing the same thing over and over

        – Nathan W
        Aug 1 '13 at 13:53






      • 1





        Also, you're deleting the row during the Except clause. It's generally a bad idea to manipulate an array while you're traversing it, since it messes up the indexing (eg, cursor.next is no longer the "next" feature you're expecting)

        – Stephen Lead
        Aug 1 '13 at 13:55











      • I'm sorry I have a very low level programming so your possible solutions are real headache for me. However I believe that the entities that update because when I power the end of the program, it deleted all the fields exactly as I wanted

        – user19717
        Aug 1 '13 at 15:23













      0












      0








      0







      Disclaimer - I haven't actually tried to run your code, and have only skimmed it briefly.



      But it looks like you have two while row loops. Try using two unrelated cursors, eg row1, row2



      EDIT: here is an approach which uses a recursive script to perform the NEAR. Each time you delete a point, the NEAR function is called again. (I don't have access to an ArcInfo license so I can't actually test it, so perhaps treat this as pseudo-code):



      import arcpy, sys

      feature = arcpy.GetParameterAsText(0)
      distance = 500

      def nearRoutine():
      #calculate the distances using the current dataset
      arcpy.Near_analysis(feature, feature)

      #iterate through any features which are within the distance
      cur = arcpy.UpdateCursor(feature, NEAR_DIST < distance)
      row = cur.next()
      while row:

      #this point is within the distance of its neighbor, so delete it
      cur.deleteRow(row)

      #now re-run this routine on the new dataset
      del row, cur
      nearRoutine

      #call the recursive routine. It will get progressively faster to run as it will loop through fewer points each time
      nearRoutine()





      share|improve this answer















      Disclaimer - I haven't actually tried to run your code, and have only skimmed it briefly.



      But it looks like you have two while row loops. Try using two unrelated cursors, eg row1, row2



      EDIT: here is an approach which uses a recursive script to perform the NEAR. Each time you delete a point, the NEAR function is called again. (I don't have access to an ArcInfo license so I can't actually test it, so perhaps treat this as pseudo-code):



      import arcpy, sys

      feature = arcpy.GetParameterAsText(0)
      distance = 500

      def nearRoutine():
      #calculate the distances using the current dataset
      arcpy.Near_analysis(feature, feature)

      #iterate through any features which are within the distance
      cur = arcpy.UpdateCursor(feature, NEAR_DIST < distance)
      row = cur.next()
      while row:

      #this point is within the distance of its neighbor, so delete it
      cur.deleteRow(row)

      #now re-run this routine on the new dataset
      del row, cur
      nearRoutine

      #call the recursive routine. It will get progressively faster to run as it will loop through fewer points each time
      nearRoutine()






      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Aug 3 '13 at 21:57

























      answered Aug 1 '13 at 13:50









      Stephen LeadStephen Lead

      14.2k1281188




      14.2k1281188












      • I was thinking that and because feature never gets redefined so it's doing the same thing over and over

        – Nathan W
        Aug 1 '13 at 13:53






      • 1





        Also, you're deleting the row during the Except clause. It's generally a bad idea to manipulate an array while you're traversing it, since it messes up the indexing (eg, cursor.next is no longer the "next" feature you're expecting)

        – Stephen Lead
        Aug 1 '13 at 13:55











      • I'm sorry I have a very low level programming so your possible solutions are real headache for me. However I believe that the entities that update because when I power the end of the program, it deleted all the fields exactly as I wanted

        – user19717
        Aug 1 '13 at 15:23

















      • I was thinking that and because feature never gets redefined so it's doing the same thing over and over

        – Nathan W
        Aug 1 '13 at 13:53






      • 1





        Also, you're deleting the row during the Except clause. It's generally a bad idea to manipulate an array while you're traversing it, since it messes up the indexing (eg, cursor.next is no longer the "next" feature you're expecting)

        – Stephen Lead
        Aug 1 '13 at 13:55











      • I'm sorry I have a very low level programming so your possible solutions are real headache for me. However I believe that the entities that update because when I power the end of the program, it deleted all the fields exactly as I wanted

        – user19717
        Aug 1 '13 at 15:23
















      I was thinking that and because feature never gets redefined so it's doing the same thing over and over

      – Nathan W
      Aug 1 '13 at 13:53





      I was thinking that and because feature never gets redefined so it's doing the same thing over and over

      – Nathan W
      Aug 1 '13 at 13:53




      1




      1





      Also, you're deleting the row during the Except clause. It's generally a bad idea to manipulate an array while you're traversing it, since it messes up the indexing (eg, cursor.next is no longer the "next" feature you're expecting)

      – Stephen Lead
      Aug 1 '13 at 13:55





      Also, you're deleting the row during the Except clause. It's generally a bad idea to manipulate an array while you're traversing it, since it messes up the indexing (eg, cursor.next is no longer the "next" feature you're expecting)

      – Stephen Lead
      Aug 1 '13 at 13:55













      I'm sorry I have a very low level programming so your possible solutions are real headache for me. However I believe that the entities that update because when I power the end of the program, it deleted all the fields exactly as I wanted

      – user19717
      Aug 1 '13 at 15:23





      I'm sorry I have a very low level programming so your possible solutions are real headache for me. However I believe that the entities that update because when I power the end of the program, it deleted all the fields exactly as I wanted

      – user19717
      Aug 1 '13 at 15:23













      0














      Another approach is to use the Simplify Line command. This will remove all extraneous vertices within a given distance, aka "delete point in a distance of x meters"



      Esri have already done the hard work of writing this function so you might as well use it...






      share|improve this answer



























        0














        Another approach is to use the Simplify Line command. This will remove all extraneous vertices within a given distance, aka "delete point in a distance of x meters"



        Esri have already done the hard work of writing this function so you might as well use it...






        share|improve this answer

























          0












          0








          0







          Another approach is to use the Simplify Line command. This will remove all extraneous vertices within a given distance, aka "delete point in a distance of x meters"



          Esri have already done the hard work of writing this function so you might as well use it...






          share|improve this answer













          Another approach is to use the Simplify Line command. This will remove all extraneous vertices within a given distance, aka "delete point in a distance of x meters"



          Esri have already done the hard work of writing this function so you might as well use it...







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Aug 2 '13 at 6:23









          Stephen LeadStephen Lead

          14.2k1281188




          14.2k1281188





















              0














              import math
              #calculate distance in 2 D
              def distance(a,b) :
              return math.sqrt(pow((a[0]-b[0]),2) + pow((a[1]-b[1]),2) )

              #
              def clean_array2d(array,limit) :
              result = array
              i = 0
              while(i < len(array)) :
              j = 0
              while(j < len(result)) :
              if j != i :
              dist = distance(array[i], result[j])
              if dist < limit :
              result.pop(j)
              j = j + 1
              i = i + 1

              return result
              dist = 10
              arr = [(974, 34), (975, 34), (976, 34)]

              print(clean(arr,dist)) #[(976, 34)]





              share|improve this answer










              New contributor




              The Machine is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.
























                0














                import math
                #calculate distance in 2 D
                def distance(a,b) :
                return math.sqrt(pow((a[0]-b[0]),2) + pow((a[1]-b[1]),2) )

                #
                def clean_array2d(array,limit) :
                result = array
                i = 0
                while(i < len(array)) :
                j = 0
                while(j < len(result)) :
                if j != i :
                dist = distance(array[i], result[j])
                if dist < limit :
                result.pop(j)
                j = j + 1
                i = i + 1

                return result
                dist = 10
                arr = [(974, 34), (975, 34), (976, 34)]

                print(clean(arr,dist)) #[(976, 34)]





                share|improve this answer










                New contributor




                The Machine is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.






















                  0












                  0








                  0







                  import math
                  #calculate distance in 2 D
                  def distance(a,b) :
                  return math.sqrt(pow((a[0]-b[0]),2) + pow((a[1]-b[1]),2) )

                  #
                  def clean_array2d(array,limit) :
                  result = array
                  i = 0
                  while(i < len(array)) :
                  j = 0
                  while(j < len(result)) :
                  if j != i :
                  dist = distance(array[i], result[j])
                  if dist < limit :
                  result.pop(j)
                  j = j + 1
                  i = i + 1

                  return result
                  dist = 10
                  arr = [(974, 34), (975, 34), (976, 34)]

                  print(clean(arr,dist)) #[(976, 34)]





                  share|improve this answer










                  New contributor




                  The Machine is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.










                  import math
                  #calculate distance in 2 D
                  def distance(a,b) :
                  return math.sqrt(pow((a[0]-b[0]),2) + pow((a[1]-b[1]),2) )

                  #
                  def clean_array2d(array,limit) :
                  result = array
                  i = 0
                  while(i < len(array)) :
                  j = 0
                  while(j < len(result)) :
                  if j != i :
                  dist = distance(array[i], result[j])
                  if dist < limit :
                  result.pop(j)
                  j = j + 1
                  i = i + 1

                  return result
                  dist = 10
                  arr = [(974, 34), (975, 34), (976, 34)]

                  print(clean(arr,dist)) #[(976, 34)]






                  share|improve this answer










                  New contributor




                  The Machine is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.









                  share|improve this answer



                  share|improve this answer








                  edited Apr 2 at 13:52





















                  New contributor




                  The Machine is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.









                  answered Apr 2 at 13:31









                  The MachineThe Machine

                  11




                  11




                  New contributor




                  The Machine is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.





                  New contributor





                  The Machine is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.






                  The Machine is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Geographic Information Systems Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f67633%2fpython-delete-point-in-a-distance-of-x-meters%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      រឿង រ៉ូមេអូ និង ហ្ស៊ុយលីយេ សង្ខេបរឿង តួអង្គ បញ្ជីណែនាំ

                      QGIS export composer to PDF scale the map [closed] Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?Print Composer QGIS 2.6, how to export image?QGIS 2.8.1 print composer won't export all OpenCycleMap base layer tilesSave Print/Map QGIS composer view as PNG/PDF using Python (without changing anything in visible layout)?Export QGIS Print Composer PDF with searchable text labelsQGIS Print Composer does not change from landscape to portrait orientation?How can I avoid map size and scale changes in print composer?Fuzzy PDF export in QGIS running on macSierra OSExport the legend into its 100% size using Print ComposerScale-dependent rendering in QGIS PDF output

                      PDF-ში გადმოწერა სანავიგაციო მენიუproject page