Here is what I am trying to do -
I have a point feature class, in the feature class there is a field called
AdjRate. If the values in that field are > 0 then do one set of
geoprocessing, if the values are = 0 then use an alternate set of geoprocessing
functions. I have found several example scripts with IF THEN STATEMENTS
for model builder, but nothing like this. So far all I can find are examples
for checking if an extension exists etc... I know this must be super easy for
people who know python, but unfortunately I don't. I am trying to learn, but
need to figure this out before I have time. All you geniuses out there please
help! THANK YOU!
so you saw this? Using If-Then-Else logic for branching—Help | ArcGIS for Desktop and the parts way down at the bottom of the page?
If you are stuck at "if" – Part 1 | ArcGIS Blog and nothing helped? perhaps, you need to provide your syntax for your query
Hi, First thank you for responding - and yes -I have read this - several time - I think that's where my limitations in python are really showing. I have downloaded the example tool boxes as well. I tried to understand and copy those pieces - but I think i am so limited that i am not even sure which arcpy function to call - here is an example of what I mean -
def x(InputFeatureClass): import arcpy desc = arcpy.Describe(InputFeatureClass) type = desc.shapeType I - where it reads arcpy.Describe(InputFeatureclass) type - I think I need a different function here - but maybe I don't - I would post the code block, but I don't even have enough in it to post really . That's how little I know.
so here is what i have so far - and I havent a clue if this is even near correct
desc = arcpy.Describe(AttributeToCheck) - not sure what would go here
RateValue = desc.datatype - I have no idea what would go hear either
if Rate > 60000:
The field is already in the feature class - if the field is > 0 I want to process the data down path a, if the value is = 0 I want to process down path b - I did get a little bit further-
But not sure where to go from here....
you have 3 different spellings of AttributeToCheck
also it will return No Tgt Rate if it is < 0 ... if that is ok
otherwise it is going to return a string "false" make sure it needs a string because a boolean is either False or True with capital letters and no quotes.
Beyond that , I am not sure what it does
What is the purpose of getting unique values? Do you intend to do some kind of iteration? What would you iterate? Without iteration I do not think you need If Then logic at all.
For problems like this I normally start the script with the shape file, use the Make Feature Layer tool to convert it to a Layer, use the Select Layer By Attribute tool with a selection expression of "FIELD" > 0, do the processing on those records, then Select Layer By Attributes with a selection expression of "FIELD" <=0 or "FIELD" IS NULL and do the other processing. ("FIELD" is any actual field name of an existing numeric field).
This does give me some ideas on a different approach. Yes, I do need to iterate the files - there will be hundreds of files like this. I THINK i need to iterate anyway. Essentially each file comes to me in the same format. A shapefile with several attributes. The name of the shapefile is irrelevant. There is a field in the shapefile that will have a an average of > 90 - these files will be soybean, then a second field (Tgt_Rate_s) is checked for average =<1. These will not get a QC check because they lack the necessary data to do so. If this Tgt_Rate_s average is > 1 then the qc process will be run. Once the QC process has run then IDW occurs. This happens for every shapefile. If its not soybean its then classified as corn and will have different processes that run. I have 4 models that work right now. For each of these. However right now, I have to check the fields, move each "type", corn vs soy then Tgt_rate_s (yes or now) - ending up with 4 folders. Then I use the appropriate model and iterate the shapefiles in the respective folder. My goal was to combine the processes so that I could just choose the files to iterate and not worry about separating into 4 different folders first. Thanks so much for all of the suggestions and help. My model that works is pasted below. There is a lot in the model around selecting a field boundary and setting as a mast as well. Thanks!
ModelBuilder is a waste of time frankly for what you want to do, since this type of general model requires real programming and not the pseudo-coding ModelBuilder offers. Converting the process to Python is the best advice and you will get much more help on the Forum. The learning curve may seem steep, but you won't get it done in ModelBuilder faster, since once you get to complexities like this ModelBuilder starts showing its many limitations and Python becomes much simpler to set up.
Export the 4 separate working models into 4 seperate Python files using the modelBuilder export functions as a starting point.
I don't see how to connect your description of what you are doing to the model you have posted, since you are assuming I will understand field names and other information that only you currently know exist. For example, what in the shapefile will have an average of >90? A field? A count of records? The whole process can probably be restructured to be better organized to enhance the code's ability to handle the full range of your inputs once all of the essential components in play are actually laid out in an intelligible order to people like Dan and myself.