0

I have some polygons and want to convert each polygon to a series of points. I use "feature vertices to points". Here is the result.

The Farm ID field has SCAPD01-1 polygon and it has 190 points. I want SCAPD01-10 polygon, the number point start from 1 not 191.. And it should store point ID numbers in the Point field

enter image description here

Son of a Beach
  • 8,182
  • 1
  • 17
  • 33
tamara
  • 63
  • 4

1 Answers1

0

Let's say you created a new field for this purpose called "Point". You should be able to use the 'Calculate Field' to generate unique IDs sequentially for each group (according to a grouping field such as 'FarmID') by doing something like this:

  • Right-click the column header for the Point field (or whatever your point ID field is called) and choose 'Field Calculator'
  • In the Calculate Field's 'Code Block' parameter, enter:
idGroups = {}
def calculateIDs(groupID):
    global idGroups
    if groupID in idGroups:
        idGroups[groupID] += 1
    else:
        idGroups[groupID] = 1
    return idGroups[groupID]
  • In the Calculate Field's 'Point' parameter (or whatever your point ID field is called), enter:
calculateIDs(!FarmID!)

(double click the 'FarmID' field to enter it correctly)

  • Click the Calculate Field's 'Apply' button (or 'OK' button)

NB: This is entirely untested. I just made it up off the top of my head.

Son of a Beach
  • 8,182
  • 1
  • 17
  • 33
  • thanks. but when I try this python, there was a failure during processing. – tamara Jul 11 '22 at 06:29
  • It says:

    ERROR 000539. Error running expression: calculate("SCAPD01-1") Traceback (most recent call last): File"", line 1, in File"", line 4, in calculateID KeyError: 'SCAPD01-1'

    – tamara Jul 11 '22 at 06:36
  • hii thanks a lot for the help.. it is very helpful – tamara Jul 11 '22 at 06:45