<?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 Script to read from shapefile and insert in matrix. in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/python-script-to-read-from-shapefile-and-insert-in/m-p/63055#M2236</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Everyone,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am working on a Python script that I could use some assistance with.&amp;nbsp; I am trying to take the values within the "P_Area" and "P_Area_1" fields that reside in the Srcfile (variable name for shapefile of interest and insert these values into the first two columns of a matrix.&amp;nbsp; Using Numpy I have managed to set up a n x m matrix with 179 rows and 360 columns.&amp;nbsp; I could use some assistance with the next step of reading the values from these two fields and writing them to the matrix.&amp;nbsp; Any help would be greatly appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have attached the script that is in progress.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 09 Nov 2010 13:47:55 GMT</pubDate>
    <dc:creator>GeorgeBentley</dc:creator>
    <dc:date>2010-11-09T13:47:55Z</dc:date>
    <item>
      <title>Python Script to read from shapefile and insert in matrix.</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/python-script-to-read-from-shapefile-and-insert-in/m-p/63055#M2236</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Everyone,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am working on a Python script that I could use some assistance with.&amp;nbsp; I am trying to take the values within the "P_Area" and "P_Area_1" fields that reside in the Srcfile (variable name for shapefile of interest and insert these values into the first two columns of a matrix.&amp;nbsp; Using Numpy I have managed to set up a n x m matrix with 179 rows and 360 columns.&amp;nbsp; I could use some assistance with the next step of reading the values from these two fields and writing them to the matrix.&amp;nbsp; Any help would be greatly appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have attached the script that is in progress.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Nov 2010 13:47:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/python-script-to-read-from-shapefile-and-insert-in/m-p/63055#M2236</guid>
      <dc:creator>GeorgeBentley</dc:creator>
      <dc:date>2010-11-09T13:47:55Z</dc:date>
    </item>
    <item>
      <title>Re: Python Script to read from shapefile and insert in matrix.</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/python-script-to-read-from-shapefile-and-insert-in/m-p/63056#M2237</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Well it looks like the you are making a cursor in your defined function and trying to use it ouside the function which will cause you problems. If you want a list that contains all of the values for a field I would do it this way.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
cursor=gp.SearchCursor(Srcfile)
row=cursor.Next()
P_Area=[]
P_Area1=[]
while row:
&amp;nbsp;&amp;nbsp;&amp;nbsp; P_Area.append(row.GetValue(P_Area))
&amp;nbsp;&amp;nbsp;&amp;nbsp; P_Area1.append(row.GetValue(P_Area1))
del cursor
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;That gives you two lists. One for each field. How do drop them into a numpy matrix Im not sure since I havnt used it, but this is a better way to get the lists. It may be easier to put the numbers into the matrix as you are taking them from the cursor instead of using the lists. I dont see how you can load a list into a numpy matrix though, at least from the numpy docs.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:24:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/python-script-to-read-from-shapefile-and-insert-in/m-p/63056#M2237</guid>
      <dc:creator>ChrisMathers</dc:creator>
      <dc:date>2021-12-10T22:24:44Z</dc:date>
    </item>
  </channel>
</rss>

