Select to view content in your preferred language

Replacing Data Between Fields in an Attribute Table Based on a Word

342
5
Jump to solution
11-26-2024 01:46 PM
GISJess
Frequent Contributor

I have a field in a Plant layer called 'Plant Species' and another field called 'Other Plant Species'. The 'Plant Species' field has domains for a variety of plant names, with an 'Other' option at the end of the list. The 'Other Plant Species' is a string type-in that will conditionally pop up when 'Other' is selected in the Field Maps app. 

Our field work is now done with, and now I would like to replace the any of the 'Other' attributes in the 'Plant Species' field, with the corresponding type-in option in the 'Other Plant Species' field in ArcGIS Pro. 

How do I do this in Python? I feel like I have seen a script in Python for this before, but I cannot find it. If you can help me out with providing generic script, that would be so helpful. Thanks!

0 Kudos
1 Solution

Accepted Solutions
marksm_macomb
Frequent Contributor

Hi,

It sounds like you can do this with a simple field calculation. Select all records where "Plant Species" = "Other" first, then right click on the "Plant Species" field, choose calculate field. Then double click on the "Other Plant Species" field from the options in the calculate field pane and that should do it.

View solution in original post

5 Replies
Eugene_Adkins
Frequent Contributor

Maybe this link will help you. 

0 Kudos
marksm_macomb
Frequent Contributor

Hi,

It sounds like you can do this with a simple field calculation. Select all records where "Plant Species" = "Other" first, then right click on the "Plant Species" field, choose calculate field. Then double click on the "Other Plant Species" field from the options in the calculate field pane and that should do it.

GISJess
Frequent Contributor

Thank you, I totally have done this before, but for some reason was thinking it was via a script. I was making it way more complicated than it needed to be! Thanks for your response!

rmatthewman
Emerging Contributor

This can be a fairly simple field calculation - but you will either need to remove the domain from Plant Species or add all unique values in Other Plant Species to the domain.

The arcade calculation would look something like:

iif($feature.PlantSpecies == 'Other', $feature.OtherPlantSpecies, $feature.PlantSpecies)

Which tells the field calculator to replace 'Other' with the corresponding value in OtherPlantSpecies for that feature, or leave the value alone if it is not equal to Other. 

Or you could just select by attribute Where PlantSpecies Is Other and field calculate $OtherPlantSpecies. Since you're only differentiating one unique value in the PlantSpecies field, it doesn't make too much of a difference/change the time needed. 6 of one and half dozen of the other; just make sure you have the rows you want re-calculated selected or you will re-populate all of them. 

rmatthewman
Emerging Contributor

To clarify: When you right-click -> Field Calculate on the PlantSpecies field, insert the code snippet with the proper field names changed out. If you haven't used Arcade, I really reccomend getting familiar with it. It's fairly intuitive and already treats attribute tables as lists to loop through. 

0 Kudos