I am working on a file GDB containing polygons with multiple fields and values. One of the text fields of that GDB is filled by applying a python script that uses the information of many other fields to generate the text values.
That script works very well, but I need to add an exclusion rule at the beginning so it will not be applied on certain polygons based on specific values from a certain field (the goal is not to overwrite the values of those polygons which values are gonna be manually written before running the script).
In applied words, the script gives an Ecosystem name for each polygon based on biological and geomorphological field values, but I don't want the script to be processed on polygons that contains validation data from a certain source. In that case, it means I don't want it to be processed when the ''Validation'' field equals 4 specific values (which are specific sources of validation), because those Ecosystem names have to and are written manually before running the script and I don't want to overwrite them. (See the screenshot I've joined)
I should specify that I am not the one that wrote the script initially. The person left so I need to find my way around and I am a complete beginner in python scripting. I was hoping someone could give me a hand and tell me if there is a straightforward way for this. Thank you!!!
Post your code with formatting if you could
Reading from a screen grab is difficult.
It appears you have some encoding issues. Is this line at the top of your script?
# -*- coding: utf-8 -*-
and are doing this in arcgis pro with python 3? a separate python IDE?
anything useful to your environment would help
Hi Dan !
Thanks for your answer and your help. Actually, ideally I'm not willing to change the content of the actual script which works well and I'm affraid I would mess it. If it is possible, I would only want a line of code code at the beginning that will exclude some polygons (lines in the attribute fields) for which the code will generate a value (and leave the name of the Ecosystem as it is). In this case, It means that all polygons for which Valid_terr = "UQAR 2018 et IML2018 (à venir)" would not have their Ecosystem names overwritten.
I'm working in ArcMAp 10.7 and I run the code in the attribut table with the Field calculator (after having joined the domain tables by right clicking on my feature class layer > Join and relate > Join). The code was written in an external python IDE (like PythonWin or NotePadd++ I don't know exactly.
Maybe the answer of my question cannot be as straightforward as I think it can !;P
Let me know if you still think I should post my code on Code Formatting! I clicked on your link, i'm not sure, is it an other forum specifically for code questions or it's a place to put my script relate from my post here?
One thing to keep in mind is that when you run any tool on a layer or table vies it only applies to the selected set of rows. So if the polygon code that is "filling values" is working on a layer, you can apply a selection to the layer or table view before executing your script.
That would have been a good tip, but I want it to be part of the script, because other people in time will be applying it and I don't want to risk to overwrite anything. But thanks for your answer! ;)
The link I posted shows your you post code in your questions.
It is the only way to really see whether there are syntax and/or formatting errors and you can scroll up and down within a thread to look at code but you can't do that when an image is posted.
Your screenshot shows how the variable "ecosystem" is calculated, but not how it is written into the feature class.
I understand that you don't want to post the whole script, but to help you, we need to know how the field is written.
Please tell us:
Please look for code blocks that include any of the following and post them: