Select by location and switch selection not working consistently

3275
4
10-09-2013 02:27 AM
RafaelAnleu
New Contributor
Hy everybody, I am trying to make a model on ArcGis 10 Desktop which is going to be part of a huge analysis routine but my problem comes up at the very beginning of things and is quite simple. I need to select a poligon feature which intersects previously selected point feature which is a feature "not intersecting" a third layer, thus the result of a "switch selection".

The routine goes like this (see the picture)

[ATTACH=CONFIG]28162[/ATTACH]

1) Select points from layer "P" that intersect polygon layer "A" (select by location).
2) Switch selection (select by attribute) because I am interested in the points not intersecting layer "A".
3) Select feature polygons from layer "B" that intersect the result of the switch selection (select by location).

As far as I understand, I need to the put the selection type for step 1) and step 3) as "NEW_SELECTION", since I am only interested in these precise features. During my first trials this was not working. The problem actually came during step 2), where the SWITCH_SELECTION instead of switching the selected points, added the previously not selected points. Thus I ended up with my whole point layer being selected.

Then I decided to set the selection type to "ADD_TO_SELECTION" on both step 1) and 3). Since on each layer i have nothing else chosen, this should work exactly like "NEW_SELECTION". And Voila, it did worked. Now just for fun I changed back to "NEW_SELECTION" on step 1), and guess what? It also worked. And finally I have tried all combinations:

Step 1     Step 3
NEW_...      NEW_...
NEW_...      ADD_...
ADD_...      NEW_...
ADD_...      ADD_...


and now they all work as expected. That sounds like good news, but I am fearing that there is some bug, that goes away when you start tampering with the selection type. Does anybody knows something about? Similar experience? Some sort of environmental variable or any other crap that needs to be taken care off? It would be of great help since I do not want to get any surprises once I have the full working model.

Cheers

Rafael
0 Kudos
4 Replies
MattSayler
Occasional Contributor II
I haven't had this particular issue before, but occassionally have had some 'unexpected' behavior when running selections. To troubleshoot, try working from a new mxd; bring the layers in new (Add Data, no copy n paste). Run the model on that. If the issue isn't repeatable, it was probably just a glitch in the session.

If you're still concerned, you could add a step in the model to export the selection results to a temp folder. That way as you progress through developement and testing you can always go back and check that you got the expected selection set for a given run.
0 Kudos
RafaelAnleu
New Contributor
Thanks for the comment Matt, I will try what you said.

One thing I noted later today, and that I forgot to post is that things start working once I change the name of the output variable. You see when you leave it to ArcGis to name your output variables, it will put "InputVariableName", "InputVariableName(2)" in my case where the output is only a virtual operation on the same file. Once I changed "InputVariableName(2)" to whatever else, things worked again. Are output variable names actually important? Aren't they just meant for visualization purposes? Isn't the file name what is important? and if in did the output variable name is important, why the hell does ESRI places names automatically that are "automatically" not going to work? Any thoughts on that Matt?

Rafael
0 Kudos
MattSayler
Occasional Contributor II
I'm not sure I can help you there. Honestly, I don't even use model builder anymore because of quirky stuff like that. Python makes it so much easier to control what's going on. Only loss is not having the flow chart to use as a visual aid.

If you have the opportunity, I would highly recommend learning python. It will be a learning curve if you're a non-programmer, but I think the payoff is pretty huge. I'll take script troubles over model builder troubles any day.
0 Kudos
ScottMoyer
Occasional Contributor
Rafael,
Something you may want to assess is the effect of validating your model. We're told validation is to ensure that the model will run properly, but maybe it resets/clears variables? Did you validate after renaming "InputVariableName(2)", and things ran well? Well, this is just something to consider.
Scott
0 Kudos