How To: Copy/clone content from one ArcGIS Online ...

文章推薦指數: 80 %
投票人數:10人

Procedure. The following Python script (run from a Jupyter Notebook interface) uses the clone_items method in the arcgis module to copy hosted ... English Deutsch Español français Português 中文 日本語 Menu Products Desktop Enterprise Online Developers Apps MoreProducts LegacyProducts KnowledgeBase Downloads OtherResources OtherResources GISDictionary SupportServicesBlog EsriCommunity ArcGISforDevelopers wiki.GIS.com EarlyAdopterProgram ArcGISIdeas EsriSupportServices ArcGISBlogs ArcGISCodeSharing ProductLifeCycles SupportOptions RequestCase StartChat ManageCases PremiumSupport PrioritySupport ContactSupport Continueintheapp Continue Stayonweb TechnicalSupport EsriSupportv5.5isnowavailablefordownload! EsriSupportv5.5isnowavailablefordownload! Seewhat'snew!. CloseandDon'tRemind Backtoresults Print Share Contentfeedbackiscurrentlyofflineformaintenance.Pleasetryagaininafewminutes. BeTheFirstToGetSupportUpdates Wanttoknowaboutthelatesttechnicalcontentandsoftwareupdates? GetNotifications IsThisContentHelpful? SearchonEsriCommunity SubmittoArcGISIdeas Backtotop HowTo:Copy/clonecontentfromoneArcGISOnlineorganizationorPortalforArcGIStoanother Summary ArcGISOnlineAssistantisoftenconsideredastheonlywaytocopycontentsfromoneArcGISOnlineorganizationorPortalforArcGIS toanother.However,theinstructionsprovidedbelowdescribehowtodothisusingtheArcGISAPIforPythontocopycontentswebmaps,configurableapps,dashboards,shapefiles,filegeodatabases,andothers. Procedure ThefollowingPythonscript(runfromaJupyterNotebookinterface)usestheclone_items methodinthearcgismodule tocopyhostedfeaturelayersandtheunderlyingservicefromoneArcGISOnlineorganizationtoanother.ThesamplecellsusedareintendedforuseinJupyterNotebook,butcanbemodifiedforuseinastandalonescript. Note: TheuserexecutingthecopyshouldbeanadmininthetargetGIS. Importthenecessarymodule. fromarcgis.gisimportGIS SpecifytheURLandcredentialoftheoriginArcGISOnlineaccount.  #ForArcGISOnline gis=GIS("https://arcgis.com","Username","Password") #ForPortalforArcGIS gis=GIS("https://..com/portal","Username","Password") Specifytheusernameoftheaccounttoexportthecloneditems.  username_2=input("Enterusernameoftargetorganization:") #ForArcGISOnline gis2=GIS("https://arcgis.com",username_2) #ForPortalforArcGIS gis2=GIS("https://..com/portal",username_2) Createalistofitemstoclone.Thereareafewoptionstodoso: Setthemaximumnumberofitemstoexport: num_items=5 items=gis1.content.search(query="owner:{}".format(username),max_items=num_items,sort_field='id',sort_order='desc') Getthemaximumnumberofitemsasinputparameter: num_items=int(input("Howmanyitemswouldyouliketoclone?")) items=gis1.content.search(query="owner:{}".format(username),max_items=num_items,sort_field='id',sort_order='desc') Getaspecificitemusingitemid: itemid=''#inserttheitemid items=gis.content.get(itemid) UsetheSearchfunctionwithaquerytosearchforspecificitemstoclone.Thegeneralformatisasfollows: items=gis.content.search(query,item_type=None,sort_field='avgRating',sort_order='desc',max_items=10,outside_org=False,categories=None,category_filters=None) Printthelistoftheitemstobecloned. print(str(len(items))+"itemswillbecloned.Seethelistbelow:") items Createalogictoclonetheitemsusingthe clone_items() functionandtohandleanerrorifthecloningprocessfails.  defdeep_copy_content(input_list): foritemininput_list: try: print("Cloning"+item.title) copy_list=[] copy_list.append(item) gis2.content.clone_items(copy_list,copy_data=True,search_existing_items=True) print("Successfullycloned"+item.title) exceptExceptionase: print(e) print("Thefunctionhascompleted") deep_copy_content(items) Note: Asanalternative,theclone_items()functioncanalsobeusedoutsideofthelogiccodeblockifhandlingexceptionisunnecessary.Afterstep5,theclone_items()functioncanbeusedassuch: gis2.content.clone_items([items]) Thefollowingshowsasampleofafullscript: fromarcgis.gisimportGIS gis=GIS("https://arcgis.com","Username","Password") username_2=input("Enterusernameoftargetorganization:") gis2=GIS("https://arcgis.com",username_2) #Getaspecificitemusingitemid: itemid='cc94b27a35d14f40987d96f3d2a39e67' items=gis.content.get(itemid)  print(str(len(items))+"itemswillbecloned.Seethelistbelow:") items defdeep_copy_content(input_list): foritemininput_list: try: print("Cloning"+item.title) copy_list=[] copy_list.append(item) gis2.content.clone_items(copy_list,copy_data=True,search_existing_items=True) print("Successfullycloned"+item.title) exceptExceptionase: print(e) print("Thefunctionhascompleted") deep_copy_content(items) RelatedInformation arcgis.gismodule:ContentManagerHowTo:Findspecificitemsusingqueriesinthearcgis.gismodulewiththeArcGISPythonAPIArcGISOnline:Hostedlayers LastPublished:5/13/2021 ArticleID:000022252 Software:PortalforArcGIS10.8.1,10.8,10.7.1,10.7,10.6.1,10.6 Wanttogetnotified? IsThisContentHelpful? DownloadtheEsriSupportApponyourphonetoreceivenotificationswhennewcontentisavailableforEsriproductsyouuse DownloadtheEsriSupportApponyourphonetoreceivenotificationswhennewcontentisavailableforEsriproductsyouuse IsThisContentHelpful? Yes No Howcanwemakethisbetter?Pleaseprovideasmuchdetailaspossible. Submit ContactourSupportTeam RequestCase StartChat TranslationFeedback Howcanwemakethistranslationbetter? Submit Getnotifiedaboutlatestupdatestothistechnicalarticle? Yes No DoyouwanttoUnsubscribe? Yes No PleasebeawarethatEsriwillbeupgradinginternalsystemsFriSep16,5pmthroughMonSep19,5amPacificTime.Duringthismaintenancewindow,youmayexperiencedelaysinreachingaTechnicalSupportanalystorreceivingstatusupdatesonyourexistingcase. Loading



請為這篇文章評分?