On ArcGIS online there is an Item Information section that ranks the completeness of item metadata.
Is it possible to access this information using the Python API?
Hi Alex Gilvarry,
Please have a look at the script below. I use this to publish data (Feature Classes in a zipped File Geodatabase) and populate all the metadata at once. In this way I have a very high Item Information score immediately after publishing π
The input should be:
E.g. data = 'C:/Data/MY_NEW_FGDB.gdb.zip'
E.g. service_thumbnail_path = 'C:/Data/Thumbnail_test.png'
What do you think?
HTH,
Egge-Jan
<SPAN class="comment token">## ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++</SPAN> <SPAN class="comment token">## Script: agol_publish_fc_from_fgdb_to_featureserver_layer.py</SPAN> <SPAN class="comment token">## Goal: to publish a Feature Class from a File Geodatabase to a FeatureServer Layer</SPAN> <SPAN class="comment token">## Author: Egge-Jan Polle - Tensing GIS Consultancy</SPAN> <SPAN class="comment token">## Date: April 3, 2019</SPAN> <SPAN class="comment token">## ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++</SPAN> <SPAN class="comment token">#</SPAN> <SPAN class="comment token"># This script should be run within a specific ArcGIS/Python environment using the batch file below</SPAN> <SPAN class="comment token"># (This batch file comes with the installation of ArcGIS Pro)</SPAN> <SPAN class="comment token"># "C:\Program Files\ArcGIS\Pro\bin\Python\scripts\propy.bat" agol_publish_fc_from_fgdb_to_featureserver_layer.py</SPAN> <SPAN class="comment token">#</SPAN> <SPAN class="keyword token">import</SPAN> os<SPAN class="punctuation token">,</SPAN> datetime <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> provide_credentials <SPAN class="keyword token">import</SPAN> provide_credentials <SPAN class="comment token"># Variables to complete before publishing the service =====================================================================================</SPAN> <SPAN class="comment token"># data - The path to the zip file containing the input File Geodatabase</SPAN> <SPAN class="comment token"># E.g.'C:/Data/MY_NEW_FGDB.gdb.zip'</SPAN> data <SPAN class="operator token">=</SPAN> <SPAN class="string token">''</SPAN> <SPAN class="comment token"># service_name - The name of the FeatureServer</SPAN> <SPAN class="comment token"># E.g. 'MY_VERY_FIRST_FEATURE_SERVER'</SPAN> service_name <SPAN class="operator token">=</SPAN> <SPAN class="string token">'MY_VERY_FIRST_FEATURE_SERVER_TEST'</SPAN> <SPAN class="comment token"># service_description - Description of the item. In the Dutch interface: "Beschrijving"</SPAN> <SPAN class="comment token"># E.g. 'Here you can put a description of the Feature Layer'</SPAN> service_description <SPAN class="operator token">=</SPAN> <SPAN class="string token">'Here you can put a description of the Feature Layer'</SPAN> <SPAN class="comment token"># service_snippet - Provide a short summary (limit to max 250 characters) of the what the item is.</SPAN> <SPAN class="comment token"># E.g. 'Here you can put a short snippet describing the Feature Layer'</SPAN> service_snippet <SPAN class="operator token">=</SPAN> <SPAN class="string token">'Here you can put a short snippet describing the Feature Layer'</SPAN> <SPAN class="comment token"># service_terms_of_use - Any license information or restrictions regarding the content. In the Dutch interface: "Gebruiksvoorwaarden"</SPAN> <SPAN class="comment token"># E.g. 'FOR INTERNAL USE ONLY'</SPAN> service_terms_of_use <SPAN class="operator token">=</SPAN> <SPAN class="string token">'FOR INTERNAL USE ONLY'</SPAN> <SPAN class="comment token"># service_credits - Information on the source of the content. In the Dutch interface: "Credits (toeschrijving)"</SPAN> <SPAN class="comment token"># E.g. 'Β© Me, myself and I'</SPAN> service_credits <SPAN class="operator token">=</SPAN> <SPAN class="string token">'Β© Me, myself and I'</SPAN> <SPAN class="comment token"># service_tags - Tags listed as comma-separated values, or a list of strings. Used for searches on items. In the Dutch interface: "Labels"</SPAN> <SPAN class="comment token"># E.g. ['INSPIRE','Open Data']</SPAN> service_tags <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="string token">'INSPIRE'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'Open Data'</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="comment token"># service_wkid - To set the targetSR to the SR of your input data.</SPAN> <SPAN class="comment token"># If you don't specify the targetSR data will be transformed to wkid 102100 (-> wkid 3857 -> Web Mercator)</SPAN> <SPAN class="comment token"># E.g. 28992 (i.e. RD_New)</SPAN> service_wkid <SPAN class="operator token">=</SPAN> <SPAN class="number token">28992</SPAN> <SPAN class="comment token"># service_thumbnail_path - The path to a thumbnail file (a 600*400 pixels PNG file) for your service</SPAN> <SPAN class="comment token"># E.g.'C:/Data/Thumbnail_test.png'</SPAN> service_thumbnail_path <SPAN class="operator token">=</SPAN> <SPAN class="string token">''</SPAN> <SPAN class="comment token"># =========================================================================================================================================</SPAN> <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">'==================='</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN>str<SPAN class="punctuation token">(</SPAN>datetime<SPAN class="punctuation token">.</SPAN>datetime<SPAN class="punctuation token">.</SPAN>now<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">' - Start'</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">'First you have to log in to ArcGIS Online'</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># Log in</SPAN> username<SPAN class="punctuation token">,</SPAN> password <SPAN class="operator token">=</SPAN> provide_credentials<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> my_agol <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> username<SPAN class="punctuation token">,</SPAN> password<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">del</SPAN> password <SPAN class="comment token"># It is best to remove the password from memory asap</SPAN> <SPAN class="comment token"># Add input File Geodatabase</SPAN> filegdb <SPAN class="operator token">=</SPAN> my_agol<SPAN class="punctuation token">.</SPAN>content<SPAN class="punctuation token">.</SPAN>add<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">{</SPAN><SPAN class="string token">"type"</SPAN> <SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"File Geodatabase"</SPAN><SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">,</SPAN> data<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN>str<SPAN class="punctuation token">(</SPAN>datetime<SPAN class="punctuation token">.</SPAN>datetime<SPAN class="punctuation token">.</SPAN>now<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">" - Input FGDB has been added to content on ArcGIS Online"</SPAN><SPAN class="punctuation token">)</SPAN> wait <SPAN class="operator token">=</SPAN> input<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Optionally: check your content - PRESS ENTER TO CONTINUE"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># Publish the FeatureServer</SPAN> srv_publish_parameters <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">{</SPAN><SPAN class="string token">'name'</SPAN> <SPAN class="punctuation token">:</SPAN> service_name<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'description'</SPAN> <SPAN class="punctuation token">:</SPAN> service_description<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'copyrightText'</SPAN> <SPAN class="punctuation token">:</SPAN> service_credits<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'targetSR'</SPAN> <SPAN class="punctuation token">:</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="string token">'wkid'</SPAN> <SPAN class="punctuation token">:</SPAN> service_wkid <SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">}</SPAN> published_service <SPAN class="operator token">=</SPAN> filegdb<SPAN class="punctuation token">.</SPAN>publish<SPAN class="punctuation token">(</SPAN>publish_parameters<SPAN class="operator token">=</SPAN>srv_publish_parameters<SPAN class="punctuation token">)</SPAN> item_id <SPAN class="operator token">=</SPAN> published_service<SPAN class="punctuation token">.</SPAN>id <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN>str<SPAN class="punctuation token">(</SPAN>datetime<SPAN class="punctuation token">.</SPAN>datetime<SPAN class="punctuation token">.</SPAN>now<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">" - Service has been published on ArcGIS Online"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN>str<SPAN class="punctuation token">(</SPAN>datetime<SPAN class="punctuation token">.</SPAN>datetime<SPAN class="punctuation token">.</SPAN>now<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">" - The ItemID of the new service is: {}"</SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN>item_id<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN> wait <SPAN class="operator token">=</SPAN> input<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Optionally: check your content - PRESS ENTER TO CONTINUE"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># Update description of the service item</SPAN> item_properties <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">{</SPAN><SPAN class="string token">'snippet'</SPAN> <SPAN class="punctuation token">:</SPAN> service_snippet<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'title'</SPAN> <SPAN class="punctuation token">:</SPAN> service_name<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'description'</SPAN> <SPAN class="punctuation token">:</SPAN> service_description<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'licenseInfo'</SPAN> <SPAN class="punctuation token">:</SPAN> service_terms_of_use<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'accessInformation'</SPAN> <SPAN class="punctuation token">:</SPAN> service_credits<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'tags'</SPAN> <SPAN class="punctuation token">:</SPAN> service_tags<SPAN class="punctuation token">}</SPAN> <SPAN class="keyword token">if</SPAN> published_service<SPAN class="punctuation token">.</SPAN>update<SPAN class="punctuation token">(</SPAN>item_properties<SPAN class="punctuation token">,</SPAN> thumbnail<SPAN class="operator token">=</SPAN>service_thumbnail_path<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN>str<SPAN class="punctuation token">(</SPAN>datetime<SPAN class="punctuation token">.</SPAN>datetime<SPAN class="punctuation token">.</SPAN>now<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">" - The item properties and the thumbnail of the published service have been updated"</SPAN><SPAN class="punctuation token">)</SPAN> wait <SPAN class="operator token">=</SPAN> input<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Optionally: check your content - PRESS ENTER TO CONTINUE"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># Remove the input File Geodatabase from ArcGIS Online (as it is no longer needed)</SPAN> <SPAN class="keyword token">if</SPAN> my_agol<SPAN class="punctuation token">.</SPAN>content<SPAN class="punctuation token">.</SPAN>delete_items<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">[</SPAN>filegdb<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN>str<SPAN class="punctuation token">(</SPAN>datetime<SPAN class="punctuation token">.</SPAN>datetime<SPAN class="punctuation token">.</SPAN>now<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">" - The input FGDB has been deleted from the content on ArcGIS Online"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">'==================='</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN>str<SPAN class="punctuation token">(</SPAN>datetime<SPAN class="punctuation token">.</SPAN>datetime<SPAN class="punctuation token">.</SPAN>now<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">" - Your Feature Layer has been published"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">'==================='</SPAN><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>β</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><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>
provide_credentials.py:
<SPAN class="keyword token">import</SPAN> json<SPAN class="punctuation token">,</SPAN> os <SPAN class="keyword token">from</SPAN> getpass <SPAN class="keyword token">import</SPAN> getpass <SPAN class="comment token">#to accept passwords in an interactive fashion</SPAN> <SPAN class="keyword token">def</SPAN> <SPAN class="token function">provide_credentials</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN> file_with_credentials <SPAN class="operator token">=</SPAN> <SPAN class="string token">'my_credentials.json'</SPAN> username <SPAN class="operator token">=</SPAN> <SPAN class="string token">''</SPAN> password <SPAN class="operator token">=</SPAN> <SPAN class="string token">''</SPAN> <SPAN class="keyword token">if</SPAN> os<SPAN class="punctuation token">.</SPAN>path<SPAN class="punctuation token">.</SPAN>exists<SPAN class="punctuation token">(</SPAN>file_with_credentials<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">with</SPAN> open<SPAN class="punctuation token">(</SPAN>file_with_credentials<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">as</SPAN> f<SPAN class="punctuation token">:</SPAN> data <SPAN class="operator token">=</SPAN> json<SPAN class="punctuation token">.</SPAN>load<SPAN class="punctuation token">(</SPAN>f<SPAN class="punctuation token">)</SPAN> username <SPAN class="operator token">=</SPAN> data<SPAN class="punctuation token">[</SPAN><SPAN class="string token">'username'</SPAN><SPAN class="punctuation token">]</SPAN> password <SPAN class="operator token">=</SPAN> data<SPAN class="punctuation token">[</SPAN><SPAN class="string token">'password'</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="keyword token">if</SPAN> <SPAN class="operator token">not</SPAN> username <SPAN class="operator token">or</SPAN> username <SPAN class="operator token">==</SPAN> <SPAN class="string token">'USERNAME'</SPAN> <SPAN class="operator token">or</SPAN> <SPAN class="operator token">not</SPAN> password <SPAN class="operator token">or</SPAN> password <SPAN class="operator token">==</SPAN> <SPAN class="string token">'PASSWORD'</SPAN><SPAN class="punctuation token">:</SPAN> username <SPAN class="operator token">=</SPAN> input<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'Please enter your username: '</SPAN><SPAN class="punctuation token">)</SPAN> password <SPAN class="operator token">=</SPAN> getpass<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'Please enter your password (this will remain invisible): '</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">return</SPAN> username<SPAN class="punctuation token">,</SPAN> passwordββββββββββββββββ<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>
my_credentials.json:
<SPAN class="punctuation token">{</SPAN> <SPAN class="string token">"username"</SPAN><SPAN class="punctuation token">:</SPAN><SPAN class="string token">"USERNAME"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"password"</SPAN><SPAN class="punctuation token">:</SPAN><SPAN class="string token">"PASSWORD"</SPAN> <SPAN class="punctuation token">}</SPAN>ββββ<SPAN class="line-numbers-rows"><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN><SPAN>β</SPAN></SPAN>
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.