<?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 How to use an iterator to set the 'Template Extent' for the CREATE FISHNET tool? in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/how-to-use-an-iterator-to-set-the-template-extent/m-p/71452#M2523</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have a base "fishnet" polygon grid. I attempted to create a model that iterates over each cell in that base fishnet grid and subdivide that cell with the Create Fishnet tool into a new feature class.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I expected that I simply would need to set the output from my iterate feature iterator&amp;nbsp; as the 'Template Extent' parameter for the Create Fishnet tool. However, while I can see the name of this iterator output model variable in the drop-down list for the 'Template Extent' parameter;&amp;nbsp; the name does not have the blue Model Variable icon. And more importantly, the template extent does not update at each model iteration.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there a way that I can make my model recognize aan iteration output as a template extent?&amp;nbsp; ( see screenshot below)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]19323[/ATTACH]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 15 Nov 2012 10:29:59 GMT</pubDate>
    <dc:creator>MarkZweifler</dc:creator>
    <dc:date>2012-11-15T10:29:59Z</dc:date>
    <item>
      <title>How to use an iterator to set the 'Template Extent' for the CREATE FISHNET tool?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/how-to-use-an-iterator-to-set-the-template-extent/m-p/71452#M2523</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have a base "fishnet" polygon grid. I attempted to create a model that iterates over each cell in that base fishnet grid and subdivide that cell with the Create Fishnet tool into a new feature class.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I expected that I simply would need to set the output from my iterate feature iterator&amp;nbsp; as the 'Template Extent' parameter for the Create Fishnet tool. However, while I can see the name of this iterator output model variable in the drop-down list for the 'Template Extent' parameter;&amp;nbsp; the name does not have the blue Model Variable icon. And more importantly, the template extent does not update at each model iteration.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there a way that I can make my model recognize aan iteration output as a template extent?&amp;nbsp; ( see screenshot below)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]19323[/ATTACH]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Nov 2012 10:29:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/how-to-use-an-iterator-to-set-the-template-extent/m-p/71452#M2523</guid>
      <dc:creator>MarkZweifler</dc:creator>
      <dc:date>2012-11-15T10:29:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to use an iterator to set the 'Template Extent' for the CREATE FISHNET tool?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/how-to-use-an-iterator-to-set-the-template-extent/m-p/71453#M2524</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I have a base "fishnet" polygon grid. I attempted to create a model that iterates over each cell in that base fishnet grid and subdivide that cell with the Create Fishnet tool into a new feature class.&lt;BR /&gt;&lt;BR /&gt;I expected that I simply would need to set the output from my iterate feature iterator&amp;nbsp; as the 'Template Extent' parameter for the Create Fishnet tool. However, while I can see the name of this iterator output model variable in the drop-down list for the 'Template Extent' parameter;&amp;nbsp; the name does not have the blue Model Variable icon. And more importantly, the template extent does not update at each model iteration.&amp;nbsp; &lt;BR /&gt;Is there a way that I can make my model recognize aan iteration output as a template extent?&amp;nbsp; ( see screenshot below)&lt;BR /&gt;&lt;BR /&gt;[ATTACH=CONFIG]19323[/ATTACH]&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Mark,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I know you are looking for a model solution here, but can you implement this with just straight-up Python code?&amp;nbsp; I had a need for doing this same thing and came up with the code below (it is pulled from a larger script/process, but I peiced it together as best I could and it does work on a 9x9 grid example).&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You will need to alter the inputLocation and inputFC variables, add the cellHeight and Width you want the output grids to be and it should just work.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;also: this is for ArcGIS 9.3.1, but again it should just work in newer versions.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcgisscripting
gp = arcgisscripting.create(9.3)

#you will need to modify these two parameters for your situation.&amp;nbsp; This is an ex of a pgdb FeatureClass
inputLocation = "\\\\C:\Scratch.mdb"
inputFC = inputLocation + "\\exGRID"

# Open a search cursor on a feature class 
rows = gp.searchcursor(inputFC)
row = rows.Next()
i = 1
while row:
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; gp.AddMessage("Attempting to process polgyon " + str(i))
&amp;nbsp; 
&amp;nbsp; #Get the shape field
&amp;nbsp;&amp;nbsp; shape = row.shape
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp; #Get the extent object
&amp;nbsp;&amp;nbsp; extent = shape.extent

&amp;nbsp;&amp;nbsp; outputName = "Fishnet_" + str(i)
&amp;nbsp;&amp;nbsp; outFC = inputLocation + "\\" + outputName
&amp;nbsp; 
&amp;nbsp; #Get the origin (lowerLeft) and y-axis (upperLeft) properties of the polygon
&amp;nbsp;&amp;nbsp; ll = extent.lowerleft
&amp;nbsp;&amp;nbsp; ul = extent.upperleft
&amp;nbsp;&amp;nbsp; ur = extent.upperright
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; originXY = str(ll.x) + " " + str(ll.y)
&amp;nbsp;&amp;nbsp; yaxisXY = str(ul.x) + " " + str(ul.y)
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; opp_corner = str(ur.x) + " " + str(ur.y)

&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; gp.AddMessage("LowerLeft (x,y): %f, %f" % (ll.x, ll.y))
&amp;nbsp;&amp;nbsp; gp.AddMessage("UpperLeft (x,y): %f, %f" % (ul.x, ul.y))
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; gp.AddMessage("XMin: %f" % (extent.xmin))
&amp;nbsp;&amp;nbsp; gp.AddMessage("YMin: %f" % (extent.ymin))
&amp;nbsp;&amp;nbsp; gp.AddMessage("XMax: %f" % (extent.xmax))
&amp;nbsp;&amp;nbsp; gp.AddMessage("YMax: %f" % (extent.ymax))
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; #keep the cell width/height set to zero as it will use the opp_corner to figure it out
&amp;nbsp;&amp;nbsp; cellWidth = 0
&amp;nbsp;&amp;nbsp; cellHeight = 0
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; #plug in the #rows/#cols you want the output grids to contain 
&amp;nbsp;&amp;nbsp; nrows = 10
&amp;nbsp;&amp;nbsp; ncols = 10
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; gp.CreateFishnet_management(outFC, originXY, yaxisXY, cellWidth, cellHeight, nrows, ncols, opp_corner)
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; gp.AddMessage("Created " + outputName)
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; i = i + 1
&amp;nbsp;&amp;nbsp; row = rows.Next()
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:45:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/how-to-use-an-iterator-to-set-the-template-extent/m-p/71453#M2524</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2021-12-10T22:45:38Z</dc:date>
    </item>
  </channel>
</rss>

