Adding sequential numbers for the selected features

617
5
Jump to solution
01-17-2024 11:41 AM
YuvarajuDhananjay
New Contributor II

I need sequential numbers(1,2,3...) for the selected features in the particular feild in attribute table, how to do it?

0 Kudos
2 Solutions

Accepted Solutions
Bud
by
Notable Contributor

What kind of geodatabase?


If it's a mobile or enterprise geodatabase, it could be done in a SQL database view. And then you could join from the FC to the view and use the field calculator to populate the ID field in the FC.

Mobile geodatabase (SQLite):

select
    c.*,
    row_number() over (order by population_2021 desc) as sorted_id
from
    cities c

 

(File geodatabases don't have a row_number() function.)


If it's a file geodatabase (or any kind of geodatabase), you could use the Sort geoprocessing tool in conjunction with a join.

Like this:

In hindsight, I could have joined on Objectid=OrigFID, instead of using my temp_unique_id field.

ArcGIS Pro 3.2.1

View solution in original post

5 Replies
Raul
by
New Contributor III

Check out this arcticle by ESRI Support, It's for ArcMap but it still works in pro! You can modify the python code to fit your needs :).

https://support.esri.com/en-us/knowledge-base/how-to-create-sequential-numbers-in-a-field-in-arcmap-...

If you want something more simple, calculate your field equal to the ObjectID

0 Kudos
YuvarajuDhananjay
New Contributor II

this sequential number() is working based on OBJECTID, but I need the numbers without using OBJECTID in just sequential manner how my order is on the attribute table?

0 Kudos
Bud
by
Notable Contributor

What kind of geodatabase?


If it's a mobile or enterprise geodatabase, it could be done in a SQL database view. And then you could join from the FC to the view and use the field calculator to populate the ID field in the FC.

Mobile geodatabase (SQLite):

select
    c.*,
    row_number() over (order by population_2021 desc) as sorted_id
from
    cities c

 

(File geodatabases don't have a row_number() function.)


If it's a file geodatabase (or any kind of geodatabase), you could use the Sort geoprocessing tool in conjunction with a join.

Like this:

In hindsight, I could have joined on Objectid=OrigFID, instead of using my temp_unique_id field.

ArcGIS Pro 3.2.1