Raster Interaction with Model Builder - Allowing a user to select the user inputs

5175
11
02-19-2015 10:38 AM
JustinGleeson
Occasional Contributor

I have a basic model that uses Raster Iteration to process all of the rasters in a .gdb. The model allows the user to define a weighting in the GUI and then the model runs a raster calculation on each iteration, stores the results in Collect Values and finally does a Cell Statistics calculation ton create the final output. 

As of now the Raster Iteration runs through all rasters in the .gdb. Is there a way of providing the user with a checkbox/radio button in the GUI to just choose a selection of the rasters in the .gdb?

The image below shows the model and the GUI. Ideally I'd like to be able to select the required rasters in the GUI before assigning the weightings.

Any advice or links on this would be great.

Many Thanks Justin

ModelEx.jpg

0 Kudos
11 Replies
JayantaPoddar
MVP Esteemed Contributor

Hi Justin,

In that case don't use iteration. Keep a single input raster. Mention the input and output as a Model parameter. Save the model as a tool. Run the tool in batch.

Thanks,

Jay



Think Location
0 Kudos
JustinGleeson
Occasional Contributor

Hi Jay,

Thanks for your reply. If it's just for one input then yes this would work.

However, I need to create an input that will allow the user to select multiple rasters to feed into the analysis. For example I would have Road, Urban, Water, Forestry, Sensitive Land Use rasters in the .gdb. As of now all the rasters go into the iteration but I want to enable the user to choose say only Urban, Water and Forestry or indeed another combination.

Justin

0 Kudos
ShitijMehta
Esri Regular Contributor

Hi Justin,

Thanks for writing back to me via the multivalue choice list blog. If you know a little bit of python for sure you can tweak the script in this blog to populate the raster dataset list. My script works on a table and asks for a field. It then populates all the unique values of the field for a user to check on the tool dialog.

What you would need to do is: ask for a workspace, Ask for a data type you want to show, then in the tool validation code (All the magic is there in tool validation - right click tool>properties>Validation Tab>Edit).

Read all the datasets in that workspace that match the format you asked on the tool dialog and populate them. No need for frequency as all dataset names will be unique.

Worth all the effort instead of letting a user just browse to the workspace as it is currently in your model?... hmmm? Not sure.

Try it and let me know.

0 Kudos
JustinGleeson
Occasional Contributor

Thanks so much for the reply. I will look into this and see how I go. I've little python experience but I guess there is a first time for everything.

Yes, this is a key step in what I am trying to achieve. I only want the user to be able to select from a pre-defined list of rasters through a check box/list.

This will have to be duplicated in the GUI for different 'themes' as we want users to select a sub-set of (a) soils rasters, then (b) forestry rasters and then (c) sensitive area rasters etc. Each selection will determine the rasters to feed into the Iterate Raster process and will take into account the user defined weights (1-5) that feed into the Raster Calculator. The results from each 'Theme' will then feed into the final Cell Statistics for the final raster output.

It's pretty much all working except for now everything in each 'theme' .gdb goes into the iteration processes. My challenge is to try and modify your script to limit the inputs through user interaction.

will be in touch

appreciate it

Justin

0 Kudos
ShitijMehta
Esri Regular Contributor

Ok. Wait.. lets rethink...

So you have all your rasters in one workspace or separate workspaces? theme.gdb = soil.gdb?

If all are in one, do all soil rasters have something in their name to identify them as soil rasters? or foresty rasters?

Is this list of rasters a static list or changes every week or month or ... In short is it a dynamic list or a static one?

Share a snapshot of your workspace and the raster datasets, if you can.

0 Kudos
JustinGleeson
Occasional Contributor

To start with....I really appreciate your help and interest!

Yes, as it stands I have a separate .gdb for each theme containing all the relevant rasters (WaterData.gdb contains aquiferVul, LakeStatus, RiverStatus etc). Same goes for soilsdata.gdb, forestrydata.gdb, EnvData etc.

The list of rasters in each .gdb will be static and not change on a regular basis (maybe updated every year or so).

Image of workspace and test version of working model attached. I guess what I need to do is plug in a script that will allow user selection from EnvData.gdb and SoilsData.gdb etc to feed into relevant Raster Iteration sub-models.

Thanks again!

Justin

Sample GDB.jpg

Model1.png

0 Kudos
ShitijMehta
Esri Regular Contributor

Ok.. I see the gdb now.

So, from the model tool dialog what do you want your users to see?

All four ai. lakes, majorroads and nha as a list and for them to pick one or two?

Or just show them a subset say air and lakes and for them to pick one or both?

Do these names change?

You just want the user to pick a name which looks cleaner on the dialog like Air and Lakes instead of browsing to c_air and c_Lakes?

Why I am asking all these is to figure out if you can accomplish this using the value list filter and calculate value tool.

Can you pass a predetermined list on the tool ui and then after the user picks one or more from that predetermined list you just pass them and link them in the model to the correct raster dataset.

0 Kudos
JustinGleeson
Occasional Contributor

OK, the raster names in the .gdb at the moment are just test rasters and the final versions will have 'cleaner' names: RiverStatus, Lake Status etc

In the dialog I want the user to work through each of the themes and select the layers they are interested in and decide on the sensitivity weighting they want to apply.

For instance, for each theme (soils, env, water etc) I'd like a list of all the rasters in each .gdb displayed with a check box that will allow the user to select what they are interested in (similar to the check box you have in your blog post). So, this could be one, two, three of the raster layers or indeed all of them. Selecting these will somehow send them to the Raster Iteration sub-model. The next part of the dialog will ask the user to input the weighting they want to apply to this theme (this bit is already working). Again, this parameter will be sent to the Raster iteration sub-model.

This will be duplicated for each theme in the final dialog.

Does that explain it?

Justin

0 Kudos
JustinGleeson
Occasional Contributor

Hi Shitij,

Have you had any further thoughts on this? Do you think your script is something that may work for what I am trying to achieve?

Thanks

0 Kudos