<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Iterating through geometries in a layer for multiple if conditional statements. in Python Snippets Questions</title>
    <link>https://community.esri.com/t5/python-snippets-questions/iterating-through-geometries-in-a-layer-for/m-p/1624823#M717</link>
    <description>&lt;P&gt;Yould you mind re-sharing your code using a codeblock? Python requires correct whitespace to be read properly and you have flattened your code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="HaydenWelch_0-1750278823351.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/134591iBD8106458E316D1B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="HaydenWelch_0-1750278823351.png" alt="HaydenWelch_0-1750278823351.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 18 Jun 2025 20:33:48 GMT</pubDate>
    <dc:creator>HaydenWelch</dc:creator>
    <dc:date>2025-06-18T20:33:48Z</dc:date>
    <item>
      <title>Iterating through geometries in a layer for multiple if conditional statements.</title>
      <link>https://community.esri.com/t5/python-snippets-questions/iterating-through-geometries-in-a-layer-for/m-p/1624805#M716</link>
      <description>&lt;P&gt;I am trying to iterate through the features of a layer and verify two different variables in two different fields in the same row. If both variables are true then it will apply a geoprocessing tool with one of the 2&amp;nbsp; results. The geoprocessing is Feature vertices to Point. I want to run it to create an output with points at the start of the line feature or on both sides of the line feature.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used already If/elif/else and it didn't work. I added the selection feature to apply the function of the geoprocessing tool to only the features that meet the conditions because without it it will apply it to all the lines in the layer once the condition was True in some of them and not just to the ones that meet the conditions.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried this code and it works in separates blocks using notebook in ArcPro but when I put it all together it doesn't work.&amp;nbsp;&lt;/P&gt;&lt;P&gt;What do you think could be change to make it work? or what am I doing wrong here?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;import arcpy&lt;BR /&gt;from arcpy import env&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;arcpy.env.workspace = "workspace_gdb"&lt;BR /&gt;feature_class = "Line_Feature_Class"&lt;BR /&gt;output_vertices_topoint = "output_location"&lt;BR /&gt;output_vertices_topoint2 = "output_location"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;value_x1 = "W"&lt;BR /&gt;value_x2 = "N"&lt;BR /&gt;value_x3 = "NW"&lt;BR /&gt;value_y1 = "NS"&lt;BR /&gt;value_y2 = "WE"&lt;BR /&gt;field_name1 = "WindDegrees1"&lt;BR /&gt;field_name2 = "WBDirection"&lt;BR /&gt;domain_name = "Wind Direction"&lt;/P&gt;&lt;P&gt;domains = arcpy.da.ListDomains(arcpy.env.workspace)&lt;BR /&gt;target_domain= None&lt;BR /&gt;for domain in domains:&lt;BR /&gt;if domain_name == domain.name:&lt;BR /&gt;target_domain=domain&lt;BR /&gt;break&lt;/P&gt;&lt;P&gt;if target_domain:&lt;BR /&gt;# Create a dictionary of coded values.&lt;BR /&gt;coded_values = domain.codedValues&lt;BR /&gt;&lt;BR /&gt;arcpy.management.MakeFeatureLayer(feature_class, "temp_layer")&lt;/P&gt;&lt;P&gt;with arcpy.da.SearchCursor("temp_layer", ["SHAPE@", field_name1, field_name2]) as search_cursor:&lt;BR /&gt;for row in search_cursor:&lt;BR /&gt;object_id = row[0]&lt;BR /&gt;coded_value1 = row[1]&lt;BR /&gt;coded_value2 = row[2]&lt;/P&gt;&lt;P&gt;if coded_value1 == value_y1 and coded_value2 == value_x3:&lt;BR /&gt;# Select the feature&lt;BR /&gt;arcpy.management.SelectLayerByAttribute("temp_layer", "NEW_SELECTION", f"{field_name1} = '{value_y1}' AND {field_name2} = '{value_x3}'")&lt;BR /&gt;&lt;BR /&gt;# Perform actions on the selected feature&lt;BR /&gt;arcpy.management.FeatureVerticesToPoints("temp_layer", output_vertices_topoint, "START")&lt;BR /&gt;&lt;BR /&gt;else:&lt;BR /&gt;&lt;BR /&gt;print(f"Feature does not meet any condition.")&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;arcpy.management.SelectLayerByAttribute(feature_class, "CLEAR_SELECTION")&lt;BR /&gt;break&lt;BR /&gt;&lt;BR /&gt;with arcpy.da.SearchCursor("temp_layer", ["SHAPE@", field_name1, field_name2]) as search_cursor:&lt;BR /&gt;for row in search_cursor:&lt;BR /&gt;object_id = row[0]&lt;BR /&gt;coded_value1 = row[1]&lt;BR /&gt;coded_value2 = row[2]&lt;/P&gt;&lt;P&gt;if coded_value1 == value_y2 and coded_value2 == value_x3:&lt;BR /&gt;# Select the feature&lt;BR /&gt;arcpy.management.SelectLayerByAttribute("temp_layer", "NEW_SELECTION", f"{field_name1} = '{value_y2}' AND {field_name2} = '{value_x3}'")&lt;BR /&gt;&lt;BR /&gt;# Perform actions on the selected feature&lt;BR /&gt;arcpy.management.FeatureVerticesToPoints("temp_layer", output_vertices_topoint2, "START")&lt;BR /&gt;&lt;BR /&gt;else:&lt;BR /&gt;&lt;BR /&gt;print(f"Feature does not meet any condition.")&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;arcpy.management.SelectLayerByAttribute(feature_class, "CLEAR_SELECTION")&lt;BR /&gt;break&lt;BR /&gt;&lt;BR /&gt;with arcpy.da.SearchCursor("temp_layer", ["SHAPE@", field_name1, field_name2]) as search_cursor:&lt;BR /&gt;for row in search_cursor:&lt;BR /&gt;object_id = row[0]&lt;BR /&gt;coded_value1 = row[1]&lt;BR /&gt;coded_value2 = row[2]&lt;/P&gt;&lt;P&gt;if coded_value1 == value_y1 and coded_value2 == value_x2:&lt;BR /&gt;# Select the feature&lt;BR /&gt;arcpy.management.SelectLayerByAttribute("temp_layer", "NEW_SELECTION", f"{field_name1} = '{value_y1}' AND {field_name2} = '{value_x2}'")&lt;BR /&gt;&lt;BR /&gt;# Perform actions on the selected feature&lt;BR /&gt;arcpy.management.FeatureVerticesToPoints("temp_layer", output_vertices_topoint2, "START")&lt;BR /&gt;&lt;BR /&gt;else:&lt;BR /&gt;&lt;BR /&gt;print(f"Feature does not meet any condition.")&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;arcpy.management.SelectLayerByAttribute(feature_class, "CLEAR_SELECTION")&lt;BR /&gt;break&lt;BR /&gt;&lt;BR /&gt;with arcpy.da.SearchCursor("temp_layer", ["SHAPE@", field_name1, field_name2]) as search_cursor:&lt;BR /&gt;for row in search_cursor:&lt;BR /&gt;object_id = row[0]&lt;BR /&gt;coded_value1 = row[1]&lt;BR /&gt;coded_value2 = row[2]&lt;/P&gt;&lt;P&gt;if coded_value1 == value_y1 and coded_value2 == value_x1:&lt;BR /&gt;# Select the feature&lt;BR /&gt;arcpy.management.SelectLayerByAttribute("temp_layer", "NEW_SELECTION", f"{field_name1} = '{value_y1}' AND {field_name2} = '{value_x1}'")&lt;BR /&gt;&lt;BR /&gt;# Perform actions on the selected feature&lt;BR /&gt;arcpy.management.FeatureVerticesToPoints("temp_layer", output_vertices_topoint, "BOTH_ENDS")&lt;BR /&gt;&lt;BR /&gt;else:&lt;BR /&gt;&lt;BR /&gt;print(f"Feature does not meet any condition.")&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;arcpy.management.SelectLayerByAttribute(feature_class, "CLEAR_SELECTION")&lt;BR /&gt;break&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;with arcpy.da.SearchCursor("temp_layer", ["SHAPE@", field_name1, field_name2]) as search_cursor:&lt;BR /&gt;for row in search_cursor:&lt;BR /&gt;object_id = row[0]&lt;BR /&gt;coded_value1 = row[1]&lt;BR /&gt;coded_value2 = row[2]&lt;/P&gt;&lt;P&gt;if coded_value1 == value_y2 and coded_value2 == value_x2:&lt;BR /&gt;# Select the feature&lt;BR /&gt;arcpy.management.SelectLayerByAttribute("temp_layer", "NEW_SELECTION", f"{field_name1} = '{value_y2}' AND {field_name2} = '{value_x2}'")&lt;BR /&gt;&lt;BR /&gt;# Perform actions on the selected feature&lt;BR /&gt;arcpy.management.FeatureVerticesToPoints("temp_layer", output_vertices_topoint, "BOTH_ENDS")&lt;BR /&gt;&lt;BR /&gt;else:&lt;BR /&gt;&lt;BR /&gt;print(f"Feature does not meet any condition.")&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;arcpy.management.SelectLayerByAttribute(feature_class, "CLEAR_SELECTION")&lt;BR /&gt;break&lt;BR /&gt;&lt;BR /&gt;with arcpy.da.SearchCursor("temp_layer", ["SHAPE@", field_name1, field_name2]) as search_cursor:&lt;BR /&gt;for row in search_cursor:&lt;BR /&gt;object_id = row[0]&lt;BR /&gt;coded_value1 = row[1]&lt;BR /&gt;coded_value2 = row[2]&lt;/P&gt;&lt;P&gt;if coded_value1 == value_y2 and coded_value2 == value_x1:&lt;BR /&gt;# Select the feature&lt;BR /&gt;arcpy.management.SelectLayerByAttribute("temp_layer", "NEW_SELECTION", f"{field_name1} = '{value_y2}' AND {field_name2} = '{value_x1}'")&lt;BR /&gt;&lt;BR /&gt;# Perform actions on the selected feature&lt;BR /&gt;arcpy.management.FeatureVerticesToPoints("temp_layer", output_vertices_topoint2, "START")&lt;BR /&gt;&lt;BR /&gt;else:&lt;BR /&gt;&lt;BR /&gt;print(f"Feature does not meet any condition.")&lt;BR /&gt;print (row[1], row[2])&lt;BR /&gt;&lt;BR /&gt;arcpy.management.SelectLayerByAttribute(feature_class, "CLEAR_SELECTION")&lt;BR /&gt;break&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jun 2025 20:09:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/iterating-through-geometries-in-a-layer-for/m-p/1624805#M716</guid>
      <dc:creator>CristinaBurgosOtero</dc:creator>
      <dc:date>2025-06-18T20:09:52Z</dc:date>
    </item>
    <item>
      <title>Re: Iterating through geometries in a layer for multiple if conditional statements.</title>
      <link>https://community.esri.com/t5/python-snippets-questions/iterating-through-geometries-in-a-layer-for/m-p/1624823#M717</link>
      <description>&lt;P&gt;Yould you mind re-sharing your code using a codeblock? Python requires correct whitespace to be read properly and you have flattened your code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="HaydenWelch_0-1750278823351.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/134591iBD8106458E316D1B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="HaydenWelch_0-1750278823351.png" alt="HaydenWelch_0-1750278823351.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jun 2025 20:33:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/iterating-through-geometries-in-a-layer-for/m-p/1624823#M717</guid>
      <dc:creator>HaydenWelch</dc:creator>
      <dc:date>2025-06-18T20:33:48Z</dc:date>
    </item>
    <item>
      <title>Re: Iterating through geometries in a layer for multiple if conditional statements.</title>
      <link>https://community.esri.com/t5/python-snippets-questions/iterating-through-geometries-in-a-layer-for/m-p/1624845#M718</link>
      <description>&lt;P&gt;Since it's difficult to follow your logic in the provided code, I went ahead and did my best to create a version that's as simple as possible. I think from here it'll be easier to figure out what exactly you need:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def main():
    feature_class = 'Line_Feature_Class'
        
    # Build this however you want
    queries ={
        'NS-NW': "WindDegrees1 = 'NS' AND WBDirection = 'NW'",
        'WE-NW': "WindDegrees1 = 'WE' AND WBDirection = 'NW'",
        'NS-N' : "WindDegrees1 = 'NS' AND WBDirection = 'N'",
        'NS-W' : "WindDegrees1 = 'NS' AND WBDirection = 'W'",
        'WE-N' : "WindDegrees1 = 'WE' AND WBDirection = 'N'",
        'WE-W' : "WindDegrees1 = 'WE' AND WBDirection = 'W'",
    }
    
    # Add more of these as needed
    start_points = []
    both_points = []
    
    for query_name, query in queries.items():
        # Get all matching feature shapes
        matches: list[arcpy.Polyline] = [
            shape
            for shape, in arcpy.da.SearchCursor(feature_class, ['SHAPE@'], where_clause=query)
            if isinstance(shape, arcpy.Polyline) # For the type linter
        ]
        
        # Handle based on query name
        if query_name in ('NS-NW', 'WE-NW', 'NS-N', 'WE-W'):
            # Get start
            for line in matches:
                # First Point
                start_points.append(arcpy.PointGeometry(line.firstPoint, spatial_reference=line.spatialReference))
                
        elif query_name in ('NS-W', 'WE-N'):
            # Get Both
            for line in matches:
                # First Point
                both_points.append(arcpy.PointGeometry(line.firstPoint, spatial_reference=line.spatialReference))
                # Last Point
                both_points.append(arcpy.PointGeometry(line.lastPoint, spatial_reference=line.spatialReference))
        
        # Raise an error if the query is not handled      
        else:
            raise ValueError(f'Undefined Query `{query_name}`!')
    
    arcpy.management.CopyFeatures(start_points, 'StartPoints')
    arcpy.management.CopyFeatures(both_points, 'BothPoints')
    
if __name__ == '__main__':
    main()&lt;/LI-CODE&gt;&lt;P&gt;&lt;STRIKE&gt;Fixed the index error on line 21 as per Blake's reply&lt;/STRIKE&gt;&lt;/P&gt;&lt;P&gt;Switched to singleton unpacking instead so i don't have to see magic indexes (`shape,` will unpack (1,) as shape=1)&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jun 2025 22:34:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/iterating-through-geometries-in-a-layer-for/m-p/1624845#M718</guid>
      <dc:creator>HaydenWelch</dc:creator>
      <dc:date>2025-06-18T22:34:37Z</dc:date>
    </item>
    <item>
      <title>Re: Iterating through geometries in a layer for multiple if conditional statements.</title>
      <link>https://community.esri.com/t5/python-snippets-questions/iterating-through-geometries-in-a-layer-for/m-p/1624856#M719</link>
      <description>&lt;P&gt;I think there's something missing on line 20.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jun 2025 21:51:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/iterating-through-geometries-in-a-layer-for/m-p/1624856#M719</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2025-06-18T21:51:18Z</dc:date>
    </item>
    <item>
      <title>Re: Iterating through geometries in a layer for multiple if conditional statements.</title>
      <link>https://community.esri.com/t5/python-snippets-questions/iterating-through-geometries-in-a-layer-for/m-p/1624857#M720</link>
      <description>&lt;P&gt;Oops. Originally I was unpacking oid and shape so I didn't need the index. Totally forgot to fix it.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jun 2025 21:52:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/iterating-through-geometries-in-a-layer-for/m-p/1624857#M720</guid>
      <dc:creator>HaydenWelch</dc:creator>
      <dc:date>2025-06-18T21:52:26Z</dc:date>
    </item>
    <item>
      <title>Re: Iterating through geometries in a layer for multiple if conditional statements.</title>
      <link>https://community.esri.com/t5/python-snippets-questions/iterating-through-geometries-in-a-layer-for/m-p/1624861#M721</link>
      <description>&lt;P&gt;In addition to formatting your code with a code block, like&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/607017"&gt;@HaydenWelch&lt;/a&gt;&amp;nbsp;mentioned, please clarify what you mean when you say, "it doesn't work." Do you get an error message? Is the output empty? If the output has data, is it incorrect? If it's a data issue, please clarify what you want it to look like and what you're getting instead.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jun 2025 22:01:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/iterating-through-geometries-in-a-layer-for/m-p/1624861#M721</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2025-06-18T22:01:38Z</dc:date>
    </item>
    <item>
      <title>Re: Iterating through geometries in a layer for multiple if conditional statements.</title>
      <link>https://community.esri.com/t5/python-snippets-questions/iterating-through-geometries-in-a-layer-for/m-p/1624865#M722</link>
      <description>&lt;P&gt;What threw me off was the &lt;A href="https://docs.python.org/3/library/typing.html#typing-support-for-type-hints" target="_self"&gt;type hinting&lt;/A&gt; for &lt;FONT face="courier new,courier"&gt;matches&lt;/FONT&gt;. I've never seen that before!&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":rainbow:"&gt;🌈&lt;/span&gt;&lt;/P&gt;&lt;P&gt;But now that you mention the index issue, I think you also need to update line 23 with an index too.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jun 2025 22:21:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/iterating-through-geometries-in-a-layer-for/m-p/1624865#M722</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2025-06-18T22:21:08Z</dc:date>
    </item>
    <item>
      <title>Re: Iterating through geometries in a layer for multiple if conditional statements.</title>
      <link>https://community.esri.com/t5/python-snippets-questions/iterating-through-geometries-in-a-layer-for/m-p/1624869#M723</link>
      <description>&lt;P&gt;I need to stop programming on 3 hours of sleep haha&lt;/P&gt;&lt;P&gt;Decided to use another fun Python feature instead of indexing in case we need to add stuff to the result&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also you should definitely be hinting everything you write if you aren't already. If you use an editor that has Pylance, the code basically writes itself. You get highlighting and auto-completion for everything. This is an instance of me forcing the type since the SearchCursor returns a tuple with the signature tuple[Any, ...] which means I lose that auto-complete with the results.&lt;/P&gt;&lt;P&gt;Because I know the 'SHAPE@' field is a Polyline, I can go ahead and assign that type to the result. The instance check isn't necessary, but if you have your settings for Pylance set to `strict` it will yell at you that you don't actually know that the type of that value is Polyline, so adding a guard there will ensure that if you run the script on a Point feature or something it'll error out ASAP&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jun 2025 22:40:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/iterating-through-geometries-in-a-layer-for/m-p/1624869#M723</guid>
      <dc:creator>HaydenWelch</dc:creator>
      <dc:date>2025-06-18T22:40:23Z</dc:date>
    </item>
    <item>
      <title>Re: Iterating through geometries in a layer for multiple if conditional statements.</title>
      <link>https://community.esri.com/t5/python-snippets-questions/iterating-through-geometries-in-a-layer-for/m-p/1625741#M724</link>
      <description>&lt;P&gt;Hi! Thank you for the responses and the recommendations, all this is very helpful for me. When I mentioned it doesn't work, I mean when I put together the code in just one cell, since I've been working in Notebooks in ArcPro, the code runs but it gives me back just one of the results I'm expecting. It doesn't get any errors message. While I had them in separate cells for testing the code running all of them, it would work and give me the results I was expecting. I set the data in the attribute table for it to give me back two outputs, from a "vertices to points" function, one output with the features that meet the conditions for one point at the start of the line and another output with the features that meet the conditions for the points on both side of the line. When I run it, now it is just giving me one result (both ends) and not the other one too, while in the data are features that meet the conditions for that function.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I haven't used Pylance, but will do.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Here is the code I have been using.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
from arcpy import env

arcpy.env.workspace = 'workspace'
feature_class = 'line_feature_class'
output_vertices_topoint = 'output1_point_feature_class'
output_vertices_topoint2 = 'output2_point_feature_class'

value_x1 = "W"
value_x2 = "N"
value_x3 = "NW"
value_y1 = "NS"
value_y2 = "WE"
field_name1 = "WindDegrees1"
field_name2 = "WBDirection"
domain_name = "Wind Direction"

domains = arcpy.da.ListDomains(arcpy.env.workspace)
target_domain= None
for domain in domains:
    if domain_name == domain.name:
        target_domain=domain
        break

if target_domain:
    # Create a dictionary of coded values.
    coded_values = domain.codedValues
    
arcpy.management.MakeFeatureLayer(feature_class, "temp_layer")

with arcpy.da.SearchCursor("temp_layer", ["SHAPE@", field_name1, field_name2]) as search_cursor:
    for row in search_cursor:
        object_id = row[0]
        coded_value1 = row[1]
        coded_value2 = row[2]

        if coded_value1 == value_x1 and coded_value2 == value_y1:
            # Select the feature
            arcpy.SelectLayerByAttribute_management("temp_layer", "NEW_SELECTION", f"{field_name1} = '{value_x1}' AND {field_name2} = '{value_y1}'")
                
            # Perform actions on the selected feature
            arcpy.management.FeatureVerticesToPoints("temp_layer", output_vertices_topoint, "START")
                   
        else:
                # Cases where the condition is not met
            print(f"Feature does not meet any condition.")
                # Clear selection 
                
            arcpy.SelectLayerByAttribute_management(feature_class, "CLEAR_SELECTION")
            
with arcpy.da.SearchCursor("temp_layer", ["SHAPE@", field_name1, field_name2]) as search_cursor:
    for row in search_cursor:
        object_id = row[0]
        coded_value1 = row[1]
        coded_value2 = row[2]

        if coded_value1 == value_x2 and coded_value2 == value_y1:
            # Select the feature
            arcpy.SelectLayerByAttribute_management("temp_layer", "NEW_SELECTION", f"{field_name1} = '{value_x2}' AND {field_name2} = '{value_y1}'")
                
            # Perform actions on the selected feature
            arcpy.management.FeatureVerticesToPoints("temp_layer", output_vertices_topoint2, "BOTH_ENDS")
                   
        else:
                # Cases where the condition is not met
            print(f"Feature does not meet any condition.")
                # Clear selection 
                
            arcpy.SelectLayerByAttribute_management(feature_class, "CLEAR_SELECTION")
        
with arcpy.da.SearchCursor("temp_layer", ["SHAPE@", field_name1, field_name2]) as search_cursor:
    for row in search_cursor:
        object_id = row[0]
        coded_value1 = row[1]
        coded_value2 = row[2]

        if coded_value1 == value_x2 and coded_value2 == value_y2:
            # Select the feature
            arcpy.SelectLayerByAttribute_management("temp_layer", "NEW_SELECTION", f"{field_name1} = '{value_x2}' AND {field_name2} = '{value_y2}'") 
                
            # Perform actions on the selected feature
            arcpy.management.FeatureVerticesToPoints("temp_layer", output_vertices_topoint, "START")
                   
        else:
                # Cases where the condition is not met
            print(f"Feature does not meet any condition.")
                # Clear selection 
                
            arcpy.SelectLayerByAttribute_management(feature_class, "CLEAR_SELECTION")
            
with arcpy.da.SearchCursor("temp_layer", ["SHAPE@", field_name1, field_name2]) as search_cursor:
    for row in search_cursor:
        object_id = row[0]
        coded_value1 = row[1]
        coded_value2 = row[2]

        if coded_value1 == value_x1 and coded_value2 == value_y2:
            # Select the feature
            arcpy.SelectLayerByAttribute_management("temp_layer", "NEW_SELECTION", f"{field_name1} = '{value_x1}' AND {field_name2} = '{value_y2}'") 
                
            # Perform actions on the selected feature
            arcpy.management.FeatureVerticesToPoints("temp_layer", output_vertices_topoint2, "BOTH_ENDS")
                   
        else:
                # Cases where the condition is not met
            print(f"Feature does not meet any condition.")
                # Clear selection 
                
            arcpy.SelectLayerByAttribute_management(feature_class, "CLEAR_SELECTION")
                       
with arcpy.da.SearchCursor("temp_layer", ["SHAPE@", field_name1, field_name2]) as search_cursor:
    for row in search_cursor:
        object_id = row[0]
        coded_value1 = row[1]
        coded_value2 = row[2]

        if coded_value1 == value_x3 and coded_value2 == value_y1:
            # Select the feature
            arcpy.SelectLayerByAttribute_management("temp_layer", "NEW_SELECTION", f"{field_name1} = '{value_x3}' AND {field_name2} = '{value_y1}'")
                
            # Perform actions on the selected feature
            arcpy.management.FeatureVerticesToPoints("temp_layer", output_vertices_topoint, "START")
                   
        else:
                # Cases where the condition is not met
            print(f"Feature does not meet any condition.")
                # Clear selection 
                
            arcpy.SelectLayerByAttribute_management(feature_class, "CLEAR_SELECTION")
    
with arcpy.da.SearchCursor("temp_layer", ["SHAPE@", field_name1, field_name2]) as search_cursor:
    for row in search_cursor:
        object_id = row[0]
        coded_value1 = row[1]
        coded_value2 = row[2]

        if coded_value1 == value_x3 and coded_value2 == value_y2:
            # Select the feature
            arcpy.SelectLayerByAttribute_management("temp_layer", "NEW_SELECTION", f"{field_name1} = '{value_x3}' AND {field_name2} = '{value_y2}'")
                
            # Perform actions on the selected feature
            arcpy.management.FeatureVerticesToPoints("temp_layer", output_vertices_topoint, "START")
                   
        else:
                # Cases where the condition is not met
            print(f"Feature does not meet any condition.")
                # Clear selection 
                
            arcpy.SelectLayerByAttribute_management(feature_class, "CLEAR_SELECTION")
            break
            &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jun 2025 15:26:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/iterating-through-geometries-in-a-layer-for/m-p/1625741#M724</guid>
      <dc:creator>CristinaBurgosOtero</dc:creator>
      <dc:date>2025-06-23T15:26:02Z</dc:date>
    </item>
    <item>
      <title>Re: Iterating through geometries in a layer for multiple if conditional statements.</title>
      <link>https://community.esri.com/t5/python-snippets-questions/iterating-through-geometries-in-a-layer-for/m-p/1625750#M725</link>
      <description>&lt;P&gt;It seems like you're overwriting "temp_layer" with each cursor operation and your selections are also shadowing each other. So only the last matching selection and "temp_layer" are created.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jun 2025 15:32:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/iterating-through-geometries-in-a-layer-for/m-p/1625750#M725</guid>
      <dc:creator>HaydenWelch</dc:creator>
      <dc:date>2025-06-23T15:32:29Z</dc:date>
    </item>
    <item>
      <title>Re: Iterating through geometries in a layer for multiple if conditional statements.</title>
      <link>https://community.esri.com/t5/python-snippets-questions/iterating-through-geometries-in-a-layer-for/m-p/1627793#M726</link>
      <description>&lt;P&gt;I reviewed the logic of the conditional statements and cleaned up the selections and its working now!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Jun 2025 14:52:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/iterating-through-geometries-in-a-layer-for/m-p/1627793#M726</guid>
      <dc:creator>CristinaBurgosOtero</dc:creator>
      <dc:date>2025-06-27T14:52:09Z</dc:date>
    </item>
    <item>
      <title>Re: Iterating through geometries in a layer for multiple if conditional statements.</title>
      <link>https://community.esri.com/t5/python-snippets-questions/iterating-through-geometries-in-a-layer-for/m-p/1627838#M727</link>
      <description>&lt;P&gt;Awesome! Glad it worked out! Hopefully you leaned some stuff along the way haha&lt;/P&gt;</description>
      <pubDate>Fri, 27 Jun 2025 15:49:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/iterating-through-geometries-in-a-layer-for/m-p/1627838#M727</guid>
      <dc:creator>HaydenWelch</dc:creator>
      <dc:date>2025-06-27T15:49:22Z</dc:date>
    </item>
  </channel>
</rss>

