<?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 can I create a matrix as input in Python tool in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-can-i-create-a-matrix-as-input-in-python-tool/m-p/406190#M31972</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, is there any way to create such matrix:&lt;/P&gt;&lt;P&gt;&lt;IMG alt="3.png" class="image-1 jive-image" src="https://lh4.googleusercontent.com/-4vdvCtqE9Sg/U_CcJL3FffI/AAAAAAAAAmo/AByM27352HA/w626-h513-no/3.png" style="width: 620px; height: 508px;" /&gt;&lt;/P&gt;&lt;P&gt;in the input window and fill it with values. Is it possible in Arcpy or anyhow? The only way i can guess is to input excel table but using third-party inputs makes the work-flow more time consuming.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 14 May 2016 17:01:25 GMT</pubDate>
    <dc:creator>StanislawPolanski</dc:creator>
    <dc:date>2016-05-14T17:01:25Z</dc:date>
    <item>
      <title>How can I create a matrix as input in Python tool</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-create-a-matrix-as-input-in-python-tool/m-p/406190#M31972</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, is there any way to create such matrix:&lt;/P&gt;&lt;P&gt;&lt;IMG alt="3.png" class="image-1 jive-image" src="https://lh4.googleusercontent.com/-4vdvCtqE9Sg/U_CcJL3FffI/AAAAAAAAAmo/AByM27352HA/w626-h513-no/3.png" style="width: 620px; height: 508px;" /&gt;&lt;/P&gt;&lt;P&gt;in the input window and fill it with values. Is it possible in Arcpy or anyhow? The only way i can guess is to input excel table but using third-party inputs makes the work-flow more time consuming.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 14 May 2016 17:01:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-create-a-matrix-as-input-in-python-tool/m-p/406190#M31972</guid>
      <dc:creator>StanislawPolanski</dc:creator>
      <dc:date>2016-05-14T17:01:25Z</dc:date>
    </item>
    <item>
      <title>Re: How can I create a matrix as input in Python tool</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-create-a-matrix-as-input-in-python-tool/m-p/406191#M31973</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are a ton of ways to do stuff like this in python. Are you trying to have a window where the user can enter values by hand into the matrix? I would guess that the most direct approach would be to just use a script tool.&lt;/P&gt;&lt;P&gt;&lt;A href="http://pro.arcgis.com/en/pro-app/arcpy/geoprocessing_and_python/a-quick-tour-of-creating-script-tools.htm" title="http://pro.arcgis.com/en/pro-app/arcpy/geoprocessing_and_python/a-quick-tour-of-creating-script-tools.htm"&gt;What is a script tool?—Geoprocessing and Python | ArcGIS for Desktop&lt;/A&gt; &lt;/P&gt;&lt;P&gt;The input would not come is as matrix but as a list of parameters which you then could add to NumPy matrix if you need to do matrix operations.&lt;/P&gt;&lt;P&gt; &lt;A href="http://docs.scipy.org/doc/numpy-1.10.1/reference/generated/numpy.matrix.html" title="http://docs.scipy.org/doc/numpy-1.10.1/reference/generated/numpy.matrix.html"&gt;numpy.matrix — NumPy v1.10 Manual&lt;/A&gt; &lt;/P&gt;&lt;P&gt;Or one could have the user make in as an xls or csv and then have the script tool take that as an input....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 14 May 2016 19:24:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-create-a-matrix-as-input-in-python-tool/m-p/406191#M31973</guid>
      <dc:creator>forestknutsen1</dc:creator>
      <dc:date>2016-05-14T19:24:07Z</dc:date>
    </item>
    <item>
      <title>Re: How can I create a matrix as input in Python tool</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-create-a-matrix-as-input-in-python-tool/m-p/406192#M31974</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I know i can create a list of parameters, im asking if it's possible to use matrix instead. Thanks for showing interest anyway. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 14 May 2016 21:25:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-create-a-matrix-as-input-in-python-tool/m-p/406192#M31974</guid>
      <dc:creator>StanislawPolanski</dc:creator>
      <dc:date>2016-05-14T21:25:16Z</dc:date>
    </item>
    <item>
      <title>Re: How can I create a matrix as input in Python tool</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-create-a-matrix-as-input-in-python-tool/m-p/406193#M31975</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No, there is no array input directly, except through numpy, especially if you are lookng to emulate that dialog&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 14 May 2016 21:38:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-create-a-matrix-as-input-in-python-tool/m-p/406193#M31975</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-05-14T21:38:28Z</dc:date>
    </item>
    <item>
      <title>Re: How can I create a matrix as input in Python tool</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-create-a-matrix-as-input-in-python-tool/m-p/406194#M31976</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not with a python script tool or toolbox. You could build a custom form with pyside/pyqt and use a QTableWidget for the matrix. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 15 May 2016 03:47:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-create-a-matrix-as-input-in-python-tool/m-p/406194#M31976</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2016-05-15T03:47:57Z</dc:date>
    </item>
    <item>
      <title>Re: How can I create a matrix as input in Python tool</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-create-a-matrix-as-input-in-python-tool/m-p/406195#M31977</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you set up a Python toolbox (.pyt) you can dynamically create a value table parameter input. It's fairly complicated but you do have a lot of control, but still within the GP framework so you don't have to custom-build forms with Qt etc.&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/arcpy/geoprocessing_and_python/defining-parameters-in-a-python-toolbox.htm#ESRI_SECTION1_E2BAA5D4440D41D6AAB948922186905A" title="https://pro.arcgis.com/en/pro-app/arcpy/geoprocessing_and_python/defining-parameters-in-a-python-toolbox.htm#ESRI_SECTION1_E2BAA5D4440D41D6AAB948922186905A"&gt;Defining parameters in a Python toolbox—Geoprocessing and Python | ArcGIS for Desktop&lt;/A&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 15 May 2016 06:02:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-create-a-matrix-as-input-in-python-tool/m-p/406195#M31977</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2016-05-15T06:02:35Z</dc:date>
    </item>
    <item>
      <title>Re: How can I create a matrix as input in Python tool</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-create-a-matrix-as-input-in-python-tool/m-p/406196#M31978</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Of course the options begs the questions as to where in the workflow does this matrix need to be created? Is it a need that this step be calculated within the process or can the process not be broken down into a series of steps... some requiring arcmap be open and running and others not.&amp;nbsp; This information will probably be useful in deciding on the complexity of what you are going to have to do to ensure everything fits together.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 15 May 2016 22:15:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-create-a-matrix-as-input-in-python-tool/m-p/406196#M31978</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-05-15T22:15:48Z</dc:date>
    </item>
    <item>
      <title>Re: How can I create a matrix as input in Python tool</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-create-a-matrix-as-input-in-python-tool/m-p/406197#M31979</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I discounted a GPValueTable originally, but went back after your post and tried it and seems to do what the OP wants.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# import modules
import arcpy
import numpy as np

class Toolbox(object):
&amp;nbsp;&amp;nbsp;&amp;nbsp; def __init__(self):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.label = "SomeToolbox"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.alias = "SomeToolbox"

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # List of tool classes associated with this toolbox
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.tools = [Tool]

class Tool(object):
&amp;nbsp;&amp;nbsp;&amp;nbsp; def __init__(self):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.label = "SomeTool"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.description = "SomeTool"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.canRunInBackground = False

&amp;nbsp;&amp;nbsp;&amp;nbsp; def getParameterInfo(self):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; param = arcpy.Parameter(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; displayName='The Matrix',
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; name='TheMatrix',
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; datatype='GPValueTable',
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; parameterType="Required",
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; direction="Input")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; param.columns = [['GPString', 'Name'], ['Double', 'BinaYog'], ['Double', 'FiberHat'], ['Double', 'ElektrikHat'], ['Double', 'KaraYolu']]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; param.values = [['BinaYog',1,0,0,0],['FiberHat',0,1,0,0],['ElektrikHat',0,0,1,0],['KaraYolu',0,0,0,1]]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return [param]

&amp;nbsp;&amp;nbsp;&amp;nbsp; def execute(self, parameters, messages):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #row[1:] strips off the 1st column
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; matrix = np.array([row[1:] for row in parameters[0].values],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dtype=np.float32)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; messages.addMessage(matrix)&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="200938" alt="Capture.PNG" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/200938_Capture.PNG" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;EDIT: added code to show how to turn the Value Table into a numpy array.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 18:28:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-create-a-matrix-as-input-in-python-tool/m-p/406197#M31979</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2021-12-11T18:28:38Z</dc:date>
    </item>
    <item>
      <title>Re: How can I create a matrix as input in Python tool</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-create-a-matrix-as-input-in-python-tool/m-p/406198#M31980</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It does the job, but anyway it is some kind of trick, isn't it? &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 May 2016 17:04:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-create-a-matrix-as-input-in-python-tool/m-p/406198#M31980</guid>
      <dc:creator>StanislawPolanski</dc:creator>
      <dc:date>2016-05-17T17:04:12Z</dc:date>
    </item>
    <item>
      <title>Re: How can I create a matrix as input in Python tool</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-create-a-matrix-as-input-in-python-tool/m-p/406199#M31981</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It's the closest you'll get to a proper matrix/spreadsheet in the ArcPy/geoprocessing framework. Otherwise you'll have to use an external GUI toolkit, like Qt.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What do you mean "some kind of trick"?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 May 2016 03:12:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-create-a-matrix-as-input-in-python-tool/m-p/406199#M31981</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2016-05-19T03:12:30Z</dc:date>
    </item>
  </channel>
</rss>

