Select to view content in your preferred language

Adding sequential numbers for the selected features

1256
5
Jump to solution
01-17-2024 11:41 AM
Labels (3)
YuvarajuDhananjay
Emerging Contributor

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
Esteemed 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
Regular Contributor

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
Emerging Contributor

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
Esteemed 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