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

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

                      Crop image to path created in TikZ? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)Crop an inserted image?TikZ pictures does not appear in posterImage behind and beyond crop marks?Tikz picture as large as possible on A4 PageTransparency vs image compression dilemmaHow to crop background from image automatically?Image does not cropTikzexternal capturing crop marks when externalizing pgfplots?How to include image path that contains a dollar signCrop image with left size given

                      Romeo and Juliet ContentsCharactersSynopsisSourcesDate and textThemes and motifsCriticism and interpretationLegacyScene by sceneSee alsoNotes and referencesSourcesExternal linksNavigation menu"Consumer Price Index (estimate) 1800–"10.2307/28710160037-3222287101610.1093/res/II.5.31910.2307/45967845967810.2307/2869925286992510.1525/jams.1982.35.3.03a00050"Dada Masilo: South African dancer who breaks the rules"10.1093/res/os-XV.57.1610.2307/28680942868094"Sweet Sorrow: Mann-Korman's Romeo and Juliet Closes Sept. 5 at MN's Ordway"the original10.2307/45957745957710.1017/CCOL0521570476.009"Ram Leela box office collections hit massive Rs 100 crore, pulverises prediction"Archived"Broadway Revival of Romeo and Juliet, Starring Orlando Bloom and Condola Rashad, Will Close Dec. 8"Archived10.1075/jhp.7.1.04hon"Wherefore art thou, Romeo? To make us laugh at Navy Pier"the original10.1093/gmo/9781561592630.article.O006772"Ram-leela Review Roundup: Critics Hail Film as Best Adaptation of Romeo and Juliet"Archived10.2307/31946310047-77293194631"Romeo and Juliet get Twitter treatment""Juliet's Nurse by Lois Leveen""Romeo and Juliet: Orlando Bloom's Broadway Debut Released in Theaters for Valentine's Day"Archived"Romeo and Juliet Has No Balcony"10.1093/gmo/9781561592630.article.O00778110.2307/2867423286742310.1076/enst.82.2.115.959510.1080/00138380601042675"A plague o' both your houses: error in GCSE exam paper forces apology""Juliet of the Five O'Clock Shadow, and Other Wonders"10.2307/33912430027-4321339124310.2307/28487440038-7134284874410.2307/29123140149-661129123144728341M"Weekender Guide: Shakespeare on The Drive""balcony"UK public library membership"romeo"UK public library membership10.1017/CCOL9780521844291"Post-Zionist Critique on Israel and the Palestinians Part III: Popular Culture"10.2307/25379071533-86140377-919X2537907"Capulets and Montagues: UK exam board admit mixing names up in Romeo and Juliet paper"Istoria Novellamente Ritrovata di Due Nobili Amanti2027/mdp.390150822329610820-750X"GCSE exam error: Board accidentally rewrites Shakespeare"10.2307/29176390149-66112917639"Exam board apologises after error in English GCSE paper which confused characters in Shakespeare's Romeo and Juliet""From Mariotto and Ganozza to Romeo and Guilietta: Metamorphoses of a Renaissance Tale"10.2307/37323537323510.2307/2867455286745510.2307/28678912867891"10 Questions for Taylor Swift"10.2307/28680922868092"Haymarket Theatre""The Zeffirelli Way: Revealing Talk by Florentine Director""Michael Smuin: 1938-2007 / Prolific dance director had showy career"The Life and Art of Edwin BoothRomeo and JulietRomeo and JulietRomeo and JulietRomeo and JulietEasy Read Romeo and JulietRomeo and Julieteeecb12003684p(data)4099369-3n8211610759dbe00d-a9e2-41a3-b2c1-977dd692899302814385X313670221313670221