clone_items() clones the dependencies for the more complex items listed above. For example, cloning an existing web application, clones the web map and all ...
ArcGISAPIforPythonHomeSamplesAPIReferenceMenuOverviewKeyfeaturesInstallandSetupSystemrequirementsPythonenvironmentsReleasenotesUsingtheAPITheGISgismoduleUsingtheGISWorkingwithdifferentauthenticationschemesAccessingandcreatingcontentManagingyourcontentCloningcontentAccessingandmanaginggroupsAccessingandmanagingusersAccessingItemResourcesPropertiesofyourGISBuildingadistributedGISthroughcollaborationsAdministeringyourGISCustomizingthelookandfeelofyourGISgis.adminmoduleManagingyourGISserversWorkingwithgeometriesFeaturedataandanalysisIntroductiontoDataEngineeringinPythonWorkingwiththeSpatiallyEnabledDataFrameEnrichingGISdatawiththematicinformationImageryandrasteranalysisWorkingwithBigDataUsinggeoprocessingtoolsFindingplaceswithgeocodingPerformingnetworkanalysesMappingandvisualizationManagingArcGISapplicationsDeepLearningwithArcGISNavigationMenuCloningContent
Introduction¶
OnerequestthePythonAPIteamhasheardrepeatedlyfromWebGISadministrators:What'sthebestwaytomovemycontentfromadevelopmentEnterpriseororganizationtostagingtoproduction?
ThisGuideprovidesonepossibleroadmapforhowtogetcontentfromoneWebGIStoanother-atemplatefordemonstratingbasicsoftwareconceptswhentransferringcontentsotheworkflowcanbemodifiedforothertypesofcontentandtailoredforanadministrator'sparticularneed.So,firstquestiontoansweris:Whatdoesitmeantoclone?Merriam-Websterdefinescloneastheactionof"propagat[ing]aclonefrom."(Didn'tIhearmy2ndgradeteacher-andeveryteacherafterthatforthatmatter-sayit'sunhelpfultousethewordyouaredefininginitsdefinition?...)Divingfurtherintothedefinitionofa"clone",itreads"theaggregateofgeneticallyidenticalcellsororganismsasexuallyproducedbyorfromasingleprogenitorcellororganism."Okay,notexactlythecontextwe'reworkinginwhendiscussingaWebGIS.Furtheralongthedefinitionwegettosomethingmorealongthelinesofwhatwe'rethinking:"onethatappearstobeacopyofanoriginalform."BINGO!
LeveragingthePythonAPItoclonecontentfromoneWebGIStoanothercanbethoughtofas"propagatingcontentthatappearstobeacopyoftheoriginalcontent.".Givenallthedifferentcontentanditemtypes,possibleEnterpriseconfigurations,potentialArcGISOnlineOrganizationarrangements,securityconsiderations,anditemdependenciestheclone_items())functionaimstopropagateanexactduplicateofoneitemwithallitsusesandfunctionalityfromanoriginalportaltoasecondportal,buttheremaybecircumstancesthatleadtheclonetocomeclosebutnotquiteproduceanidenticalcopy.Inaddition,thevarietyofmeansforpublishingitemscreatesvaryingpossibilitiesforsupported,related,orsourceitemscreatedduringthepublishingprocess.Therelationshipbetweenanysupported,related,orsourceitemsmustbeconsideredwhencloninganitem.Forexample,theoverwritefunctionalitywillnotbeavailableonclonedhostedfeaturelayeritems,becausetheydonothaveasourcedocumentfromwhichtheywerepublished.TheFAQhereprovidesimportantinformationregardingsourceitemsinArcGISOnline.However,givenoureducationoncloning,wenowknowthatcloninganitemproducesaseconditemwhichappears-butmaynotbeidenticaltotheoriginal.It'simportanttotemperexpectationswhenthinkingaboutthePythonAPIclone_items()function.Theremaybetimesitemswillnotmigrateasexpected.
Whentalkingaboutcloningitems,let'sestablishsomebasicterminology.Cloningcanrefertoallkindsoftransfer,fromArcGISEnterprisetoArcGISOnline,EnterprisetoEnterprise,orArcGISOnlinetoEnterprise.(TheGISCommunitylessfrequentlydiscussestheneedtoclonebetweentwodistinctArcGISOnlineOrganizations,butthatispossibleaswell.)Ratherthantanglingourselvesupwhentryingtodistinguishbetweentheseportaltypeswhilewritingaboutthem,we'llrefertotheportalororganizationwherethecontentoriginatesasthesourceregardlessofportaltype.We'llconsidertheportalororganizationtowhichwe'llclonecontentasthetarget.Onwardwego!
Thisdocumentillustratestheworkflowofgatheringsourceitemsusingasourceadministratoraccount,andcloningthemintoatargetadministratoraccount.Morespecifically,thisguidewalksthroughanapproachofcloningdataservicesknownashostedfeaturelayersthatareusedasbuildingblocksforotherWebGISitems,namelywebmaps.WebMapsconsumethesedataservicesasoperationallayerbuildingblocks.We'llthencloneanArcGISDashboardandaWebMappingApplicationthateachconsumeawebmapaspartoftheirdefinition.Forinformationoneachoftheseitemtypes,pleaseclickthehyperlinksforeachtype.
Thisisanadministratorworkflow.Usingadministratoraccountsguaranteesallnecessaryprivilegeswithinthesourcetoaccesstheitemandanydependenciesandwithinthetargettocreatetheservicesanditems.Thetargetadministratorsubsequentlycancreateuseraccountsandreassignitemownershipand/orgroupmembershipaccordingtoneed.Thismightalsobethesimplestworkflowwhentheportalhasusersmanagedbyanexternalidentitystore.
NOTE:Cloningreliesonthesharingmodeltodeterminetheitemsanyparticularusercanclone.Ifausercanaccessanitem,thatusercancloneit.However,thatusercan'tcreateanythinginthetargetportaltheydon'thavetheappropriateprivilegestocreate.
Anycontentinanyportalmustbeownedbyauser,soatleastoneusermustexistinthetarget.Ifyoudon'tplanonusingtheadministratoraccountsinaworkflowsuchasthis,youmaywanttoinvestigatetheClonePortalusers,groupsandcontentsamplenotebookonhowtodefinefunctionsthatcancopyuserobjectsandthenclonecontentusingthoseaccounts.
Asoriginallywritten,PythonAPIdevelopersdesignedtheclone_items()functionfortransferringthefollowingitemtypes:
HostedWebApplicationsbuiltwithWebAppBuilderorsharedusingConfigurableAppTemplates
WebMaps
HostedFeatureLayers
HostedFeatureLayerViews
FeatureCollections
Survey123Forms
WorkforceProjects
StoryMaps(classic)
OperationViews
Dashboards
QuickCaptureProjects
ArcGISNotebooks
SimpleTypes
Thoseitemswithadownloadoption(seeDatafilesforitemsthatmaybeinaWebGISandavailablefordownload),includingzippedfilegeodatabasesandshapefiles,codesamples,zipfiles,andpackagesamongstothers.
clone_items()clonesthedependenciesforthemorecomplexitemslistedabove.Forexample,cloninganexistingwebapplication,clonesthewebmapandallhostedfeaturelayersreferencedinthemap.
clone_items()willnotclonemapservicesandimageservices.Sincetheseservicescanbepublishedtoserversotherthanthehostedserverinaconfiguration,it'simpossibleforthefunctiontodeterminewheretopublishtheminthetarget.Asaresult,theseitemswillcopyover,butwillcontinuetopointbacktotheoriginalsourceURL.
Let'sworkthroughexamplesofcloningindividualitemsandinspecttheresults.
First,let'simportthenecessarylibrariesandconnecttooursourceandtargetGIS:
Importlibraries¶
Input
frompathlibimportPath
importsys
fromarcgis.gisimportGIS,Item
fromarcgis.envimportactive_gis
fromarcgis.featuresimportFeatureLayerCollection
fromarcgis.mappingimportWebMap
Connecttosourceandtargetportals¶
Let'sstartfromadiscoverypositionasanadministrator.We'llsimulateanadministratorwho'sbeentestinganddevelopingusinganon-premiseArcGISEnterprisesystemasadevelopmentenvironmentandwantstocloneuserdataintoanArcGISOnlineenvironmentforfurtherdevelopment.
Input
source=GIS(profile="your_ent_admin_profile",verify_cert=False)
print(source)
GIS@https://pythonapi.playground.esri.com/portalversion:7.1
Input
#target=GIS(profile="your_online_admin_profile",verify_cert=False)
target=GIS(profile="cloning_admin",verify_cert=False)
print(target)
GIS@https://geosaurus.maps.arcgis.comversion:8.1
Getstartedwithcloning¶Let'sstartwithanimmediatedemonstrationofwhatclone_items()cando.We'reloggedinasanadministratorandwe'llget()aspecifichostedfeaturelayeritemownedbyoneoftheusersinthesource.We'llthencloneitintothetargetwhileutilizingtheownerparametertospecifyaparticularUserinthetargettoowntheclonedcontent.Wecanquicklyexaminetheresultingurloftheclonedfeaturelayertoconfirmthenewitem.
Input
hosted_flyr=source.content.get("07b60a9efa0342efb66704dfc5aff5c9")
hosted_flyr
Output
HospitalsinArkansas
HospitalsinArkansasintheUnitedStates.FeatureLayerCollectionbyapi_cloner
LastModified:May19,2020
0comments,2views
Input
hosted_flyr.url
Output
'https://pythonapi.playground.esri.com/server/rest/services/Hosted/Hospitals_in_Arkansas/FeatureServer'
Input
cloned_flyr=target.content.clone_items(items=[hosted_flyr],
owner="api_data_owner")
Input
cloned_flyr[0]
Output
HospitalsinArkansas
HospitalsinArkansasintheUnitedStates.FeatureLayerCollectionbyapi_data_owner
LastModified:May19,2020
0comments,0views
Input
cloned_flyr[0].url
Output
'https://services7.arcgis.com/JEwYeAy2cc8qOe3o/arcgis/rest/services/Hospitals_in_Arkansas/FeatureServer'
Wecanseethattheclone_items()functionreturnsalistcontainingthecloneditems.Indexingthelistwecanseetheoperationcreatedanewhostedfeaturelayerinthetargetorganizationownedbytheapi_data_owneruserweenteredastheownerargument.
Cloningmultipleitemssimultaneously¶Wedemonstratedabovepassingoneitemintheitemsparameterlist.Nowlet'sseehowclone_items()willcloneeveryiteminthelist.Firstlet'ssearch()thesourcefunctionforitemsownedbyaparticularuserandclonethelistitemsintoourtargetallatthesametime.
Input
tester_content=source.content.search("owner:api_tester")
tester_content
Output
[,
,
]
Input
cloned_items=target.content.clone_items(items=tester_content)
Input
cloned_items
Output
[,
,
]
Wecanseethattheclone_items()functionclonedalltheitemsinthelistwepassedtotheitemsargument.Lookingattheoutputabove,wecanseealltheitemsinourlistwerecloned.Wecanalsoseethatbynotpassinginanownerargument,theitemsareownedbytheloggedinuserthatranclone_items().
Input
target.users.me.username
Output
'clonerator'
There'saquickdemonstrationofhowtheclone_items()functionreplicatesitemsfromasourcetoatarget.Nowlet'smoveontoiteratingthroughalistofhostedfeaturelayersandworkingwithsomeadditonalparameterstocloneinformationproductsthatconsumethem.
Helperfunctions¶Let'swriteasetofhelperfunctionswecanreusethroughoutthenotebook.
Sincewe'reworkingintwodifferentportalsduringthenotebook,we'llcreateavariablecalledactive_gistorefertoeitheroftheseWebGISsystems.We'llusethatvariableinsideourfunctions,sowecanruntheminsideeachportal.
Input
active_gis=source
Next,we'llcreateafunctionthattakesaUserobjectandaGISobjectasinputandreturnsadictionarywithauniqueitem_typeasthekeyandalistofalltheitemsofthattypeownedbytheuserasthevalue.Sincethisnotebookisgearedtowardsanadministratoruser,theadministratorcanretrievetheinventoryofanyuserwithintheportal
Input
defget_user_items(user,active_gis):
user_inventory={}
user_items=active_gis.content.search(query=f"*ANDowner:{user.username}",
max_items=500)
foriteminuser_items:
ifitem.typenotinuser_inventory:
user_inventory[item.type]=[i
foriinuser_items
ifi.type==item.type]
returnuser_inventory
Next,we'lldefineafunctiontoprinttheoutputfromtheget_user_items()functionwepreviouslycreatedandprintsitinaformattogiveusaquickglimpseatanyuser'siteminventory.
Input
defprint_user_inventory(inventory):
foritype,ilistininventory.items():
try:
print(f"{itype}\n{'-'*50}")
foriinilist:
print(f"{'':3}{i.title:50}")
print("\n")
exceptExceptionase:
print(f"\t\tOperationfailedon:{i.title}")
print(f"\t\tException:{sys.exc_info()[1]}")
continue
Next,we'llcreateafunctionthatwilltakeafeatureserviceitemtypefromtheiteminventorywecreatewithget_user_items()andreturnanyWebMapobjectwithintheinventorythatconsumesthatfeatureservice.Thiscanhelpusmakesurewebmapscontaintheappropriatelayersbetweensourceandtarget.
Input
defget_fs_webmaps(fs,inv):
fs_webmap_inventory={}
fs_inv=[]
try:
forwmininv['WebMap']:
iffs.idinget_layer_item_ids(wm):
ifnotwminfs_inv:
fs_inv.append(wm)
fs_webmap_inventory[fs.title]=fs_inv
returnfs_webmap_inventory
exceptKeyErroraske:
pass
We'llalsocreateafunctionthatinspectsawebmapandreturnsalltheuniqueitemid(clickthehyperlinktoreadablogontheimportanceoftheitemid)valuesconsumedinthatwebmap.Whencloningthesetoffeatureservicesfromourinventory,we'llcreateamappingofsourcefeatureservicetocorrespondingtargetfeatureserviceclonedfromthesource.Thenwhenwesubsequentlycloneawebmap,wecanusetheget_layer_item_ids()functiontocomparetheitemidvaluesservingaslayersinthewebmaptothedictionaryofsource/targetfeatureserviceidswealreadycloned.Ifthereareanymatchesbetweenthetwo,wecancreateadictionarytouseasaparameterfortheclone_items()functiontoensurethefunctionknowswhichidtomatchtowhichwhenswizzlingtheidsintheclonedmap.We'lldemonstratethislaterinthenotebook.
Input
defget_layer_item_ids(wm):
wmo=WebMap(wm)
wm_id_list=[]
forlayerinwmo.layers:
try:
fsvc=FeatureLayerCollection(layer['url'][:-1],active_gis)
ifnotfsvc.properties['serviceItemId']inwm_id_list:
wm_id_list.append(fsvc.properties['serviceItemId'])
exceptExceptionase:
pass
returnwm_id_list
We'llcreateafunctiontoreturnalistofanywebmapitemsconsumedinadashboard.Ifweknowtheitemidofthewebmap,andwe'vealreayclonedit,wecanthenmapthesourcewebmaptothetargetwebmapinaparameteroftheclone_items()functiontoensurecorrectswizzlingofvalues.
Input
defget_dash_wm(dash):
return[active_gis.content.get(widget['itemId'])
forwidgetindash.get_data()['widgets']
ifwidget['type']=="mapWidget"]
Ok,sowe'vecreatedsomehelperfunctions.Nowlet'sinventorytheitemsownedbythesourceadministratorandthenprintouttheinventorytogetanideaofwhatitemstheadministratorowns.
Input
source_admin_inventory=get_user_items(source.users.me,source)
Input
print_user_inventory(source_admin_inventory)
MapService
--------------------------------------------------
Jordan
TorontoGreenspaceandCommunityHousing
Dashboard
--------------------------------------------------
NewOrleansServiceCalls
WebMap
--------------------------------------------------
ElephantCorridorsandRanges
KenyaAdministrativeBoundaries
NewOrleansServiceCallsperPoliceDistrict2011-2019
FeatureService
--------------------------------------------------
KENWaterways
Airport_locations
NairobiCountyBoundaries
NOLA_Police_District_Subzone_Boundaries
BotswanaPowerPlants
New_Orleans_Boundary_gax
NOLA_Police_District_Boundaries
NOLA_ServiceCallTypes_by_PoliceDistrict
KEN_Administrative_Level_Boundaries
tlh_houshold_data_blkgrp
KENWetlands
KENProtectedAreas
Shapefile
--------------------------------------------------
BotswanaPowerPlants
New_Orleans_Boundary_gax
NOLA_Police_Districts
Airport_locations
FileGeodatabase
--------------------------------------------------
KEN_Administrative_Level_Boundaries
ServiceDefinition
--------------------------------------------------
tlh_houshold_data_blkgrp
Jordan
WebMappingApplication
--------------------------------------------------
ElephantHabitatandRelationshiptoWater
Thecloningprocess¶Twoveryimportantparametersintheclone_items()functionsignatureimpactitsoutput:
search_existing_items-ThepossiblevaluesareTrueorFalse.
ThedefaultvalueisTrue.Let'sdescribewhathappenswhenthevalueissettoTrue.Whenanysourceitemisclonedintothetarget,theclone_items()functionassignsthecloneditemalltheessentialitemtypetypeKeywords(SeehyperlinkfortypeKeywordsautomaticallyassignedtoitems)plusanadditionaltypeKeywordofsource-.Forexample,ifclone_items()clonessourceitemwithitemidd879c7d972b1d989b97d037c7a7737d6,thefunctionassignsthetargethostedfeaturelayeritemthetypeKeywordofsource-d879c7d972b1d989b97d037c7a7737d6inadditiontoalltheessentialtypeKeywords.Beforeanyactualclone,clone_items()searchesthetargetforanyitemwithatypeKeywordmatchingthatpatternandifitfindsoneusestheexistingtargetitem.
item_mapping-Thisisadictionarydefinedas{'source_item_id':'target_item_id'}
Theitem_mappingparametercaninstructtheclone_items()functiontouseratargetitemastheresultofacloneforanyexistingsourceitemiftargetitemsalreadyexistthatyouknowyoualreadyhave.Forexample,let'ssayyouwanttocloneawebmaptothetarget.portal,YouknowyoualreadyhaveaFeatureLayerusedbythesourcewebmappublishedinthetargetthatyouwanttouse.Youaccomplishthiswiththeitem_mappingparameter,whichisadictionarywiththekeyasthesourceitemidandthevalueasthematchingtargetitemid.Passingthismappingobjectguidestheclone_itemsfunctionforeveryreferencetothesourceFeatureLayertousethespecifiedtargetFeatureLayer.ThisprovidesforcloningtheWebMapontopoftheFeatureLayeralreadycreatedinthetargetportal.
Wecanreturnlistsofspecificitem_typesfromourinventory.First,let'sprintalistofthedisctinctitemtypesavaiableforthisuser:
Input
foritem_typeinlist(source_admin_inventory.keys()):
print(item_type)
MapService
Dashboard
WebMap
FeatureService
Shapefile
FileGeodatabase
ServiceDefinition
WebMappingApplication
WecancreatealistofthehostedfeatureservicesusingthetypeKeywordspropertyforitemsonourFeatureServices:
FeatureLayers¶
EachiteminaWebGIShasatypeKeywordsproperty.Thepropertyreturnsalistofdescriptionsbasedonitsprimarytype.ForitemsoftypeFeatureService,iftheserviceishostedontheactiveWebGIS,theitemwillhaveaHostedServicetypeKeywordthatcanbeusedtofilterouthosteditemsfromreferenceditems.
Input
hosted_fsvc=[fs
forfsinsource_admin_inventory["FeatureService"]
if'HostedService'infs.typeKeywords]
Note:Thisresultincludeshostedfeaturelayerviewscreatedfromhostedfeaturelayers.UsethetypeKeywords'ViewService'toisolateviews.
Let'sprintoutallthefeatureservicesfortheadministrator.We'llalsoaccountforanyfoldersintheportal,andalsouseourpreviouslydefinedget_fs_webmaps()functiontoprintanywebmapthatconsumesthefeatureservice:
Input
print(f"{'FeatureLayer':<33}{'FolderID':<35}{'FolderName':15}{'ItemID'}\n"
f"{'-'*28:<30}{'-'*33:<35}{'-'*13:<15}{'-'*37}")
forhosted_fsinhosted_fsvc:
fs_wm_maps=get_fs_webmaps(hosted_fs,source_admin_inventory)[hosted_fs.title]
ifnothosted_fs.ownerFolder:
print(f"{hosted_fs.title[:30]:33}{'':35}{'RootFolder':15}{hosted_fs.id}")
iffs_wm_maps:
forwminfs_wm_maps:
print(f"{''*2}...consumedin{wm.title}webmap")
else:
pass
else:
print(f"{hosted_fs.title[:30]:33}{hosted_fs.ownerFolder:35}"
f"""{next(f['title']forfinsource.users.me.folders
iff['id']==hosted_fs.ownerFolder):15}"""
f"{hosted_fs.id}")
iffs_wm_maps:
forwminfs_wm_maps:
print(f"{''*2}...consumedin{wm.title}webmap")
else:
pass
print("\n")
FeatureLayerFolderIDFolderNameItemID
---------------------------------------------------------------------------------------------------------------
Airport_locationse576014b6a8a46f1a04ba2db6de51ff1Airportsbb61578ed24c4d068a8bf521d758f6f9
NairobiCountyBoundaries9da120268eab46048b61364fa4c01723Kenyaf6829ace38e14375a4b0640968a5bcec
NOLA_Police_District_Subzone_B27d3016208e14e40887d9b3800f5a761NewOrleans42874776bf8e4e7f842773d2bf5d6704
BotswanaPowerPlantsRootFolder46712cf2cc814014b314d3c77a41a7d4
New_Orleans_Boundary_gax27d3016208e14e40887d9b3800f5a761NewOrleans3b659cafd4dd4eb4acd09c161b307871
...consumedinNewOrleansServiceCallsperPoliceDistrict2011-2019webmap
NOLA_Police_District_Boundarie27d3016208e14e40887d9b3800f5a761NewOrleans7bb9efeffe8847e7bec6515ac66376a8
...consumedinNewOrleansServiceCallsperPoliceDistrict2011-2019webmap
NOLA_ServiceCallTypes_by_Polic27d3016208e14e40887d9b3800f5a761NewOrleans7c89adbcc6e648eda313fe9ededddf44
...consumedinNewOrleansServiceCallsperPoliceDistrict2011-2019webmap
KEN_Administrative_Level_Bound9da120268eab46048b61364fa4c01723Kenya7b4a28846f0a40efb231e800840b72ec
...consumedinElephantCorridorsandRangeswebmap
...consumedinKenyaAdministrativeBoundarieswebmap
tlh_houshold_data_blkgrp7f47934ce3e5451095da4ed889f84697Tallahasseee454a494c95542168bd4fbcd13ec3641
Nowlet'sclonethissmallsetofhostedfeatureservices,allotingforanyfailedcloning,andreplicatingthesourcefolderstructureaswell.Wewillnotexplicitlysetthesearch_extisting_itemsparameterbecauseweknowthedefaultvalueisTrue.
Wealsoarenotgoingtousetheitem_mappingparameterbecausewe'recloningintoatargetstagingportalthatwehavenotyetpopulatedwithanyitems.
Input
forhfsinhosted_fsvc:
try:
ifhfs.ownerFolder:
folder=next((f['title']
forfinsource.users.me.folders
iff['id']==hfs.ownerFolder))
ifnotfolderin[fld['title']
forfldintarget.users.me.folders]:
target.content.create_folder(folder=folder)
print(f"Cloning{hfs.title}...")
clone_fs=target.content.clone_items([hfs],folder=folder)
print(f"...completed")
else:
print(f"Cloning{hfs.title}...")
cloned_fs=target.content.clone_items([hfs])
ifnotcloned_fs:
print(f"{hfs.title}notcloned")
else:
print(f"...completed")
exceptExceptionase:
print(f"...FailedtoClone{hfs.title}...")
print(f"\tExceptionType:{sys.exc_info()[0]}")
print(f"\tExceptionValue:{sys.exc_info()[1]}")
print(f"\tExceptionTracebackline:{sys.exc_info()[2].tb_lineno}")
print(f"\tExceptionTracebackinstruction:{sys.exc_info()[2].tb_lasti}")
continue
CloningAirport_locations...
...completed
CloningNairobiCountyBoundaries...
...completed
CloningNOLA_Police_District_Subzone_Boundaries...
...completed
CloningBotswanaPowerPlants...
...completed
CloningNew_Orleans_Boundary_gax...
...completed
CloningNOLA_Police_District_Boundaries...
...completed
CloningNOLA_ServiceCallTypes_by_PoliceDistrict...
...completed
CloningKEN_Administrative_Level_Boundaries...
...completed
Cloningtlh_houshold_data_blkgrp...
...completed
Let'snowquerythetargettoinspecttheresultsofcloningourfeatureservices.
First,we'lluseourhelperfunctiontocreatethecurrentiteminventoryforourtargetadminandprintthatout.Thenwe'llquerytheclonedtargetitemtypeKeywordspropertyforakeywordmatchingthesource-pattern.Wecanthenlookforcontentinthesourcethathasthatitemidjusttoverifythecloningoperation.
Input
target_admin_inventory=get_user_items(target.users.me,target)
Input
print_user_inventory(target_admin_inventory)
FeatureService
--------------------------------------------------
Airport_locations
NOLA_ServiceCallTypes_by_PoliceDistrict
New_Orleans_Boundary_gax
NairobiCountyBoundaries
tlh_houshold_data_blkgrp
NOLA_Police_District_Subzone_Boundaries
KEN_Administrative_Level_Boundaries
BotswanaPowerPlants
NOLA_Police_District_Boundaries
Input
target_to_source={}
fortarg_fsvc_itemintarget_admin_inventory['FeatureService']:
forkeywordintarg_fsvc_item.typeKeywords:
if'source'inkeyword:
source_id=keyword.split('-')[1]
try:
flyr=source.content.get(source_id)
target_to_source[targ_fsvc_item.title]=(keyword,
flyr.title,
flyr.id)
exceptExceptionase:
pass
fortrg_item,src_itemintarget_to_source.items():
print(f"TargetItem:{trg_item:45}{src_item[0]}\n{''*2}"
f"SourceItem:{src_item[1]:45}{src_item[2]}")
print("\n")
TargetItem:Airport_locationssource-bb61578ed24c4d068a8bf521d758f6f9
SourceItem:Airport_locationsbb61578ed24c4d068a8bf521d758f6f9
TargetItem:NOLA_ServiceCallTypes_by_PoliceDistrictsource-7c89adbcc6e648eda313fe9ededddf44
SourceItem:NOLA_ServiceCallTypes_by_PoliceDistrict7c89adbcc6e648eda313fe9ededddf44
TargetItem:New_Orleans_Boundary_gaxsource-3b659cafd4dd4eb4acd09c161b307871
SourceItem:New_Orleans_Boundary_gax3b659cafd4dd4eb4acd09c161b307871
TargetItem:NairobiCountyBoundariessource-f6829ace38e14375a4b0640968a5bcec
SourceItem:NairobiCountyBoundariesf6829ace38e14375a4b0640968a5bcec
TargetItem:tlh_houshold_data_blkgrpsource-e454a494c95542168bd4fbcd13ec3641
SourceItem:tlh_houshold_data_blkgrpe454a494c95542168bd4fbcd13ec3641
TargetItem:NOLA_Police_District_Subzone_Boundariessource-42874776bf8e4e7f842773d2bf5d6704
SourceItem:NOLA_Police_District_Subzone_Boundaries42874776bf8e4e7f842773d2bf5d6704
TargetItem:KEN_Administrative_Level_Boundariessource-7b4a28846f0a40efb231e800840b72ec
SourceItem:KEN_Administrative_Level_Boundaries7b4a28846f0a40efb231e800840b72ec
TargetItem:BotswanaPowerPlantssource-46712cf2cc814014b314d3c77a41a7d4
SourceItem:BotswanaPowerPlants46712cf2cc814014b314d3c77a41a7d4
TargetItem:NOLA_Police_District_Boundariessource-7bb9efeffe8847e7bec6515ac66376a8
SourceItem:NOLA_Police_District_Boundaries7bb9efeffe8847e7bec6515ac66376a8
WecanseethatwehavethesameninehostedfeatureservicesinbothsourceandtargetWebGISsystems,andwealsohaveatypeKeywordinthetargetitemthatcontainsthesourceitemidfromwhichitwascloned.
Let'sexaminethetargetfeatureservicestoseethatwealsorecreatedthefolderstructure:
Input
target_hosted_fsvc=[fs
forfsintarget_admin_inventory["FeatureService"]
if'HostedService'infs.typeKeywords]
Input
active_gis=target
Input
print(f"{'FeatureLayer':<33}{'FolderID':<35}{'FolderName':15}{'ItemID'}\n"
f"{'-'*28:<30}{'-'*33:<35}{'-'*13:<15}{'-'*37}")
forhosted_fsintarget_hosted_fsvc:
try:
fs_wm_maps=get_fs_webmaps(hosted_fs,target_admin_inventory)[hosted_fs.title]
exceptTypeErroraste:
pass
continue
finally:
ifnothosted_fs.ownerFolder:
print(f"{hosted_fs.title[:30]:33}{'':35}{'RootFolder':15}{hosted_fs.id}")
iffs_wm_maps:
forwminfs_wm_maps:
print(f"{''*2}...consumedin{wm.title}webmap")
else:
pass
else:
print(f"{hosted_fs.title[:30]:33}{hosted_fs.ownerFolder:35}"
f"""{next(f['title']forfintarget.users.me.folders
iff['id']==hosted_fs.ownerFolder):15}"""
f"{hosted_fs.id}")
iffs_wm_maps:
forwminfs_wm_maps:
print(f"{''*2}...consumedin{wm.title}webmap")
else:
pass
print("\n")
FeatureLayerFolderIDFolderNameItemID
---------------------------------------------------------------------------------------------------------------
Airport_locations8e6711c43be04965a7819806dea87825Airports6842108a48104b6285b893470cf0b67c
NOLA_ServiceCallTypes_by_Polic0054dacb91594193be317145eaf946ccNewOrleansefb953a5bc824b3a966fd08efd13066f
New_Orleans_Boundary_gax0054dacb91594193be317145eaf946ccNewOrleans422324e7cf65467493f721fda132b6f7
NairobiCountyBoundaries4706de0f89144dba87dcf25e062416d4Kenya60a7720bb4164f14a6738fb630ee7a7e
tlh_houshold_data_blkgrp6da389baae1c48b9a0dacbf747404991Tallahassee6fa12b4241aa43e2a4b86c569d8a07ea
NOLA_Police_District_Subzone_B0054dacb91594193be317145eaf946ccNewOrleans8977c4536ab546f7bfa65258e68dfc21
KEN_Administrative_Level_Bound4706de0f89144dba87dcf25e062416d4Kenyabe66aefdb6544d3386903cbec0309ad8
BotswanaPowerPlantsRootFolder4b185d9cb2a8469da6e90d9715ceb99b
NOLA_Police_District_Boundarie0054dacb91594193be317145eaf946ccNewOrleanscc4d594a0a0f43bfb470275f8415c8e3
WecanseethatallthefeatureservicesnowexistinthetargetwiththesameFolderstructureandnewitemids.NoWebMapsconsumethefeatureservicesatthispointbecausewehaven'tyetclonedanyintothetarget.
WebMaps¶Now,let'slookattheWebMapsinoursourceorganizationandclonethemtothetarget.We'llrevisitthesourceadministator'sget_user_inventoryresultstoexaminetheWebMaps:
Input
forwminsource_admin_inventory['WebMap']:
wm_obj=WebMap(wm)
print(wm_obj.item.title)
ElephantCorridorsandRanges
KenyaAdministrativeBoundaries
NewOrleansServiceCallsperPoliceDistrict2011-2019
Let'sinspectwhatlayersareineachWebMap.
We'vedefinedacouplehelperfunctions.Onetodeterminewheteranitemishostedinaportal,andasecondtoprintthelayersinawebmap
Input
defis_hosted(item):
return[keywordforkeywordinitem.typeKeywordsif"Hosted"inkeyword]
Input
defprint_webmap_inventory(wm):
wm_obj=WebMap(wm)
print(f"{wm_obj.item.title}\n{'-'*100}")
forwm_layerinwm_obj.layers:
try:
ifis_hosted(Item(active_gis,wm_layer['itemId'])):
print(f"{''*2}{wm_layer['title']:40}HOSTED{'':5}"
f"{wm_layer['layerType']:20}{dict(wm_layer)['itemId']}")
else:
print(f"{''*2}{wm_layer['title']:40}other{'':6}"
f"{wm_layer['layerType']:20}{wm_layer.id}")
except:
print(f"{''*2}{wm_layer['title']:40}other{'':6}"
f"{wm_layer['layerType']:20}{wm_layer.id}")
print("\n")
Input
#remembertosettheactive_gisvariablewhenusingthehelperfunctions
active_gis=source
Input
forwminsource_admin_inventory['WebMap']:
print_webmap_inventory(wm)
ElephantCorridorsandRanges
----------------------------------------------------------------------------------------------------
ElephantNaturalCorridorsotherArcGISFeatureLayerElephant_Natural_Corridors_1302
ElephantRangesotherArcGISFeatureLayerElephant_Ranges_256
KENNationalBoundaryHOSTEDArcGISFeatureLayer7b4a28846f0a40efb231e800840b72ec
KENWetlandsotherArcGISFeatureLayerKenya_Protected_Areas_and_Wetlands_7235
KENWaterwaysotherArcGISFeatureLayerKenya_8543
KENProtectedAreasotherArcGISFeatureLayerKenya_Protected_Areas_and_Wetlands_9906
KENCountyBoundariesHOSTEDArcGISFeatureLayer7b4a28846f0a40efb231e800840b72ec
KenyaAdministrativeBoundaries
----------------------------------------------------------------------------------------------------
KenCountyBoundariesHOSTEDArcGISFeatureLayer7b4a28846f0a40efb231e800840b72ec
KENConstituencyBoundariesHOSTEDArcGISFeatureLayer7b4a28846f0a40efb231e800840b72ec
KENNationalBoundaryHOSTEDArcGISFeatureLayer7b4a28846f0a40efb231e800840b72ec
NewOrleansServiceCallsperPoliceDistrict2011-2019
----------------------------------------------------------------------------------------------------
NewOrleansCityBoundaryHOSTEDArcGISFeatureLayer3b659cafd4dd4eb4acd09c161b307871
NOLA_Police_District_BoundariesHOSTEDArcGISFeatureLayer7bb9efeffe8847e7bec6515ac66376a8
NOLA_ServiceCallTypes_by_PoliceDistrictHOSTEDArcGISFeatureLayer7c89adbcc6e648eda313fe9ededddf44
Let'suseoneofthehelperfunctionswewroteearlierinthenotebooktoreturnalistoftheuniqueitemIdvaluesconsumedineachwebmap:
Input
forwminsource_admin_inventory['WebMap']:
print(f"{wm.title}\n{'-'*80}")
foritem_idinget_layer_item_ids(wm):
print(f"{''*2}{item_id}")
print("\n")
ElephantCorridorsandRanges
--------------------------------------------------------------------------------
a42b8e67641149b7918ec50b657cf91f
85297d9812b441afbbd26609b9a8a561
7b4a28846f0a40efb231e800840b72ec
a535e2ba4fcd4fdbb252f70d5483ef5e
c48149de475c4e5499243a26739932d9
KenyaAdministrativeBoundaries
--------------------------------------------------------------------------------
7b4a28846f0a40efb231e800840b72ec
NewOrleansServiceCallsperPoliceDistrict2011-2019
--------------------------------------------------------------------------------
3b659cafd4dd4eb4acd09c161b307871
7bb9efeffe8847e7bec6515ac66376a8
7c89adbcc6e648eda313fe9ededddf44
We'regoingtorelyonthesearch_existing_itemsparametertohandlealltheitemsconsumedinourwebmaps.Givenwhatwe'velearnedaboutthisparameter,wecanrelyonittodetectwhetheranyoftheitemidsconsumedinourwebmapsmatchanyofthetypeKeywordsalreadyexistinginourtarget.Ifthefunctionfindsanexistingiteminthetarget,itwillswizzletheappropriatevaluesinthenewwebmapdefinition.IfthefunctiondoesnotfindanexistingitembasedonthetypeKeyword,itwillclonetheitem.Fornon-hosteditems,itwillrecreatethoseitemsintheresultingwebmap.
Input
wm_map={}
forwminsource_admin_inventory['WebMap']:
wm_obj=WebMap(wm)
print(f"{wm_obj.item.title}\n{'-'*50}")
ifwm_obj.item.ownerFolder:
folder_name=[f['title']forfinsource.users.me.folders
iff['id']==wm_obj.item.ownerFolder][0]
try:
print(f"...cloning{wm_obj.item.title}")
cloned_wm=target.content.clone_items(items=[wm_obj.item],
folder=folder_name)
wm_map[wm.id]=cloned_wm[0].id
print(f"...completed")
print(f"\n")
exceptExceptionase:
print(f"....failedtoclone{wm_obj.item.title}")
print(str(e))
print(f"\n")
ElephantCorridorsandRanges
--------------------------------------------------
...cloningElephantCorridorsandRanges
...completed
KenyaAdministrativeBoundaries
--------------------------------------------------
...cloningKenyaAdministrativeBoundaries
...completed
NewOrleansServiceCallsperPoliceDistrict2011-2019
--------------------------------------------------
...cloningNewOrleansServiceCallsperPoliceDistrict2011-2019
...completed
Let'sexaminetheresultingWebMapitemsinthetarget:
Input
target_admin_inventory=get_user_items(target.users.me,target)
Input
active_gis=target
Input
forwmintarget_admin_inventory['WebMap']:
print_webmap_inventory(wm)
ElephantCorridorsandRanges
----------------------------------------------------------------------------------------------------
ElephantNaturalCorridorsotherArcGISFeatureLayerElephant_Natural_Corridors_1302
ElephantRangesotherArcGISFeatureLayerElephant_Ranges_256
KENNationalBoundaryHOSTEDArcGISFeatureLayerbe66aefdb6544d3386903cbec0309ad8
KENWetlandsotherArcGISFeatureLayerKenya_Protected_Areas_and_Wetlands_7235
KENWaterwaysotherArcGISFeatureLayerKenya_8543
KENProtectedAreasotherArcGISFeatureLayerKenya_Protected_Areas_and_Wetlands_9906
KENCountyBoundariesHOSTEDArcGISFeatureLayerbe66aefdb6544d3386903cbec0309ad8
NewOrleansServiceCallsperPoliceDistrict2011-2019
----------------------------------------------------------------------------------------------------
NewOrleansCityBoundaryHOSTEDArcGISFeatureLayer422324e7cf65467493f721fda132b6f7
NOLA_Police_District_BoundariesHOSTEDArcGISFeatureLayercc4d594a0a0f43bfb470275f8415c8e3
NOLA_ServiceCallTypes_by_PoliceDistrictHOSTEDArcGISFeatureLayerefb953a5bc824b3a966fd08efd13066f
KenyaAdministrativeBoundaries
----------------------------------------------------------------------------------------------------
KenCountyBoundariesHOSTEDArcGISFeatureLayerbe66aefdb6544d3386903cbec0309ad8
KENConstituencyBoundariesHOSTEDArcGISFeatureLayerbe66aefdb6544d3386903cbec0309ad8
KENNationalBoundaryHOSTEDArcGISFeatureLayerbe66aefdb6544d3386903cbec0309ad8
Wecanseethatclone_items()successfullyrecreatedthewebmapsandswizzledthelayercontentstousetheitemidsoftheclonedfeatureservices.Thesearch_existing_itemsparameterallowedthefunctiontoavoidcopyingcontentthathadalreadybeenclonedintothetargetandsimplyrewiredthewebmapdefinitionsbasedonthetypeKeywordaddedduringtheclone.Forthoseitemsthatwerenothostedfeaturelayers,thefunctionrecreatestheminthewebmap,butdoesnotcreateFeatureLayer(non-hosted)itemsintheWebGISunlesstheSaveLayercontextmenuoptionisusedfromwithinthetargetWebMap.
Wealsocreatedadictionarywiththesourcewebmapidasthekeyandtheclonedtargetwebmapidasthevalue.Aswedescribedearlier,theitem_mappinginstructstheclone_items()functiontouseanitemalreadyexistinginthetargetratherthanrecreatingit.Withitemsthatconsumewebmaps,suchasdashboardsandwebmappingapplications,theclone_items()functiondoesnotautomaticallygodeepintotheitemandclonethewebmap.However,wecanusetheitem_mappingparametertoswizzlethewebmapusedinanapplicationfromthesourcetothetargetwiththewm_mapmappingwecreatedwhilecloningthesourcewebmaps.
Let'sexamineourwm)_mapdictionarytoseethatweindeedhaveadictionarymappingthathasidsasbothkeysandvalues.
Input
wm_map
Output
{'485ec5def2b14e89b95d03fcfa7537d6':'cbca10bf6d824bfc8a9c164452932b80',
'89abb46264f34953ae782748cf89e7da':'d04f97e5645248bcafc72010522177a7',
'5dfbd0b244a440d2ac097c4bf9b381a2':'b365110bedfe4396947d43a522fc9c2e'}
Let'svisuallycompareourwebmaps:
source¶
Input
source_webmap=WebMap(source.content.get(list(wm_map.keys())[1]))
source_webmap
Output
target¶
Input
target_webmap=WebMap(target.content.get(list(wm_map.values())[1]))
target_webmap
Output
Wecanseevisuallythatthemapsappeartocontainthesamelayers.Youcanrepeatthisprocessforanyotherwebmapsource/targetpairfromthewm_mapdictionarytomakeavisualcomparison.
ArcGISDashboards¶
ArcGISDashboardsuseintuitiveandinteractivedatavisualizationstoprovideinsightsintoyourdata.WhenyouuseaWebMapasamapelementinthedashboardthewebmap'soperationallayerscanserveasdatasourcesforotherelements,providingvisualandanalyticalinsightintoyourdata.
Let'sexaminetheprocessofcloningaDashboardbyrevisitingoursourceadministratorsiteminventoryandlookintoanydashboarditems.
Input
ops_dash=source_admin_inventory['Dashboard'][0]
ops_dash
Output
NewOrleansServiceCalls
AggregationofyearlyservicecallsinNewOrleans,LouisianaintheUnitedStatesbetween2011an2018.Dashboardbyarcgispyapibot
LastModified:April27,2020
0comments,7views
Input
active_gis=source
Input
dash_wm=get_dash_wm(ops_dash)[0]
dash_wm
Output
NewOrleansServiceCallsperPoliceDistrict2011-2019
SummaryoftypesofservicecallsineachpolicedistrictinNewOrleansbetween2011-2019WebMapbyarcgispyapibot
LastModified:April27,2020
0comments,129views
Let'svisualizethewebmapsowecanmakeaquickcomparisontotheresultsinourclone.
Input
WebMap(dash_wm)
Output
Input
dash_wm.id
Output
'5dfbd0b244a440d2ac097c4bf9b381a2'
Input
print_webmap_inventory(dash_wm)
NewOrleansServiceCallsperPoliceDistrict2011-2019
----------------------------------------------------------------------------------------------------
NewOrleansCityBoundaryHOSTEDArcGISFeatureLayer3b659cafd4dd4eb4acd09c161b307871
NOLA_Police_District_BoundariesHOSTEDArcGISFeatureLayer7bb9efeffe8847e7bec6515ac66376a8
NOLA_ServiceCallTypes_by_PoliceDistrictHOSTEDArcGISFeatureLayer7c89adbcc6e648eda313fe9ededddf44
Weusedourhelperfunctionstogetadashboardandexaminethelayerswithinthewebmapconsumedinthedashboard.
Let'squerythewm_mapobjectwecreatedtoseeifthisWebMapidwascloned.
Input
wm_item_mapping={src_wm:trg_wmforsrc_wm,trg_wminwm_map.items()
ifdash_wm.id==src_wm}
wm_item_mapping
Output
{'5dfbd0b244a440d2ac097c4bf9b381a2':'b365110bedfe4396947d43a522fc9c2e'}
Weclonedthewebmapusedinthisdashboardinourpreviousstepofcloningwebmaps.Wecanusethewm_item_mappingwejustcreatedastheitem_mappingparameterwhencloningthedashboardtoensurethecloneddashboardconsumedtheclonedwebmapinthetargetinsteadofstayingwireduptothesourcewebmap.
Andsincewe'rekeepingthesearch_existing_itemsparameterwiththedefaultvalueofTrue,anyitemsconsumedinthewebmapwillnotgetduplicatedbecauseoftheclone_items()functionusingthetypeKeywordssearchtouseanysourceitemidvaluetomaptoanycloneditemwiththatidinitstypeKeywordslist.
Input
target.content.clone_items(items=[ops_dash],
folder="NewOrleans",
item_mapping=wm_item_mapping)
Output
[]
Wenowinvestigateourtargetforthedashboardwejustcloned.
Input
target_admin_inventory=get_user_items(target.users.me,target)
Input
cloned_dash=target_admin_inventory['Dashboard'][0]
cloned_dash
Output
NewOrleansServiceCalls
AggregationofyearlyservicecallsinNewOrleans,LouisianaintheUnitedStatesbetween2011an2018.Dashboardbyclonerator
LastModified:May10,2020
0comments,0views
Input
active_gis=target
Input
cloned_dash_webmap=get_dash_wm(cloned_dash)[0]
cloned_dash_webmap
Output
NewOrleansServiceCallsperPoliceDistrict2011-2019
SummaryoftypesofservicecallsineachpolicedistrictinNewOrleansbetween2011-2019WebMapbyclonerator
LastModified:May10,2020
0comments,1views
Input
WebMap(cloned_dash_webmap)
Output
Input
cloned_dash_webmap.id
Output
'b365110bedfe4396947d43a522fc9c2e'
Input
print_webmap_inventory(cloned_dash_webmap)
NewOrleansServiceCallsperPoliceDistrict2011-2019
----------------------------------------------------------------------------------------------------
NewOrleansCityBoundaryHOSTEDArcGISFeatureLayer422324e7cf65467493f721fda132b6f7
NOLA_Police_District_BoundariesHOSTEDArcGISFeatureLayercc4d594a0a0f43bfb470275f8415c8e3
NOLA_ServiceCallTypes_by_PoliceDistrictHOSTEDArcGISFeatureLayerefb953a5bc824b3a966fd08efd13066f
Thewebmapclonedfromthesourcedashboardvisuallyappearsidentical,andmatchestheidvaluefromourwm_mapobject.
StoryMaps¶
ArcGISStoryMaps¶Asofversion1.8,thePythonAPIdoesnotyetsupportcloningArcGISStoryMaps.Staytunedforannouncementsastofuturecapability.
ClassicStoryMaps¶ClassicstorymapsarestoredintheportalsasWebMappingApplicationitems,solet'susethemasanexampleofcloningawebapplicationitem.
Input
active_gis=source
Input
wma=source_admin_inventory['WebMappingApplication'][0]
wma
Output
ElephantHabitatandRelationshiptoWater
Storymapshowingelephanthabitatandnavigationpathwaysinrelationstowaterandprotectedareas.WebMappingApplicationbyarcgispyapibot
LastModified:April27,2020
0comments,23views
Input
wma_webmap=source.content.get(wma.get_data()['values']['webmap'])
wma_webmap
Output
ElephantCorridorsandRanges
MapofnaturalelephantcorridorsandrangesintheGreatRiftValley.WebMapbyarcgispyapibot
LastModified:April28,2020
0comments,211views
Foraquickvisualizationofthewebmap:
Input
WebMap(wma_webmap))
Output
Input
wma_webmap.id
Output
'485ec5def2b14e89b95d03fcfa7537d6'
Input
print_webmap_inventory(wma_webmap)
ElephantCorridorsandRanges
----------------------------------------------------------------------------------------------------
ElephantNaturalCorridorsotherArcGISFeatureLayerElephant_Natural_Corridors_1302
ElephantRangesotherArcGISFeatureLayerElephant_Ranges_256
KENNationalBoundaryHOSTEDArcGISFeatureLayer7b4a28846f0a40efb231e800840b72ec
KENWetlandsotherArcGISFeatureLayerKenya_Protected_Areas_and_Wetlands_7235
KENWaterwaysotherArcGISFeatureLayerKenya_8543
KENProtectedAreasotherArcGISFeatureLayerKenya_Protected_Areas_and_Wetlands_9906
KENCountyBoundariesHOSTEDArcGISFeatureLayer7b4a28846f0a40efb231e800840b72ec
Let'sagainquerythesource\targetdictionarywecreatedwhencloningthesourcewebmapstoseeifwe'vepreviouslyclonedthewebmapconsumedbytheStoryMapapplication.
Input
wm_item_mapping={src_wm:trg_wmforsrc_wm,trg_wminwm_map.items()
ifwma_webmap.id==src_wm}
wm_item_mapping
Output
{'485ec5def2b14e89b95d03fcfa7537d6':'cbca10bf6d824bfc8a9c164452932b80'}
TheoriginalWebMapcontained7operationallayers.2fromahostedFeatureLayerintheWebGIS,and5FeatureLayersitemssourcedfromArcGISOnlineFeatureLayers.Let'susetheclone_items()function,acceptingthedefaultvaluesforthecopy_dataandsearch_existing_itemsparameters(bothTrue)andutilizingtheexistingitemwm_item_mappingobjecttowiretheapplication'swebmap.We'llthenexaminetheresults.
Input
target.content.clone_items(items=[wma],
folder="Kenya",
item_mapping=wm_item_mapping)
Output
[]
WecanseethatcloningoutputoftheWebMappingApplicationliststheapplication.Let'sfurtherexaminetheclonedapplicationfortheitemsitconsumes.
We'llquerythetargetadministratorinventoryfortheWebMappingApplicationsnowownedbythetargetadmin,andthenexaminethewebmapitconsumes.
Input
active_gis=target
Input
target_admin_inventory=get_user_items(target.users.me,target)
Input
target_wma=target_admin_inventory['WebMappingApplication'][0]
target_wma
Output
ElephantHabitatandRelationshiptoWater
Storymapshowingelephanthabitatandnavigationpathwaysinrelationstowaterandprotectedareas.WebMappingApplicationbyclonerator
LastModified:May10,2020
0comments,0views
Input
cloned_wma_webmap=target.content.get(target_wma.get_data()['values']['webmap'])
cloned_wma_webmap
Output
ElephantCorridorsandRanges
MapofnaturalelephantcorridorsandrangesintheGreatRiftValley.WebMapbyclonerator
LastModified:May10,2020
0comments,0views
Tocompare,thevisualizationofourclonedwebmapappearslikeouroriginalsource.
Input
WebMap(cloned_wma_webmap))
Output
Input
cloned_wma_webmap.id
Output
'cbca10bf6d824bfc8a9c164452932b80'
Input
print_webmap_inventory(cloned_wma_webmap)
ElephantCorridorsandRanges
----------------------------------------------------------------------------------------------------
ElephantNaturalCorridorsotherArcGISFeatureLayerElephant_Natural_Corridors_1302
ElephantRangesotherArcGISFeatureLayerElephant_Ranges_256
KENNationalBoundaryHOSTEDArcGISFeatureLayerbe66aefdb6544d3386903cbec0309ad8
KENWetlandsotherArcGISFeatureLayerKenya_Protected_Areas_and_Wetlands_7235
KENWaterwaysotherArcGISFeatureLayerKenya_8543
KENProtectedAreasotherArcGISFeatureLayerKenya_Protected_Areas_and_Wetlands_9906
KENCountyBoundariesHOSTEDArcGISFeatureLayerbe66aefdb6544d3386903cbec0309ad8
Wecanseethattheitem_mappingparameterensuredtheclonedStoryMapWebMappingApplicationusedthenewlyclonedwebmap.Examiningthelistoflayersinthewebmapshowsithasthesamesetoflayers,includingwiringupthelayerstothecorrectnewlyclonedhostedfeatureservices.
Conclusion¶ThisguidedemonstratedoneworkflowforcloningitemsbetweenasourceWebGISandatargetWebGIS.WeconnectedtoeachGISasanadministratorandclonedasetofitemsusingabottom-upapproach:firstcloningthedataservices-featureservicesthatcompriseotheritemssuchaswebmaps.Weexaminedhowthesearch_existing_itemsparameterallowsustoensureagainstneedlesscopyingofdataifwehavealreadycloneditemsintoourtarget.
Aftercloningthedatabuildingblocks,weclonedthewebmaps,againseeinghowthesearch_existing_itemsparameterautomaticallymappedanyitemsconsumedinthewebmapfromsourcetoamatchingiteminthetargetifitexists.Wethenshowhowthewebmapsserveasbuildingblocksforwebmappingapplicationsanddashboards,showinghowtheitem_mappingparametercanservetoensuretheclonedtargetitemconsumesthecorrectitemordataservicesitconsumedinthesource.
Theclone_items()functionprovidesthemeanstomigratemaps,apps,weblayersandmorecomplexitemsbetweenWebGISsystems.Foritemsthatconsumeotheritems(suchasawebmapitemconsumingasetofweblayeritems),thefunctionprovidesparameterstocontrolhowthosegetmigrated
IntroductionImportlibrariesConnecttosourceandtargetportalsGetstartedwithcloningCloningmultipleitemssimultaneouslyHelperfunctionsThecloningprocessConclusionShowtableofcontentsIntroductionImportlibrariesConnecttosourceandtargetportalsGetstartedwithcloningCloningmultipleitemssimultaneouslyHelperfunctionsThecloningprocessConclusionWasthispagehelpful?YesNoWasthispagehelpful?YesNoYourbrowserisnolongersupported.Pleaseupgradeyourbrowserforthebestexperience.Seeourbrowserdeprecationpostformoredetails.