Essentially, I need to get a Numpy array (rows = x, cols = 3) to a geodatabase table. What is happening is when I specify the dtype of the array to get the field names / types for the table, the array gets reshaped.
Any ideas?
<SPAN class="comment token">#format array to create table from</SPAN>
<SPAN class="comment token">#array of nearest values... reshaped to: rows=(inXY * toReturn), columns=3</SPAN>
formArray <SPAN class="operator token">=</SPAN> numpy<SPAN class="punctuation token">.</SPAN>array<SPAN class="punctuation token">(</SPAN>listArray<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>reshape<SPAN class="punctuation token">(</SPAN><SPAN class="operator token">-</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="number token">3</SPAN><SPAN class="punctuation token">)</SPAN>
dts <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">'IN_OID'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'<i4'</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">'NEAR_OID'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'<i4'</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">'NEAR_DIST'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'<f8'</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">]</SPAN>
finalArray <SPAN class="operator token">=</SPAN> numpy<SPAN class="punctuation token">.</SPAN>rec<SPAN class="punctuation token">.</SPAN>fromrecords<SPAN class="punctuation token">(</SPAN>formArray<SPAN class="punctuation token">,</SPAN> dtype <SPAN class="operator token">=</SPAN> dts<SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">#export to geodatabase table</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>NumPyArrayToTable<SPAN class="punctuation token">(</SPAN>finalArray<SPAN class="punctuation token">,</SPAN> r<SPAN class="string token">'...\ArcGIS\Default.gdb\out_table'</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
How the array structure should look: How the array looks after specifying dtype
And this is what the output table looks like (notice it has 60 rows... it should only contain 20)
