I'm trying to use a polygon supplied by the user to return a single feature class with multiple records in it.
I am clipping from 2 polygons sucessfully, they both have the same attributes.
I then thought I would just stick them into a feature class or set, return that and I would be good to go.
I tried to create a FeatureSet then use .load() to load my results into it.
But I only get the last result from the loop, it only ever returns a single result but I want to return multiple.
arcpy<SPAN class="punctuation token">.</SPAN>env<SPAN class="punctuation token">.</SPAN>overwriteOutput <SPAN class="operator token">=</SPAN> <SPAN class="token boolean">True</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>env<SPAN class="punctuation token">.</SPAN>workspace <SPAN class="operator token">=</SPAN> r<SPAN class="string token">'C:\Jim\BSelect.gdb'</SPAN>
fcList <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>ListFeatureClasses<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN>fcList<SPAN class="punctuation token">)</SPAN>
poly <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>GetParameterAsText<SPAN class="punctuation token">(</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">)</SPAN>
limits <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="string token">'Limits_UK_Mosaic'</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="string token">'Limits_UK_COMORG'</SPAN><SPAN class="punctuation token">]</SPAN>
<SPAN class="keyword token">def</SPAN> <SPAN class="token function">cliplimit</SPAN><SPAN class="punctuation token">(</SPAN>clippee<SPAN class="punctuation token">,</SPAN> clipper<SPAN class="punctuation token">,</SPAN> output<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>Clip_analysis<SPAN class="punctuation token">(</SPAN>clippee<SPAN class="punctuation token">,</SPAN> clipper<SPAN class="punctuation token">,</SPAN> output<SPAN class="punctuation token">)</SPAN>
feature_set <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>FeatureSet<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># loop limits and clip tifs</SPAN>
<SPAN class="keyword token">for</SPAN> i <SPAN class="keyword token">in</SPAN> range<SPAN class="punctuation token">(</SPAN>len<SPAN class="punctuation token">(</SPAN>limits<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>AddMessage<SPAN class="punctuation token">(</SPAN>limits<SPAN class="punctuation token">[</SPAN>i<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN>
output <SPAN class="operator token">=</SPAN> <SPAN class="string token">'in_memory\\'</SPAN> <SPAN class="operator token">+</SPAN> limits<SPAN class="punctuation token">[</SPAN>i<SPAN class="punctuation token">]</SPAN>
cliplimit<SPAN class="punctuation token">(</SPAN>limits<SPAN class="punctuation token">[</SPAN>i<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> poly<SPAN class="punctuation token">,</SPAN> output<SPAN class="punctuation token">)</SPAN>
feature_set<SPAN class="punctuation token">.</SPAN>load<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'in_memory\\'</SPAN> <SPAN class="operator token">+</SPAN> limits<SPAN class="punctuation token">[</SPAN>i<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>SetParameter<SPAN class="punctuation token">(</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN> feature_set<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>There something I dont get about feature class/sets I think not sure.
I just want to return a thing with both results in to my web app but I can only get one atm.
Cheers
Jim