Is it possible to toggle on/off the "Export Data - Allow others to export to different formats" option for a hosted feature layer from the ArcGIS API for Python?
Hi David,
Yes, you can do this with the following:
<SPAN class="keyword token">from</SPAN> arcgis<SPAN class="punctuation token">.</SPAN>gis <SPAN class="keyword token">import</SPAN> GIS <SPAN class="keyword token">from</SPAN> arcgis<SPAN class="punctuation token">.</SPAN>features <SPAN class="keyword token">import</SPAN> FeatureLayerCollection gis <SPAN class="operator token">=</SPAN> GIS<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"https://www.arcgis.com"</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"jskinner_CountySandbox"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"*******"</SPAN><SPAN class="punctuation token">)</SPAN> search_results <SPAN class="operator token">=</SPAN> gis<SPAN class="punctuation token">.</SPAN>content<SPAN class="punctuation token">.</SPAN>search<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'title: MD_Traffic_Cameras'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'Feature Layer'</SPAN><SPAN class="punctuation token">)</SPAN> traffic_cameras_item <SPAN class="operator token">=</SPAN> search_results<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN> trafficCameras_flc <SPAN class="operator token">=</SPAN> FeatureLayerCollection<SPAN class="punctuation token">.</SPAN>fromitem<SPAN class="punctuation token">(</SPAN>traffic_cameras_item<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN>trafficCameras_flc<SPAN class="punctuation token">.</SPAN>properties<SPAN class="punctuation token">)</SPAN> update_dict <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">{</SPAN><SPAN class="string token">'capabilities'</SPAN><SPAN class="punctuation token">:</SPAN><SPAN class="string token">'Query,Extract'</SPAN><SPAN class="punctuation token">}</SPAN> trafficCameras_flc<SPAN class="punctuation token">.</SPAN>manager<SPAN class="punctuation token">.</SPAN>update_definition<SPAN class="punctuation token">(</SPAN>update_dict<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN>trafficCameras_flc<SPAN class="punctuation token">.</SPAN>properties<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>
The service previously only had 'Query' capabilities. The above code will now enable 'Extract' which will allow others to export the data.
@JakeSkinner - Yeah, I often put my IDE into debug mode to view the properties of something. When it's an object with properties, that's usually all I need (in this case it's a free-form dict, so not helpful). Or if I can, I use AGOL Assistant on an item with the properties I want to emulate (in this case, you have to guess that extract means export). Or I use Google and find other users wandering around in the dark helping each other. But none of those would be necessary if there were even a base level of documentation! Can you tag some people at Esri or forward a link to this thread to show them how frustrating this can be? The screenshot I posted above perfectly illustrates how much documentation is missing.
@davedoesgis I'm having trouble locating the documentation as well. One way is to print the properties of a feature layer collection. A good example of this can be found here:
https://developers.arcgis.com/python/guide/updating-feature-layer-properties/
@JakeSkinner - Where can I find documentation on these options? If I go to the documentation for FeatureLayerCollectionManager, that has the update_definition method, which says it's just like the 'properties' property, but that documentation is missing.
I'd love to know more about this specifically, but in general, I often find myself in cases like this where I'm passing in JSON or a dict and it's real guesswork as to what all the options are. After hitting a dead end on the documentation, I end up googling for an answer, which leads me here to GeoNet or to the samples. Sometimes, these solve the problem, but not always, so I'm wondering if there's a better way. thanks.
I'd assume you follow Jake's example above, but just set it to "Query".
Hello!
What would be the way to add/publish a feature layer without the export capabilities?
Thanks,
Marcelo
That's great, thanks Jake Skinner
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.