Hi Everyone Quick Question,
I am trying to build a model in model builder that ask for a user to define a value in a parameter (string variable) and then integrate this string variable into my raster's extract by attribute tool (spatial analyst). Basically I want a user to be able to enter say "3.2" which is related to a string variable and then utilize this string variable in the where statement of the extract by attribute tool.
Where value <= (User define value in string variable)
The problem I have is I don't know how to integrate the separate string variable into the sql where clause.
Solved! Go to Solution.
Are you familiar using inline variable substitution in ModelBuilder? https://pro.arcgis.com/en/pro-app/latest/help/analysis/geoprocessing/modelbuilder/inline-variable-su...
I made a quick mock-up based on your screenshot and this works fine.
Note, though, that my Critical Value variable is a Float, not a String. Why do you need the variable to be a String when ultimately it has to be a number in order to compare against a numerical value in the raster? The users would be expected to enter a number for that parameter, correct?
Hi Austin,
This should hopefully help out.
Your SQL query should formatted like this:
I apologize, I am new to this whole sql coding, python is where my expertise lie, but i am trying to build my model out in model builder for other coworkers who are less skilled in python. I am still running into some errors and I think it's just because I am having a hard time wrapping my head around the coding.
Sorry I didn't explain it well enough. The FieldName represents the field you are doing the WHERE clause against. In your case it's VALUE
'"VALUE" = \'{0}\'' .format(NOAA_IH_Year_1_Crit_Value)
Are you familiar using inline variable substitution in ModelBuilder? https://pro.arcgis.com/en/pro-app/latest/help/analysis/geoprocessing/modelbuilder/inline-variable-su...
I made a quick mock-up based on your screenshot and this works fine.
Note, though, that my Critical Value variable is a Float, not a String. Why do you need the variable to be a String when ultimately it has to be a number in order to compare against a numerical value in the raster? The users would be expected to enter a number for that parameter, correct?
I am, I had wanted to use inline variable substitution but was unsure if it would work with the SQL coding. The reason I had used a string was simply because I couldn't find a number/float variable type in the model builder options and figured that I could just as easily utilize a float() function to transform the string into a float.