arcgis.apps.hub module

The Hub is the main entry point into the Hub module. It can be used as shown in the following code example.

from arcgis.gis import GIS
gis = GIS("https://arcgis.com", "<username>", "<password>")
myHub = gis.hub
a_Initiative = myHub.initiatives.get(itemId)
a_Indicators = a_Initiative.indicators.search()
myEvents = myHub.events.search()

Hub

class arcgis.apps.hub.Hub(gis, username=None, password=None)

Entry point into the Hub module. Lets you access an individual hub and its components.

Argument

Description

url

Required string. If no URL is provided by user while connecting to the GIS, then the URL will be ArcGIS Online.

username

Optional string as entered while connecting to GIS. The login user name (case-sensitive).

password

Optional string as entered while connecting to GIS. If a username is provided, a password is expected. This is case-sensitive. If the password is not provided, the user is prompted in the interactive dialog.

property community_org_id

Returns the AGOL org id of the Community Organization associated with this Hub.

property community_org_url

Returns the AGOL org id of the Community Organization associated with this Hub.

property enterprise_org_id

Returns the AGOL org id of the Enterprise Organization associated with this Hub.

property enterprise_org_url

Returns the AGOL org url of the Enterprise Organization associated with this Hub.

property events
property initiatives

Initiative

class arcgis.apps.hub.Initiative(gis, initiativeItem)

Represents an initiative within a Hub. An Initiative supports policy- or activity-oriented goals through workflows, tools and team collaboration.

delete()

Deletes the initiative. If unable to delete, raises a RuntimeException.

Returns

A bool containing True (for success) or False (for failure).

USAGE EXAMPLE: Delete an initiative successfully

initiative1 = myHub.initiatives.get('itemId12345')
initiative1.delete()

>> True
property description

Getter/Setter for the initiative description

property indicators
property itemid

Returns the item id of the initiative item

property owner

Returns the owner of the initiative item

property site_url

Returns the url of the initiative site

property snippet

Getter/Setter for the initiative snippet

property tags

Returns the tags of the initiative item

property title

Returns the title of the initiative item

update(initiative_properties=None, data=None, thumbnail=None, metadata=None)

Updates the initiative.

Note

For initiative_properties, pass in arguments for only the properties you want to be updated. All other properties will be untouched. For example, if you want to update only the initiative’s description, then only provide the description argument in initiative_properties.

Argument

Description

initiative_properties

Required dictionary. See URL below for the keys and values.

data

Optional string. Either a path or URL to the data.

thumbnail

Optional string. Either a path or URL to a thumbnail image.

metadata

Optional string. Either a path or URL to the metadata.

To find the list of applicable options for argument initiative_properties - https://esri.github.io/arcgis-python-api/apidoc/html/arcgis.gis.toc.html#arcgis.gis.Item.update

Returns

A boolean indicating success (True) or failure (False).

USAGE EXAMPLE: Update an initiative successfully

initiative1 = myHub.initiatives.get('itemId12345')
initiative1.update(initiative_properties={'description':'Create your own initiative to organize people around a shared goal.'})

>> True
property url

Returns the url of the initiative editor

Indicator

class arcgis.apps.hub.Indicator(initiativeItem, indicatorObject)

Represents an indicator within an initiative. Initiatives use Indicators to standardize data sources for ready-to-use analysis and comparison. Indicators are measurements of a system including features, calculated metrics, or quantified goals.

delete()

Deletes an indicator from the initiative

Returns

A bool containing True (for success) or False (for failure).

USAGE EXAMPLE: Delete an indicator successfully

indicator1 = initiative1.indicators.get('streetCrashes')
indicator1.delete()

>> True
get_data()

Retrieves the data associated with an indicator

property indicator_type

Returns the type (Data/Parameter) of the indicator

property indicatorid

Returns the id of the indicator

property itemid

Returns the item id of the data layer (if configured) of the indicator

property mappings

Returns the attribute mapping from data layer (if configured) of the indicator

property name

Returns the layer name (if configured) of the indicator

property optional

Status if the indicator is optional (True/False)

update(indicator_properties=None)

Updates properties of an initiative

Returns

A bool containing True (for success) or False (for failure).

USAGE EXAMPLE: Update an indicator successfully

indicator1_data = indicator1.get_data()
indicator1_data['optional'] = False
indicator1.update(indicator_properties = indicator1_data)

>> True

Refer the indicator definition (`get_data()`) to learn about fields that can be 
updated and their acceptable data format.
property url

Returns the data layer url (if configured) of the indicator

Event

class arcgis.apps.hub.Event(gis, eventObject)

Represents an event in a Hub. A Hub has many Events that can be associated with an Initiative. Events are meetings for people to support an Initiative. Events are scheduled by an organizer and have many attendees. An Event has a Group so that they can include content for preparation as well as gather and archive content during the event for later retrieval or analysis.

property attendance

Returns attendance count for a past event

property capacity

Returns attendance capacity for attendees of the event

property creator

Returns creator of the event

property description

Returns description of the event

property end_date

Returns end date of the event in milliseconds since UNIX epoch

property geometry

Returns co-ordinates of the event location

property initiativeid

Returns the initiative id of the event if it belongs to an Initiative

property is_cancelled

Check if event is Cancelled

property location

Returns the location of the event

property organizer_name

Returns the name of the organizer of the event

property organizers

Returns names of all organizers of the event

property siteid

Returns the site id of the event site

property start_date

Returns start date of the event in milliseconds since UNIX epoch

property status

Returns status of the event

property title

Returns the title of the event

InitiativeManager

class arcgis.apps.hub.InitiativeManager(hub, initiative=None)

Helper class for managing initiatives within a Hub. This class is not created by users directly. An instance of this class, called ‘initiatives’, is available as a property of the Hub object. Users call methods on this ‘initiatives’ object to manipulate (add, get, search, etc) initiatives.

add(title, description=None, data=None, thumbnail=None)

Adds a new initiative to the Hub.

Argument

Description

title

Required string.

description

Optional string.

data

Optional string. Either a path or URL to the data.

thumbnail

Optional string. Either a path or URL to a thumbnail image.

Returns

The initiative if successfully added, None if unsuccessful.

USAGE EXAMPLE: Add an initiative successfully

initiative1 = myHub.initiatives.add(title='Vision Zero Analysis')
initiative1.item
get(initiative_id)

Returns the initiative object for the specified initiative_id.

Argument

Description

initiative_id

Required string. The initiative itemid.

Returns

The initiative object if the item is found, None if the item is not found.

USAGE EXAMPLE: Fetch an initiative successfully

initiative1 = myHub.initiatives.get('itemId12345')
initiative1.item
search(scope=None, title=None, owner=None, created=None, modified=None, tags=None)

Searches for initiatives.

Argument

Description

scope

Optional string. Defines the scope of search. Valid values are ‘official’, ‘community’ or ‘all’.

title

Optional string. Return initiatives with provided string in title.

owner

Optional string. Return initiatives owned by a username.

created

Optional string. Date the initiative was created. Shown in milliseconds since UNIX epoch.

modified

Optional string. Date the initiative was last modified. Shown in milliseconds since UNIX epoch

tags

Optional string. User-defined tags that describe the initiative.

Returns

A list of matching initiatives.

IndicatorManager

class arcgis.apps.hub.IndicatorManager(gis, initiativeItem)

Helper class for managing indicators within an initiative. This class is not created by users directly. An instance of this class, called ‘indicators’, is available as a property of the Initiative object. Users call methods on this ‘indicators’ object to manipulate (add, get, search, etc) indicators of a particular initiative.

add(indicator_properties)

Adds a new indicator to given initiative.

Key:Value Dictionary Options for Argument indicator_properties

Key

Value

id

Required string. Indicator identifier within initiative template

name

Optional string. Indicator name

type

Optional string. Valid values are Data, Parameter.

optional

Required boolean

definition

Optional dictionary. Specification of the Indicator - types, fields

source

Optional dictionary. Reference to an API or collection of data along with mapping between schemas

Returns

A bool containing True (for success) or False (for failure).

USAGE EXAMPLE: Add an indicator successfully

indicator1_data = {'id': 'streetCrashes', 'type': 'Data', 'optional':False}
initiative1.indicators.add(indicator_properties = indicator1_data)

>> True
get(indicator_id)

Returns the indicator object for the specified indicator_id.

Argument

Description

indicator_id

Required string. The indicator identifier.

Returns

The indicator object if the indicator is found, None if the indicator is not found.

search(url=None, item_id=None, name=None)

Searches for indicators within an initiative.

Argument

Description

url

Optional string. url registered for indicator in source dictionary.

item_id

Optional string. itemid registered for indicator in source dictionary.

name

Optional string. name registered for indicator in source dictionary.

Returns

A list of matching indicators.

EventManager

class arcgis.apps.hub.EventManager(hub, event=None)

Helper class for managing events within a Hub. This class is not created by users directly. An instance of this class, called ‘events’, is available as a property of the Hub object. Users call methods on this ‘events’ object to manipulate (add, search, get_map etc) events of a particular Hub.

get_map()

Plot all events for a Hub in an embedded webmap within the notebook.

search(initiative_id=None, title=None, location=None, organizer_name=None)

Searches for events within a Hub.

Argument

Description

initiative_id

Optional string. Initiative itemid.

title

Optional string. Title of the event.

location

Optional string. Location where event is held.

organizer_name

Optional string. Name of the organizer of the event.

Returns

A list of matching indicators.