Introduction to Collections (ArcGIS StoryMaps)
ArcGIS StoryMaps offers a capability that allows you to assemble collections, which are sets of ArcGIS StoryMaps items bundled for sharing. Collections can include your own stories as well as stories authored by others. Other items such as ArcGIS apps, media, and files can also be added to a collection as supporting content.
You can use collections in a variety of ways, such as telling a longer story in installments or chapters; gathering stories, apps, and items that share a common theme; or creating a portfolio of your work.
from arcgis.gis import GIS
from arcgis.apps.storymap import Collection, Themes
from arcgis.apps.storymap.story_content import Imagegis = GIS(profile='your_online_profile')We start by creating a Collection and adding content to it.
my_collection = Collection()Add content to the Collection
1. StoryMap
We start by adding a StoryMap item.
storymap_item = gis.content.get('7860d45d35f6455193576933206d8352')
storymap_itemmy_collection.add(storymap_item)2. Briefing
briefing_item = gis.content.get('af0ff7bd06d046b3b7b3344c78eecb4f')
briefing_itemmy_collection.add(briefing_item)3. Map
map_item = gis.content.get('7f39672ef7f6469db7b2bbd383349fc1')
map_itemmy_collection.add(map_item)4. Web Experience app
my_experience = gis.content.get('717f06e4e65c432a866e12c86a7505f3')
my_experiencemy_collection.add(my_experience)Editing the Cover of the Collection
Now that we have added relevant content items to our Collection, we can edit the cover of our Collection.
The cover is what you see at the start of your Collection and sets the visual tone. The cover will always be the first content element (index = 0) of a Collection.
We will start by defining the Image we would like on the cover of this Collection.
img = Image("https://www.nps.gov/npgallery/GetAsset/69680c29-caa3-42da-93d9-32925e9ed409/proxy/hires")cover = my_collection.content[0]cover.title = "Nature Collection"
cover.summary = "Nature themed items for ArcGIS StoryMaps"
cover.byline = "Python Collection"
cover.media = imgSave the collection
While we are demonstrating the process to programmatically save() the Collection below, it is strongly encouraged to view and verify the Collection in the UI before you publish it, especially for the first time you are publishing a Collection.
my_collection.save(title = "Nature Collection", tags = "Python", access = "private")View content of Collection
You can view the contents of a Collection as a list and a table using the content and content_info properties respectively.
my_collection.content[Cover(), CollectionNavigation(), <Item title:"Nature Themed Story" type:StoryMap owner:MMajumdar_geosaurus>, <Item title:"Nature themed Briefing slides" type:StoryMap owner:MMajumdar_geosaurus>, <Item title:"Nature WebMap" type:Web Map owner:MMajumdar_geosaurus>, <Item title:"Capitals and time zones" type:Web Experience owner:MMajumdar_geosaurus>]
my_collection.content_info| Type | Instance | Visibility | Location | |
|---|---|---|---|---|
| 0 | StoryMap | {'id': '7860d45d35f6455193576933206d8352', 'ow... | True | [] |
| 1 | StoryMap | {'id': 'af0ff7bd06d046b3b7b3344c78eecb4f', 'ow... | True | [] |
| 2 | Web Map | {'id': '7f39672ef7f6469db7b2bbd383349fc1', 'ow... | True | [] |
| 3 | Web Experience | {'id': '717f06e4e65c432a866e12c86a7505f3', 'ow... | True | [] |
You can also update the visibility of a particular content item in the Collection using the update_content_info() method.
E.g., the Web Experience item is still work in progress and we can hide it.
my_collection.update_content_info(index = 3, visible = False)| Type | Instance | Visibility | Location | |
|---|---|---|---|---|
| 0 | StoryMap | {'id': '7860d45d35f6455193576933206d8352', 'ow... | True | [] |
| 1 | StoryMap | {'id': 'af0ff7bd06d046b3b7b3344c78eecb4f', 'ow... | True | [] |
| 2 | Web Map | {'id': '7f39672ef7f6469db7b2bbd383349fc1', 'ow... | True | [] |
| 3 | Web Experience | {'id': '717f06e4e65c432a866e12c86a7505f3', 'ow... | False | [] |
my_collection.save()We now see in the Edit mode that the Web Experience app is hidden.
Remove an item from the Collection
We can remove an item by passing the item's index to the remove() function. Let us remove the Web Experience app from Collection.
my_collection.remove(3)True
my_collection.content[Cover(), CollectionNavigation(), <Item title:"Nature Themed Story" type:StoryMap owner:MMajumdar_geosaurus>, <Item title:"Nature themed Briefing slides" type:StoryMap owner:MMajumdar_geosaurus>, <Item title:"Nature WebMap" type:Web Map owner:MMajumdar_geosaurus>]
my_collection.save()Update theme of the Collection
Theme sets the visual style and appearance of the Collection. ArcGIS StoryMaps supports the following themes:
Supported values for Theme are:
SUMMITOBSIDIANRIDGELINEMESATIDALSLATE
You can fetch and update the theme of your Collection as shown below.
my_collection.get_theme()'summit'
my_collection.theme(Themes.TIDAL)True
my_collection.save()The theme of the Collection has been successfully updated.