Attribute tables in ArcGIS are not nearly as easily editable in comparison to something like Excel.

For example, you have sorted the table based on some column value, and now want to fill in the column beside it with 2,4,6,8... etc. descending. In Excel this is extremely easy - just start the pattern, highlight it and drag down. Done.

If I wanted to do something like this natively in ArcGIS, from what I know of ArcGIS, python scripting is required.

Of course I could also look at the table through Access/Excel/some spreadsheet, and do the operation from there much easier, save it, and open it back up in ArcGIS.

However, ESRI does not officially recommend such tricks.

Really, it would just be great if attribute tables in ArcGIS (and all GIS for that matter) had the same type of editability as Excel, but I'm sure there are many spatial database issues with even beginning to think about implementing such a concept.

So is the "best practice" for filling in patterns into tables really using python scripting?

I can write python scripts, but have a harder time managing what I've done in the past (maybe I just need to get better at storing "common" scripts?).

Or is there officially recommended ways that avoid scripting by using tools/extensions in ArcGIS, or some other software?

  • 2
    See also this ArcGIS Ideas post: ideas.arcgis.com/ideaView?id=087300000008JMcAAM – blah238 Aug 1 '12 at 22:55
  • I've always been very frustrated that it isn't possible to reference previous rows in Calculate Field the same (incredibly easy) way you can in Excel. Adding the formula functionality that Excel has ( C4=(C3-B4)/2) would be incredible. – AlmaThom Aug 1 '12 at 23:00
  • 4
    Fundamentally the difference between Excel and ArcGIS is Excel is a spreadsheet application where data is not strongly typed and data consistency is not enforced in any way. Whereas ArcGIS has to deal with many other types of databases and data consistency is of upmost importance. That's why it doesn't behave like Excel, and to many people that's a good thing. That said, without a doubt, many user interface improvements could be made without sacrificing data consistency/integrity. – blah238 Aug 2 '12 at 0:18
  • makes sense - good way to put it – youzer Aug 2 '12 at 18:04

You can select some rows and right-click the field you want to populate and click Calculate Field. For a small to medium number of features/rows, I would suggest doing this within an edit session so that you can undo/redo.

Then enter an expression (in either VBScript or Python syntax) and click OK.

More here: Making simple field calculations.

| improve this answer | |
  • hi blah238, I have found the field calculator to be valuable in much previous work - but I have never used it to calculate field values that change based on other values in the same column. Specifically, how would I use it to execute my original example? (Its quite likely that I just don't know something I should about field calculator) – youzer Aug 2 '12 at 17:56
  • For your specific example you would use a global variable. See the "Calculate a sequential ID or number based on an interval" example under Accumulative and sequential calculations on the Calculate Field examples page. – blah238 Aug 3 '12 at 21:29

There are a couple of ways that you can use a cursor in ArcGIS to calculate field values from a python script: InsertCursor and UpdateCursor. These methods give you the ability to either insert (create a value) or update (change the value) depending on what is going on in your dataset. ArcGIS Desktop help has a couple of wonderful examples for that application and you can try it out in the interactive Python window to see how it works.

Additionally, you can use Python from the Calculate Field to do the same thing for multiple rows using a definition function. In the graphic below I did a simple conversion for DD to sq. meters (the math may be off) which should help you see how to use the field calculator with Python to get that excel like functionality.

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.