I am trying to use field calculator to number points between -700 and 700. I have used this code block:
rec=0
def autoIncrement():
global rec
pStart = 700
pInterval = -1
if (rec == 0):
rec = pStart
else:
rec += pInterval
return rec
which works great, but only numbers between 700 and 0, but I would like it to number all the way to -700 before starting over. Is this possible with this approach or do I need to try a different method?
-
Try divmod or % operator on autoincremented value and 1400-resultFelixIP– FelixIP2017年04月25日 20:18:35 +00:00Commented Apr 25, 2017 at 20:18
-
Sorry, I'm new to this - I'm not sure I understand what you mean by this, could you explain further?miss_lilly_belle– miss_lilly_belle2017年04月26日 16:59:52 +00:00Commented Apr 26, 2017 at 16:59
1 Answer 1
Assuming you have 1401 points to number and you are trying to autodecrement, try the code below:
rec=-700
def autoIncrement():
global rec
pStart = 700
pInterval = 1
if (rec == -700):
rec = pStart
else:
rec -= pInterval
return rec
I should say though, this is an easy fix, not a proper solution to your problem or possible derivatives!
-
This did what I needed and was more 'proper' than the clunky temporary solution I came up with. Thanks!miss_lilly_belle– miss_lilly_belle2017年04月26日 17:00:40 +00:00Commented Apr 26, 2017 at 17:00
Explore related questions
See similar questions with these tags.