I would like to use numpy array from a excel file for a selection of features. Do I have to convert the array to a list first, and how to do that? With the following code I get the following error? Or some better ideas, many files to select?
<SPAN class="comment token">#!/usr/bin/env python</SPAN>
<SPAN class="comment token"># -*- coding: iso-8859-1 -*-</SPAN>
<SPAN class="comment token"># </SPAN>
<SPAN class="keyword token">import</SPAN> numpy <SPAN class="keyword token">as</SPAN> np
<SPAN class="keyword token">import</SPAN> arcpy
<SPAN class="keyword token">import</SPAN> pandas <SPAN class="keyword token">as</SPAN> pd
<SPAN class="keyword token">import</SPAN> sys<SPAN class="punctuation token">,</SPAN> os
<SPAN class="comment token"># Encoding der Standardausgabe herausfinden</SPAN>
stdout_encoding <SPAN class="operator token">=</SPAN> sys<SPAN class="punctuation token">.</SPAN>stdout<SPAN class="punctuation token">.</SPAN>encoding <SPAN class="operator token">or</SPAN> sys<SPAN class="punctuation token">.</SPAN>getfilesystemencoding<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
inTable <SPAN class="operator token">=</SPAN> r<SPAN class="string token">"R:\Karto\Bierer2019\FFH_MEKA_FACT\Tabellen\wk13.xlsx"</SPAN>
outP <SPAN class="operator token">=</SPAN> r<SPAN class="string token">"R:\Karto\Bierer2019\FFH_MEKA_FACT\Shape"</SPAN>
fc <SPAN class="operator token">=</SPAN> r<SPAN class="string token">"\\RPKSF001\GIS_DATA\ArcUISTools15\Data\UIS_ALk.gdb\UIS_0100000047100001"</SPAN>
fl <SPAN class="operator token">=</SPAN> <SPAN class="string token">"ALK"</SPAN>
<SPAN class="comment token"># Tabelle</SPAN>
Flrstkz <SPAN class="operator token">=</SPAN> pd<SPAN class="punctuation token">.</SPAN>read_excel<SPAN class="punctuation token">(</SPAN>inTable<SPAN class="punctuation token">,</SPAN> index_col<SPAN class="operator token">=</SPAN>None<SPAN class="punctuation token">,</SPAN> na_values<SPAN class="operator token">=</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">'NA'</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> parse_cols <SPAN class="operator token">=</SPAN> <SPAN class="string token">"A"</SPAN><SPAN class="punctuation token">)</SPAN>
x <SPAN class="operator token">=</SPAN> np<SPAN class="punctuation token">.</SPAN>array<SPAN class="punctuation token">(</SPAN>Flrstkz<SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>MakeFeatureLayer_management<SPAN class="punctuation token">(</SPAN>fc<SPAN class="punctuation token">,</SPAN> fl<SPAN class="punctuation token">)</SPAN>
field <SPAN class="operator token">=</SPAN> <SPAN class="string token">'FLURSTUECKSKENNZEICHEN'</SPAN>
<SPAN class="keyword token">for</SPAN> i <SPAN class="keyword token">in</SPAN> x<SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">print</SPAN> i
sc <SPAN class="operator token">=</SPAN> <SPAN class="string token">"%s = + %s"</SPAN><SPAN class="punctuation token">(</SPAN>field<SPAN class="punctuation token">,</SPAN> i<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN> sc
arcpy<SPAN class="punctuation token">.</SPAN>SelectLayerByAttribute_management <SPAN class="punctuation token">(</SPAN>fl<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"NEW_SELECTION"</SPAN><SPAN class="punctuation token">,</SPAN> sc<SPAN class="punctuation token">)</SPAN>
outFc <SPAN class="operator token">=</SPAN> os<SPAN class="punctuation token">.</SPAN>path<SPAN class="punctuation token">.</SPAN>join<SPAN class="punctuation token">(</SPAN>outP<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"WK13_"</SPAN><SPAN class="operator token">+</SPAN> i <SPAN class="operator token">+</SPAN> <SPAN class="string token">".shp"</SPAN><SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>CopyFeatures_management<SPAN class="punctuation token">(</SPAN>fl<SPAN class="punctuation token">,</SPAN> outFc<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></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>[8334100002890000384]
Traceback (most recent call last):
File "R:/Karto/zGIS/Python_2019/NumPy/NumPY_MEKA_FAKT.py", line 30, in <module>
sc = "%s = + %s"(field, i)
TypeError: 'str' object is not callable
Better would be the "quercy" in (np.array)?