Subject: setting and updating the symbology for a hosted feature layer created from a zipped FGDB.
Background: I uploaded a zipped FGDB to AGOL and created a hosted feature layer from it. In the visualization tab of that hosted feature layer, I can manually set the symbology and save the layer. When I look at the description or data for the layer (either in Python or in the ArcGIS Online Assistant), I don't see any symbology. For hosted feature layers, it is usually in the data dict in ['layers'][0]['layerDefinition']['drawingInfo']['renderer'] (replace '0' with layer ID, as needed).
Problem: In my hosted feature layer, however, the layerDefinition only contains defaultVisibility (even after I've set symbology). I have several more of these to create and want to automate setting the symbology.
Question: Where is that symbology stored and can I update it with Python? I attempted to set it based on another hosted feature layer that has the symbology I want.
<SPAN class="comment token"># Hosted feature layer created by uploading a zipped FGDB</SPAN>
hfl_item <SPAN class="operator token">=</SPAN> portal<SPAN class="punctuation token">.</SPAN>get_item_by_id<SPAN class="punctuation token">(</SPAN><SPAN class="operator token"><</SPAN>id<SPAN class="operator token">></SPAN><SPAN class="punctuation token">)</SPAN>
hfl_data <SPAN class="operator token">=</SPAN> hfl_item<SPAN class="punctuation token">.</SPAN>get_data<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Hosted feature layer created in Pro with fancy symbology</SPAN>
sym_item <SPAN class="operator token">=</SPAN> portal<SPAN class="punctuation token">.</SPAN>get_item_by_id<SPAN class="punctuation token">(</SPAN><SPAN class="operator token"><</SPAN>id<SPAN class="operator token">></SPAN><SPAN class="punctuation token">)</SPAN>
sym_data <SPAN class="operator token">=</SPAN> sym_item<SPAN class="punctuation token">.</SPAN>get_data<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Copy data from one and save to the other</SPAN>
drawingInfo <SPAN class="operator token">=</SPAN> sym_data<SPAN class="punctuation token">[</SPAN><SPAN class="string token">'layers'</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">'layerDefinition'</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">'drawingInfo'</SPAN><SPAN class="punctuation token">]</SPAN>
hfl_data<SPAN class="punctuation token">[</SPAN><SPAN class="string token">'layers'</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">'layerDefinition'</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">'drawingInfo'</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> drawingInfo
result <SPAN class="operator token">=</SPAN> hfl_item<SPAN class="punctuation token">.</SPAN>update<SPAN class="punctuation token">(</SPAN>data<SPAN class="operator token">=</SPAN>hfl_data<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>
The last line produces the following exception:
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">"C:\eclipse\plugins\org.python.pydev.core_7.3.0.201908161924\pysrc\pydevd.py"</SPAN><SPAN class="punctuation token">,</SPAN> line <SPAN class="number token">2643</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">in</SPAN> <SPAN class="operator token"><</SPAN>module<SPAN class="operator token">></SPAN>
main<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
File <SPAN class="string token">"C:\eclipse\plugins\org.python.pydev.core_7.3.0.201908161924\pysrc\pydevd.py"</SPAN><SPAN class="punctuation token">,</SPAN> line <SPAN class="number token">2636</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">in</SPAN> main
globals <SPAN class="operator token">=</SPAN> debugger<SPAN class="punctuation token">.</SPAN>run<SPAN class="punctuation token">(</SPAN>setup<SPAN class="punctuation token">[</SPAN><SPAN class="string token">'file'</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> None<SPAN class="punctuation token">,</SPAN> None<SPAN class="punctuation token">,</SPAN> is_module<SPAN class="punctuation token">)</SPAN>
File <SPAN class="string token">"C:\eclipse\plugins\org.python.pydev.core_7.3.0.201908161924\pysrc\pydevd.py"</SPAN><SPAN class="punctuation token">,</SPAN> line <SPAN class="number token">1920</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">in</SPAN> run
<SPAN class="keyword token">return</SPAN> self<SPAN class="punctuation token">.</SPAN>_exec<SPAN class="punctuation token">(</SPAN>is_module<SPAN class="punctuation token">,</SPAN> entry_point_fn<SPAN class="punctuation token">,</SPAN> module_name<SPAN class="punctuation token">,</SPAN> file<SPAN class="punctuation token">,</SPAN> globals<SPAN class="punctuation token">,</SPAN> locals<SPAN class="punctuation token">)</SPAN>
File <SPAN class="string token">"C:\eclipse\plugins\org.python.pydev.core_7.3.0.201908161924\pysrc\pydevd.py"</SPAN><SPAN class="punctuation token">,</SPAN> line <SPAN class="number token">1927</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">in</SPAN> _exec
pydev_imports<SPAN class="punctuation token">.</SPAN>execfile<SPAN class="punctuation token">(</SPAN>file<SPAN class="punctuation token">,</SPAN> globals<SPAN class="punctuation token">,</SPAN> locals<SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># execute the script</SPAN>
File <SPAN class="string token">"C:\eclipse\plugins\org.python.pydev.core_7.3.0.201908161924\pysrc\_pydev_imps\_pydev_execfile.py"</SPAN><SPAN class="punctuation token">,</SPAN> line <SPAN class="number token">25</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">in</SPAN> execfile
<SPAN class="keyword token">exec</SPAN><SPAN class="punctuation token">(</SPAN>compile<SPAN class="punctuation token">(</SPAN>contents<SPAN class="operator token">+</SPAN><SPAN class="string token">"\n"</SPAN><SPAN class="punctuation token">,</SPAN> file<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'exec'</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">,</SPAN> glob<SPAN class="punctuation token">,</SPAN> loc<SPAN class="punctuation token">)</SPAN>
File <SPAN class="string token">"C:\Users\daskov\eclipse-workspace\Python Prototypes\src\geoprocessing\upload_zip.py"</SPAN><SPAN class="punctuation token">,</SPAN> line <SPAN class="number token">47</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">in</SPAN> <SPAN class="operator token"><</SPAN>module<SPAN class="operator token">></SPAN>
result <SPAN class="operator token">=</SPAN> hfl_item<SPAN class="punctuation token">.</SPAN>update<SPAN class="punctuation token">(</SPAN>data<SPAN class="operator token">=</SPAN>hfl_data<SPAN class="punctuation token">)</SPAN>
File <SPAN class="string token">"C:\Users\daskov\AppData\Local\ESRI\conda\envs\gis-dev\lib\site-packages\arcgis\gis\__init__.py"</SPAN><SPAN class="punctuation token">,</SPAN> line <SPAN class="number token">7874</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">in</SPAN> update
large_thumbnail<SPAN class="punctuation token">)</SPAN>
File <SPAN class="string token">"C:\Users\daskov\AppData\Local\ESRI\conda\envs\gis-dev\lib\site-packages\arcgis\_impl\portalpy.py"</SPAN><SPAN class="punctuation token">,</SPAN> line <SPAN class="number token">2176</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">in</SPAN> update_item
<SPAN class="keyword token">if</SPAN> _is_http_url<SPAN class="punctuation token">(</SPAN>data<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
File <SPAN class="string token">"C:\Users\daskov\AppData\Local\ESRI\conda\envs\gis-dev\lib\site-packages\arcgis\_impl\connection.py"</SPAN><SPAN class="punctuation token">,</SPAN> line <SPAN class="number token">1308</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">in</SPAN> _is_http_url
<SPAN class="keyword token">return</SPAN> urlparse<SPAN class="punctuation token">(</SPAN>url<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>scheme <SPAN class="keyword token">in</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="string token">'http'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'https'</SPAN><SPAN class="punctuation token">]</SPAN>
File <SPAN class="string token">"C:\Users\daskov\AppData\Local\ESRI\conda\envs\gis-dev\lib\urllib\parse.py"</SPAN><SPAN class="punctuation token">,</SPAN> line <SPAN class="number token">367</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">in</SPAN> urlparse
url<SPAN class="punctuation token">,</SPAN> scheme<SPAN class="punctuation token">,</SPAN> _coerce_result <SPAN class="operator token">=</SPAN> _coerce_args<SPAN class="punctuation token">(</SPAN>url<SPAN class="punctuation token">,</SPAN> scheme<SPAN class="punctuation token">)</SPAN>
File <SPAN class="string token">"C:\Users\daskov\AppData\Local\ESRI\conda\envs\gis-dev\lib\urllib\parse.py"</SPAN><SPAN class="punctuation token">,</SPAN> line <SPAN class="number token">123</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">in</SPAN> _coerce_args
<SPAN class="keyword token">return</SPAN> _decode_args<SPAN class="punctuation token">(</SPAN>args<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="punctuation token">(</SPAN>_encode_result<SPAN class="punctuation token">,</SPAN><SPAN class="punctuation token">)</SPAN>
File <SPAN class="string token">"C:\Users\daskov\AppData\Local\ESRI\conda\envs\gis-dev\lib\urllib\parse.py"</SPAN><SPAN class="punctuation token">,</SPAN> line <SPAN class="number token">107</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">in</SPAN> _decode_args
<SPAN class="keyword token">return</SPAN> tuple<SPAN class="punctuation token">(</SPAN>x<SPAN class="punctuation token">.</SPAN>decode<SPAN class="punctuation token">(</SPAN>encoding<SPAN class="punctuation token">,</SPAN> errors<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">if</SPAN> x <SPAN class="keyword token">else</SPAN> <SPAN class="string token">''</SPAN> <SPAN class="keyword token">for</SPAN> x <SPAN class="keyword token">in</SPAN> args<SPAN class="punctuation token">)</SPAN>
File <SPAN class="string token">"C:\Users\daskov\AppData\Local\ESRI\conda\envs\gis-dev\lib\urllib\parse.py"</SPAN><SPAN class="punctuation token">,</SPAN> line <SPAN class="number token">107</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">in</SPAN> <SPAN class="operator token"><</SPAN>genexpr<SPAN class="operator token">></SPAN>
<SPAN class="keyword token">return</SPAN> tuple<SPAN class="punctuation token">(</SPAN>x<SPAN class="punctuation token">.</SPAN>decode<SPAN class="punctuation token">(</SPAN>encoding<SPAN class="punctuation token">,</SPAN> errors<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">if</SPAN> x <SPAN class="keyword token">else</SPAN> <SPAN class="string token">''</SPAN> <SPAN class="keyword token">for</SPAN> x <SPAN class="keyword token">in</SPAN> args<SPAN class="punctuation token">)</SPAN>
AttributeError<SPAN class="punctuation token">:</SPAN> <SPAN class="string token">'dict'</SPAN> object has no attribute <SPAN class="string token">'decode'</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>