-1

I made a model which exports polygons to a new layer within a loop (FOR iterator: from value 1614 to 1654, by value 10). Nr. 1 is the first shapefile, Nr. 2 is the second shapefile.

enter image description here

I only want to export adjacent polygons from the previous layer See also the inserted picture. I believe a get count iterator is needed, in combination with a select by location tool. I played around, but can't get it to work in a model. I tried this, the model actually selects polygons which touch boundaries. But the while iterator doesn't function quite right. I get this error message (see below):

enter image description here

*ERROR 000539: Error running expression: EXP (count)
Traceback (most recent call last):
   File "<expression>", line 1, in <module>
   NameError: name 'count' is not defined Failed to execute (Calculate Value).*

Polygon neighbors is not an option since I am working with multiple shapefiles.

  • 1
    It will depend on precisely what you are trying to do but I would think about using Polygon Neighbors to pre-calculate adjacency rather than doing repeated Select By Locations. – PolyGeo Nov 3 '15 at 11:18
  • The model adds 10 values each loop creating a water flood. Starting point from the 1614 value (blue box). The output should only contain polygons which are connected to the starting value. In the example above the pink boxes which aren't connected shouldnt be selected to polygon. I believe Polygon Neighbors does not work, or does it? – Chris Driessen Nov 3 '15 at 18:09
  • See my edited question. I had to remove the first picture since I am allowed to post just two links in a topic. – Chris Driessen Nov 3 '15 at 19:00
  • I am unable to discern precisely what you are trying to do (labelling your polygons with their values might make your diagram more useful), but I would think Polygon Neighbors would result in a simpler and faster solution. Requirements like these are also likely to be easier to meet using ArcPy than ModelBuilder. As a new user be sure to take the Tour. – PolyGeo Nov 3 '15 at 21:46
  • 1
    Nowhere in your question does it mention two layers being used. I suggest revising and re-reading your question a few times to make sure that what you are asking is clear and includes all necessary information to answer it. – PolyGeo Nov 4 '15 at 10:38
1

Looking at your model image there are four things wrong with what I see:

  1. The Calculate Value tool is outputting a BOOLEAN you have data type set to Variant.
  2. The code in the Calculate Value tool is returning a string but you want to return a BOOLEAN so turn "true" into True and "false" into False, note first character is capitalized.
  3. You are trying to use inline substitution, you get the result of GetCount and do a test but you have not used the correct syntax. In the expression box in Calculate Value you should be passing the output of GetCount using the syntax EXP(%Count%). Note how it is enclosed in %%, suggest you look at help an inline substitution to understand this better.
  4. You want the Calculate Value tool to be a precondition, i.e. if count is greater than zero then allow iterator to continue. You have connected it to the Iterator as parameter (not sure how you did that). A precondition ALWAYS has a dotted line. So use the connect tool and reconnect it as a precondition.

On a completely separate note as you have experienced new people to GIS SE have limited functionality. You can very quickly get more abilities by engaging with the community. You've posted 6 days ago and you are still on reputation score of 1 this tells everyone you have done nothing! Try looking at a few questions vote up/down, comment, try to answer old questions, you'll be surprised how quickly your reputation and abilities increases...

0

I used this model to iterate select by location, which works for the selection of polygon which touches neighbor polygon. Islands aren't selected. It's not dynamic yet, work in progress.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.