Can I have multiple inputs in clip GP task?

3354
8
11-13-2015 12:44 PM
JessicaKnight1
New Contributor III

I am working on moving a web app I've coded in the JavaScript API over to the Web App Builder. In my app, I had it set up so a user placed a point on a map, selected a buffer distance, and then selected one or many items to be clipped out of the resulting buffer. I went through model builder and set up a basic buffer-clip and it works great in WAB. But I am stuck on how I can have possible multiple selections for the clip. I've only had limited use of model builder in the past and didn't need it for my API coding. Any guidance would be great. Thanks so much.

0 Kudos
8 Replies
JessicaKnight1
New Contributor III

Anyone?

0 Kudos
AveKargaja
Occasional Contributor

Jessica Knight I Would try to build an union and a dissolve (or similar) function into the model.

     buffer(s)->union->dissolve->clip

0 Kudos
JessicaKnight1
New Contributor III

Can you expand on that? I only have one buffer but would want the user to have the ability to select multiple layers to clip at the same time. Not really sure a union/dissolve would help. I would think it would be some way to change the model using the clip function.

Can I add the clip tool multiple times in the model but make only one of those required?

0 Kudos
JessicaKnight1
New Contributor III

Any other thoughts?

0 Kudos
KevinHibma
Esri Regular Contributor

Look at using the Extract Data Task​. It already does what you want (clips multiple layers).

The only thing you want to do is pull that model into your own model where you'll have buffer as the first tool and the output of buffer is passed as the selecting features to the extract data task. (Because the EDT is setup to accept a polygon that a user could draw, thus you're just tweaking the front end experience)

JessicaKnight1
New Contributor III

Will that also display the results on the map? That's what I'm looking for. I don't really have a need for the results to be put into a .zip file.

0 Kudos
KevinHibma
Esri Regular Contributor

No it wont. The task will only make the output zip file. I just assumed because you were using doing a variable number of input layers to clip that your end goal was to actually extract them for download.

You're going to need to look at using the iterators inside model builder and build the task yourself. However, at this point I'd say a python script might be more straight forward and give you more flexibility. I'm not entirely sure you can setup a model with an iterator to accept multiple layers and iterator over them. (Because your input will probably be featurelayer:multivalue). Thus in a script you'd accept the multivalue, then split the inputs and iterate over them in a loop.

I'll point this out though - GP Services do not like when you have variable numbers of outputs. For example, if your tool accepts 1-5 layers as an input, you could set it up to have 1-5 output featureclasses (after the buffer/clip operation). The problem being, GP Services want well defined scenarios, so if your user only selects 2 layers, but the service expects 5, it doesnt get all the outputs back it was expecting too. So you'll need to come up with a single parameter, passing back a multivalue. (I cant remember off the top of my head if this will work, its been a long time since I've worked with output:multivalue).  The take home point here is:  you'll have to set your model or script up in a given way to work properly as a gp service and I can't tell you that particular way without knowing your exact requirements.

However, this all could be moot if you're just wanting to return the "clip" results as a map image (instead of the features sent back to the client to be drawn). That is a snap shot of the output to be drawn on top of your map. But at this point I'm making a lot of assumptions on your workflow and end goals. Hopefully some of the thoughts above will allow you to move forward with your workflow.

RebeccaStrauch__GISP
MVP Esteemed Contributor

Although this may not help much to resolve your issues, these are links I found last week when researching the multiple input aspect in a python script (for my Desktop project, not WAB). Good info that might clarify the input part of your question:

http://www.arcgis.com/home/item.html?id=91501d56a92e4534a16054554ac9f6d1   (a script "How to create a MULTIVALUE parameter choice list from an input feature class/table automatically.")

Generating a choice list from a field | ArcGIS Blog

This might give you some other ideas on how to approach it.

Since it seems what you are really trying to do is to create a Web AppBuilder Custom Widgets​   I just tagged that group.  You could also use the "move"  option for this thread, which should show in the right column (as long as the thread is open in it's own tab, and not thru you inbox).