<?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 PYTHON Using a 'for' loop (ex. for i in list:) to create a series of shapefiles to use to create TINs in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-using-a-for-loop-ex-for-i-in-list-to-create/m-p/762632#M58904</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i'm trying to select a set of depth values (points - ex. 2902, 2904, 2906, etc.)from surveyed points.&amp;nbsp; save those to their own point layer, convert those to a TIN, then calc. Volumes. My approach was to make a list of the values, use those values as VARIABLES to create a series of shapefiles (shp2906, shp2908, etc.) then create TINs from those. Hard coding the numbers it&amp;nbsp; works, but wanted to pass the depth values (using "select" (ex. grid_code le 2906)) name the shapefile&amp;nbsp; and the tin (ex. tin2904, tin 2906, etc)&amp;nbsp;was hoping to use the iteration&amp;nbsp; as a variable, but it's not liking any of my attempts......&amp;nbsp;thanks in advance, for any ideas....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 10 Nov 2020 19:07:29 GMT</pubDate>
    <dc:creator>petegillard</dc:creator>
    <dc:date>2020-11-10T19:07:29Z</dc:date>
    <item>
      <title>PYTHON Using a 'for' loop (ex. for i in list:) to create a series of shapefiles to use to create TINs</title>
      <link>https://community.esri.com/t5/python-questions/python-using-a-for-loop-ex-for-i-in-list-to-create/m-p/762632#M58904</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i'm trying to select a set of depth values (points - ex. 2902, 2904, 2906, etc.)from surveyed points.&amp;nbsp; save those to their own point layer, convert those to a TIN, then calc. Volumes. My approach was to make a list of the values, use those values as VARIABLES to create a series of shapefiles (shp2906, shp2908, etc.) then create TINs from those. Hard coding the numbers it&amp;nbsp; works, but wanted to pass the depth values (using "select" (ex. grid_code le 2906)) name the shapefile&amp;nbsp; and the tin (ex. tin2904, tin 2906, etc)&amp;nbsp;was hoping to use the iteration&amp;nbsp; as a variable, but it's not liking any of my attempts......&amp;nbsp;thanks in advance, for any ideas....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Nov 2020 19:07:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-using-a-for-loop-ex-for-i-in-list-to-create/m-p/762632#M58904</guid>
      <dc:creator>petegillard</dc:creator>
      <dc:date>2020-11-10T19:07:29Z</dc:date>
    </item>
    <item>
      <title>Re: PYTHON Using a 'for' loop (ex. for i in list:) to create a series of shapefiles to use to create TINs</title>
      <link>https://community.esri.com/t5/python-questions/python-using-a-for-loop-ex-for-i-in-list-to-create/m-p/762633#M58905</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is always best to share some of your code, often times it is easier to interpret code than someone's explanation of their code.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Nov 2020 20:44:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-using-a-for-loop-ex-for-i-in-list-to-create/m-p/762633#M58905</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2020-11-10T20:44:04Z</dc:date>
    </item>
    <item>
      <title>Re: PYTHON Using a 'for' loop (ex. for i in list:) to create a series of shapefiles to use to create TINs</title>
      <link>https://community.esri.com/t5/python-questions/python-using-a-for-loop-ex-for-i-in-list-to-create/m-p/762634#M58906</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think this may help. It looks through a list of depths and exports a feature class from the source data that is queried for each depth, and then&amp;nbsp;also a tin. It's just a quick hack so there's no error handling etc. Also I'm not sure how to properly embed code, hopefully this works.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Marc&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# IMPORT ARCPY
import arcpy
arcpy.OverwriteOutput = True

# SCRIPT VARIABLES
sr = arcpy.SpatialReference(2193)

# MAKE SURE INPUT AND OUTPUT DATA/GDB EXIST
out_fgdb = r"C:\Temp\out.gdb"
out_folder = r"C:\Temp"
surv_pts = r"C:\Temp\s_pts.shp"
surv_lyr = arcpy.MakeFeatureLayer_management(surv_pts)
depth_list = [1,2,3,4,5]

# VALUES FOR TIN CREATION
depth_field = "depth"
tin_type = "Mass_Points &amp;lt;None&amp;gt;"

# ITERATE THROUGH DEPTHS, OUTPUT FEATURE CLASSES AND TINS
for d in depth_list:
 fc_name = "points_{}".format(d)
 fc_path = "{}\{}".format(out_fgdb,fc_name)
 query = "depth = {}".format(d)
 tin_path = r"{}\tin_{}".format(out_folder,d)

 # CREATE A FEATURECLASS IN THE OUTPUT FGDB
 arcpy.FeatureClassToFeatureClass_conversion(surv_lyr, out_fgdb, fc_name, query)
 tin_def = "{} {} {}".format(fc_path, depth_field, tin_type)

 # CREATE A TIN IN THE OUTPUT FOLDER
 arcpy.CreateTin_3d(tin_path,
 sr,
 tin_def,
 constrained_delaunay="DELAUNAY")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 16:53:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-using-a-for-loop-ex-for-i-in-list-to-create/m-p/762634#M58906</guid>
      <dc:creator>Marc_Graham</dc:creator>
      <dc:date>2021-12-12T16:53:32Z</dc:date>
    </item>
    <item>
      <title>Re: PYTHON Using a 'for' loop (ex. for i in list:) to create a series of shapefiles to use to create</title>
      <link>https://community.esri.com/t5/python-questions/python-using-a-for-loop-ex-for-i-in-list-to-create/m-p/1000658#M59024</link>
      <description>&lt;P&gt;thanks, thought of that...…...everywhere in the code&amp;nbsp;below "2922" is the depth.&amp;nbsp;I was trying to pull from a &amp;nbsp;"list" of&amp;nbsp;depths to use as a variable (we're looking at volume of water at 2ft. depth intervals&amp;nbsp;). This code worked, but was hoping to automate it.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;# Import arcpy module
import arcpy
from arcpy import env

arcpy.CheckOutExtension("3D")


# Local variables:
UPDpts = r"Y:\GIS\Pete\resPTS_test\UPDFk_pts_Clip.shp"
le2922 = r"Y:\GIS\Pete\resPTS_test\le2922.shp"
le2922tin = r"Y:\GIS\Pete\resPTS_test\le2922tin"
#proj = r"Coordinate Systems/Projected Coordinate Systems/State Plane/State Plane NAD 1983 (2011) Montana FIPS 2500 (Intl Feet).prj"
proj = arcpy.SpatialReference ("NAD 1983 (2011) StatePlane Montana FIPS 2500 (Intl Feet).prj")


# Process: Select
arcpy.Select_analysis(UPDpts, le2922, "grid_code &amp;lt;= 2922")

# Process: Create Tin
arcpy.CreateTin_3d("le2922tin", proj,"le2922.shp grid_code masspoints" " ")
arcpy.DelineateTinDataArea_3d("le2922tin", 11, "PERIMETER_ONLY")


# Process: Calc. volume
arcpy.SurfaceVolume_3d("le2922tin", "tin2922_vol.txt",
                      "BELOW", 2922, 1)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2020 13:51:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-using-a-for-loop-ex-for-i-in-list-to-create/m-p/1000658#M59024</guid>
      <dc:creator>petegillard</dc:creator>
      <dc:date>2020-11-12T13:51:32Z</dc:date>
    </item>
    <item>
      <title>Re: PYTHON Using a 'for' loop (ex. for i in list:) to create a series of shapefiles to use to create</title>
      <link>https://community.esri.com/t5/python-questions/python-using-a-for-loop-ex-for-i-in-list-to-create/m-p/1000659#M59025</link>
      <description>&lt;P&gt;thanks, i'll see if I can decipher this....appreciate the help&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2020 13:52:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-using-a-for-loop-ex-for-i-in-list-to-create/m-p/1000659#M59025</guid>
      <dc:creator>petegillard</dc:creator>
      <dc:date>2020-11-12T13:52:24Z</dc:date>
    </item>
    <item>
      <title>Re: PYTHON Using a 'for' loop (ex. for i in list:) to create a series of shapefiles to use to create</title>
      <link>https://community.esri.com/t5/python-questions/python-using-a-for-loop-ex-for-i-in-list-to-create/m-p/1000996#M59028</link>
      <description>&lt;P&gt;G'day Peter and Marc,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Marc, that script looked like it should work pretty well.&amp;nbsp; I haven't run it but what you have got down should go pretty well.&lt;/P&gt;&lt;P&gt;The only change that I would make would be to build the "Depth_List" dynamically by iterating through the original tables "Depth" field and adding them to the Depth List and converting it into a "set", which will&amp;nbsp;ensure that there is only one value for each depth.&lt;BR /&gt;so...&lt;BR /&gt;adding in&amp;nbsp; the following should help.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;depthList = [row[0] for row in arcpy.da.SearchCursor(originalTable, depthField)]
depthset = set(depthList)&lt;/LI-CODE&gt;&lt;P&gt;or to make it even smaller:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;depthSet = set([row[0] for row in arcpy.da.SearchCursor(originalTable, depthField)])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope you find the answer,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Michael&lt;/P&gt;</description>
      <pubDate>Fri, 13 Nov 2020 02:07:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-using-a-for-loop-ex-for-i-in-list-to-create/m-p/1000996#M59028</guid>
      <dc:creator>Michael_Boyce</dc:creator>
      <dc:date>2020-11-13T02:07:53Z</dc:date>
    </item>
  </channel>
</rss>

