Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have to check an attribute table field (MY ID NO) of polygon feature against a tiff image of parcel map where fields are written as 12-58,65,87,2565-89999,58648.

Example: Parcel map tiff(image) contains plot no (MY ID NO in poly feature's attribute table) against each plot, each tiff has a corner box that describe the plot numbers included in this tiff map. Now I have to check is all the opposite plot no (collected from tiff image file, and also mentioned in the corner-box describing included plot no) is populated in the MY ID NO field.

Now I want a field calculator script (I think it is easy and better way to check, suggestions also preferred) to populate "Sorted Range" field. I need only "Sorted Range" field. My table as below:

Portion of Attribute Table

share|improve this question
I'm not certain what your diagram indicates - are you saying that you do not want the first two column values changed and that you want the values indicated written to the third column in the order indicated? If so, I don't think Field Calculator will do it but a Python Script tool would have no trouble. – PolyGeo Jan 24 '13 at 7:08
First column(MY ID NO) is my data input, second column (Range) is unnecessary but shown here to get the idea what i need.I need only third column (Sorted Range) – SIslam Jan 24 '13 at 9:30
Are you wanting to sort first and then drop out all but the first and last members of any consecutive sets of numbers? – PolyGeo Jan 24 '13 at 9:33
yes, first and last for consecutive sets plus single for single member set (e.g. 258 in the image)please see the update of question for scenerio, i want this "Sorted Range" field for checking only, this field will be deleted after check. – SIslam Jan 24 '13 at 9:55
Are you using ArcGIS 10.0 or 10.1? I'm thinking new arcpy.da cursors will work faster than old arcpy cursors - and would prefer to code in 10.1. – PolyGeo Jan 24 '13 at 10:13

Take a look at the Sort tool, which is available at ArcInfo level, it will do exactly what you need/ There are also several other questions you may want to look at which point out issues you might experience when sorting the table.

share|improve this answer
@ Arabella, i do not want sorting only, but dropping out the values between ranges(highest-lowest) for consecutive set of three or more then three menmbers and eaxctly the members for set of one &/or two member-sets. The purpose is only for check as specified in the example – SIslam Jan 24 '13 at 12:38

This Python code should do it ...

import arcpy

valueList = []
rows = arcpy.SearchCursor(r"C:\Temp\test.gdb\test")
for row in rows:
valueList = sorted(valueList)
del row,rows
print valueList

firstValue = valueList[0]
lastValue = valueList[len(valueList) - 1]
prevValue = firstValue
potentialEndRangeValue = firstValue
rangeSize = 0

rangeValueList = []
for value in valueList:
    if value == firstValue:
        # Always print first value
    elif value == lastValue:
        # Always print last value
        if rangeSize > 0:
            # This is when last Value is NOT end of a range
        if value - prevValue > 1:
            # This indicates a gap since last value
            if rangeSize > 0:
            if value != lastValue:
            rangeSize = 0
        prevValue = value
        potentialEndRangeValue = value
print rangeValueList

rows = arcpy.UpdateCursor(r"C:\Temp\test.gdb\test")
row =
for rangeValue in rangeValueList:
    row.Sorted_Range = rangeValue
    row =

del row,rows
share|improve this answer
Thanks PolyGeo, i will try this stand-alone python script.But is there any field calculator method? – SIslam Jan 26 '13 at 4:58
If there is a way to do it using Field Calculator then I do not know it. – PolyGeo Jan 26 '13 at 5:50
Thanks a lot for your kind regards. – SIslam Jan 26 '13 at 6:06

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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