<?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 Array to polygon-Python Script in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/array-to-polygon-python-script/m-p/721028#M55820</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, &lt;/P&gt;&lt;P&gt;I wann a create a python script, for creating polygon feature from coordinate array, what should be the data type for accessing the array in my paramater list. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;&lt;P&gt;Sri.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 06 Jan 2016 11:52:57 GMT</pubDate>
    <dc:creator>Srinivasa_MurthyNemani</dc:creator>
    <dc:date>2016-01-06T11:52:57Z</dc:date>
    <item>
      <title>Array to polygon-Python Script</title>
      <link>https://community.esri.com/t5/python-questions/array-to-polygon-python-script/m-p/721028#M55820</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, &lt;/P&gt;&lt;P&gt;I wann a create a python script, for creating polygon feature from coordinate array, what should be the data type for accessing the array in my paramater list. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;&lt;P&gt;Sri.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Jan 2016 11:52:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/array-to-polygon-python-script/m-p/721028#M55820</guid>
      <dc:creator>Srinivasa_MurthyNemani</dc:creator>
      <dc:date>2016-01-06T11:52:57Z</dc:date>
    </item>
    <item>
      <title>Re: Array to polygon-Python Script</title>
      <link>https://community.esri.com/t5/python-questions/array-to-polygon-python-script/m-p/721029#M55821</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There is a code example at the end of the arcpy.Polygon class help topic &lt;A href="https://pro.arcgis.com/en/pro-app/arcpy/classes/polygon.htm" title="https://pro.arcgis.com/en/pro-app/arcpy/classes/polygon.htm"&gt;Polygon—ArcPy Classes | ArcGIS for Desktop&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Jan 2016 12:33:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/array-to-polygon-python-script/m-p/721029#M55821</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-01-06T12:33:18Z</dc:date>
    </item>
    <item>
      <title>Re: Array to polygon-Python Script</title>
      <link>https://community.esri.com/t5/python-questions/array-to-polygon-python-script/m-p/721030#M55822</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Dan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your quick reply, I looked into the example.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and here is my code below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;array = arcpy.GetParameterAsText(0)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# A list of features and coordinate pairs&lt;/P&gt;&lt;P&gt;feature_info = [array]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# A list that will hold each of the Polygon objects&lt;/P&gt;&lt;P&gt;features = []&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for feature in feature_info:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Create a Polygon object based on the array of points&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Append to the list of Polygon objects&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; features.append(&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Polygon(&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Array([arcpy.Point(*coords) for coords in feature])))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Persist a copy of the Polyline objects using CopyFeatures&lt;/P&gt;&lt;P&gt;arcpy.CopyFeatures_management(features, "c:/geometry/polygons.shp")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As my array is a parameter that expects the value at runtime, what would be the datatype to assing in the tool.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Jan 2016 12:53:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/array-to-polygon-python-script/m-p/721030#M55822</guid>
      <dc:creator>Srinivasa_MurthyNemani</dc:creator>
      <dc:date>2016-01-06T12:53:24Z</dc:date>
    </item>
    <item>
      <title>Re: Array to polygon-Python Script</title>
      <link>https://community.esri.com/t5/python-questions/array-to-polygon-python-script/m-p/721031#M55823</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could try a few things to see if they work for you. The Cell Size parameter type with multivalue might work, but it is quite finicky.&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-2 jive-image" src="https://community.esri.com/legacyfs/online/165378_pastedImage_0.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You could also try to use &lt;A href="http://pro.arcgis.com/en/pro-app/arcpy/geoprocessing_and_python/programming-a-toolvalidator-class.htm#GUID-8BC6A4B7-B95D-4992-9792-482E1493FEED" rel="nofollow noopener noreferrer" target="_blank"&gt;tool validation&lt;/A&gt; and set up a value table parameter like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="165377" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/165377_pastedImage_0.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;P&gt;paste this code into the Validation and see if this works for you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
class ToolValidator(object):
&amp;nbsp; """Class for validating a tool's parameter values and controlling
&amp;nbsp; the behavior of the tool's dialog."""

&amp;nbsp; def __init__(self):
&amp;nbsp;&amp;nbsp;&amp;nbsp; """Setup arcpy and the list of tool parameters."""
&amp;nbsp;&amp;nbsp;&amp;nbsp; self.params = arcpy.GetParameterInfo()


&amp;nbsp; def initializeParameters(self):
&amp;nbsp;&amp;nbsp;&amp;nbsp; """Refine the properties of a tool's parameters.&amp;nbsp; This method is
&amp;nbsp;&amp;nbsp;&amp;nbsp; called when the tool is opened."""
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; param = self.params[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp; param.datatype = "Value Table"
&amp;nbsp;&amp;nbsp;&amp;nbsp; param.columns = [["Double","X"],["Double","Y"]]&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; return

&amp;nbsp; def updateParameters(self):
&amp;nbsp;&amp;nbsp;&amp;nbsp; """Modify the values and properties of parameters before internal
&amp;nbsp;&amp;nbsp;&amp;nbsp; validation is performed.&amp;nbsp; This method is called whenever a parameter
&amp;nbsp;&amp;nbsp;&amp;nbsp; has been changed."""
&amp;nbsp;&amp;nbsp;&amp;nbsp; return

&amp;nbsp; def updateMessages(self):
&amp;nbsp;&amp;nbsp;&amp;nbsp; """Modify the messages created by internal validation for each tool
&amp;nbsp;&amp;nbsp;&amp;nbsp; parameter.&amp;nbsp; This method is called after internal validation."""
&amp;nbsp;&amp;nbsp;&amp;nbsp; return&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 06:50:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/array-to-polygon-python-script/m-p/721031#M55823</guid>
      <dc:creator>LukeSturtevant</dc:creator>
      <dc:date>2021-12-12T06:50:44Z</dc:date>
    </item>
    <item>
      <title>Re: Array to polygon-Python Script</title>
      <link>https://community.esri.com/t5/python-questions/array-to-polygon-python-script/m-p/721032#M55824</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The data type you use depends on what format you reasonably expect and require from your user. If you can rely on your user to type in or (copy and paste) a full polygon array, like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[[[6,5],[7,8],[8,7],[6,5]]]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;...then you could simply use a string. Similarly, you could input a table of coordinates, or type and parse an input table like Luke mentions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you go with the above array option, the following slightly modified script should work:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy, ast

array = arcpy.GetParameterAsText(0) # a simple string

# A list of features and coordinate pairs
feature_info = ast.literal_eval(array)

# A list that will hold each of the Polygon objects
features = []

for feature in feature_info:
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Create a Polygon object based on the array of points
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Append to the list of Polygon objects
&amp;nbsp;&amp;nbsp;&amp;nbsp; features.append(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Polygon(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Array([arcpy.Point(*coords) for coords in feature])))

# Persist a copy of the Polyline objects using CopyFeatures
arcpy.CopyFeatures_management(features, r"C:\junk\poly.shp")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 06:50:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/array-to-polygon-python-script/m-p/721032#M55824</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2021-12-12T06:50:46Z</dc:date>
    </item>
    <item>
      <title>Re: Array to polygon-Python Script</title>
      <link>https://community.esri.com/t5/python-questions/array-to-polygon-python-script/m-p/721033#M55825</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I really don't see a point in developing a tool to do that over simply running a script. People are not going to want to copy a list of lists of lists into a dialog to make a polygon.&amp;nbsp; If your intent is to make an extent polygon (ie a rectangle) that is easily done using an extent object and constructing the polygon from that.&amp;nbsp; There are far easier ways to construct a polygon or polygons that through a dialog interface.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Jan 2016 19:22:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/array-to-polygon-python-script/m-p/721033#M55825</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-01-06T19:22:14Z</dc:date>
    </item>
    <item>
      <title>Re: Array to polygon-Python Script</title>
      <link>https://community.esri.com/t5/python-questions/array-to-polygon-python-script/m-p/721034#M55826</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Dan &amp;amp; Darren, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could able to resolve with little R&amp;amp;D.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the support.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 10 Jan 2016 04:23:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/array-to-polygon-python-script/m-p/721034#M55826</guid>
      <dc:creator>Srinivasa_MurthyNemani</dc:creator>
      <dc:date>2016-01-10T04:23:04Z</dc:date>
    </item>
  </channel>
</rss>

