I have a series of x,y co-ordinates converted from a .ply file. I was able to extract the file into a suitable x,y format for arcmap, the issue I have is that they are co-ordinate points representing 90 polygons. So in arcmap I have the coordinates for polygon 1, then a series of null rows, then co-ordinates for poly 2 etc. I have been manually entering the polygon number using field calculator but with 91 it is taking me a long time, so I thought I could use the sequential calculations script. Each null row is the same number of rows between each poly (7). so what I need is a script that will update a field with polygon 1, skips 7 null field rows, poly 2, etc etc.

The other issue is that the number of points in each polygon is different, so the only way to differentiate each polygon is the null rows in between.

I meant this script in particular


Accumulative and sequential calculations

enter image description here

  • I should add, I need to then convert these points into polygons based on their IDs
    – Sylvia N
    Nov 18, 2015 at 0:22
  • A screenshot of the table would be helpful.
    – ianbroad
    Nov 18, 2015 at 2:39
  • I think you'd have more success using an Update Cursor rather than using the field calculator. Keep a running count and if you encounter a null value, don't update the field, but increase your count. When you hit the next row with a value, update with that count number and so on.
    – Fezter
    Nov 18, 2015 at 4:57
  • Also, converting these points into polygons should be posted as a separate question, however, I believe you'll find answers to that on this site already.
    – Fezter
    Nov 18, 2015 at 4:58
  • This seems like an unusual task. Why are there always 7 null points in your feature class between point features (future polygon vertices maybe?)? It would probably save you a lot of headache in the future if you skipped this temporary dataset (I'm assuming) and went straight to polygons from your .ply file.
    – Paul
    Nov 18, 2015 at 7:12

2 Answers 2


Here's one way to number the polygons:

import arcpy

fc = "C:\\temp\\data.gdb\\points"

polygon = 1
nulls = 0

with arcpy.da.UpdateCursor(fc, ("x", "Polygon")) as cursor:
    for row in cursor:

        if row[0] is not None:
            row[1] = polygon

            nulls += 1

            if nulls == 7:
                polygon += 1
                nulls = 0

Change the fc variable to the location of your point feature class. You can run this right in the Python window in ArcMap.

  • I actually finished doing it manually.
    – Sylvia N
    Nov 18, 2015 at 5:37

You can do this with an arcpy update cursor. Below is a little script that should take care of it. It assumes Polygon is a numerical field, like an integer field. Basically, it assigns a fixed number whenever it sees x data, and increments that number when it sees the next Null value for x, waiting to use that new number until it sees x data again.

import arcpy

featureClass = "C:\\path\\to\\your\\geodatabase_and\\featureclass"

fields = ("x", "y", "Polygon")

with arcpy.da.UpdateCursor(featureClass, fields) as cursor:

    aUniqueID = 1
    frozen = False

    for row in cursor:

        if row[0]:
            if frozen:
                frozen = False
            row[2] = aUniqueID     

        if not row[0]:
            if not frozen:
                aUniqueID += 1
                frozen = True

  • A few suggestions: Use is/is not to check for None (see here for why). Similarly, boolean checking in python means that you don't need to check with ==. Just simply if freeze and if not freeze.
    – Paul
    Nov 18, 2015 at 7:16
  • Thanks @Paul - good points. Edited. Habits carrying over from Java :) Nov 18, 2015 at 23:02

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.