I'm trying to create a script that will access an AGOL hosted feature service (polygon), run a FeatureToPoint geoprocessing task against it, and overwrite a separate hosted feature service. Below is a code snippet
outFC <SPAN class="operator token">=</SPAN> <SPAN class="string token">"C:/GIS/AmericanWater/JamesMitchell/Poly2Point.gdb/WVAW_LineB_Projects_Points"</SPAN>
shh <SPAN class="operator token">=</SPAN> securityhandlerhelper<SPAN class="punctuation token">.</SPAN>securityhandlerhelper<SPAN class="punctuation token">(</SPAN>securityinfo<SPAN class="operator token">=</SPAN>securityinfo<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">if</SPAN> shh<SPAN class="punctuation token">.</SPAN>valid <SPAN class="operator token">==</SPAN> <SPAN class="token boolean">False</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">print</SPAN> shh<SPAN class="punctuation token">.</SPAN>message
<SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN>
fl<SPAN class="operator token">=</SPAN> FeatureLayer<SPAN class="punctuation token">(</SPAN>
url<SPAN class="operator token">=</SPAN>PolyUrl<SPAN class="punctuation token">,</SPAN>
securityHandler<SPAN class="operator token">=</SPAN>shh<SPAN class="punctuation token">.</SPAN>securityhandler<SPAN class="punctuation token">,</SPAN>
proxy_port<SPAN class="operator token">=</SPAN>proxy_port<SPAN class="punctuation token">,</SPAN>
proxy_url<SPAN class="operator token">=</SPAN>proxy_url<SPAN class="punctuation token">,</SPAN>
initialize<SPAN class="operator token">=</SPAN><SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">)</SPAN>
sql <SPAN class="operator token">=</SPAN> <SPAN class="string token">"MapReady = 'Yes'"</SPAN>
resFeats <SPAN class="operator token">=</SPAN> fl<SPAN class="punctuation token">.</SPAN>query<SPAN class="punctuation token">(</SPAN>where<SPAN class="operator token">=</SPAN>sql<SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>FeatureToPoint_management<SPAN class="punctuation token">(</SPAN>resFeats<SPAN class="punctuation token">,</SPAN>outFC<SPAN class="punctuation token">,</SPAN><SPAN class="string token">"CENTROID"</SPAN><SPAN class="punctuation token">)</SPAN>
fl <SPAN class="operator token">=</SPAN> PointUrl
<SPAN class="keyword token">print</SPAN> fl<SPAN class="punctuation token">.</SPAN>updateFeature<SPAN class="punctuation token">(</SPAN>features<SPAN class="operator token">=</SPAN>resFeats<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="string token">"Finished"</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>
I get the following message when it reaches the FeaureToPoint geoprocessing tool
Traceback <SPAN class="punctuation token">(</SPAN>most recent call last<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
File <SPAN class="string token">"G:\ArcMap Settings\Python\Poly2Point.py"</SPAN><SPAN class="punctuation token">,</SPAN> line <SPAN class="number token">53</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">in</SPAN> <SPAN class="operator token"><</SPAN>module<SPAN class="operator token">></SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>FeatureToPoint_management<SPAN class="punctuation token">(</SPAN>resFeats<SPAN class="punctuation token">,</SPAN>outFC<SPAN class="punctuation token">,</SPAN><SPAN class="string token">"CENTROID"</SPAN><SPAN class="punctuation token">)</SPAN>
File <SPAN class="string token">"C:\Program Files (x86)\ArcGIS\Desktop10.3\ArcPy\arcpy\management.py"</SPAN><SPAN class="punctuation token">,</SPAN> line <SPAN class="number token">2583</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">in</SPAN> FeatureToPoint
<SPAN class="keyword token">raise</SPAN> e
RuntimeError<SPAN class="punctuation token">:</SPAN> Object<SPAN class="punctuation token">:</SPAN> Error <SPAN class="keyword token">in</SPAN> executing tool<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
It seems like the tool doesn't like that my input features are coming from a AGOL hosted service. Does this matter? Is there a way around this?
Thanks,
James