Select to view content in your preferred language

calculate field

413
4
02-15-2024 04:17 AM
Labels (1)
itayroei
New Contributor

Hi dear community.

I need to accumalate value of one field by order of other field.

I sucsses to accumlate value but the order detaramine by "OBJECTID"

who can i change that?

thanks

itay

 

Tags (1)
0 Kudos
4 Replies
PedroCoutinhoMendonça
New Contributor II

Hello Itay! You can use update cursor in python do achieve what you want. In the sql_clause parameter there is one exemple of the epression used with ORDER BY

 

https://pro.arcgis.com/en/pro-app/3.1/arcpy/data-access/updatecursor-class.htm 

 

 

with arcpy.da.UpdateCursor(
        in_features, 
        ['OID@', "ELEVATION"], 
        sql_clause=("TOP 5", "ORDER BY ELEVATION DESC")
) as cur:

 

0 Kudos
itayroei
New Contributor

thank you pedro

i will try your solution

hopes that it's work for me

best regards

itay

0 Kudos
Amir-Sarrafzadeh-Arasi
Occasional Contributor

Dear itayroei,

I hope you are doing well,

 

If you are using ArcGIS Pro, you can do by this way, insert a New Notebook,

and write the python script like below image,

 

AmirSarrafzadehArasi_0-1708004265476.png

Here I read the Airports feature layer as a Pandas DataFrame, you should put your feature layer's name.

Then I have sorted by scale value, which you should put the name of the column which you want to sort the dataframe, and then create a new column which is accumaled values of size column which you should put yours.

If need more info please let me know.

 

Hope it works,

Best Wishes

 

 

Amir Sarrafzadeh Arasi
itayroei
New Contributor

thank you Amir

i will try your solution in sundey and let you knew if it's work for me

good weekend

itay

0 Kudos