arcgis.realtime module
The arcgis.realtime module provides API functions to work with and automate real-time data feeds, continuous processing and analysis of streaming data, and stream layers.
This module contains the following:
StreamLayer
provides types and functions for receiving real-time data feeds and sensor data streamed fromthe GIS to perform continuous processing and analysis. It includes support for stream layers that allow Python scriptsto subscribe to the streamed feature data or broadcast updates or alerts.The
Velocity
class and the various submodules provide API functions to automate the ArcGIS Velocity REST API.
StreamLayer
- classarcgis.realtime.StreamLayer(url,gis=None)
Allows Python scripts to subscribe to the feature data streamed from the GIS, using ArcGISGeoEvent Server or ArcGIS Velocity, or to broadcast updates and alerts. This class can be used to perform continuous processing andanalysis on streaming data as it is received.
- propertyfilter
Get/Set property used for filtering the streamed features so they meet spatial and SQL like criteria,and return the specified fields.
- subscribe(on_features,on_open=None,on_disconnect=None,on_error=None)
Allows Python scripts to subscribe to the feature data streamed from the GIS using ArcGISGeoEvent Server or ArcGIS Velocity. Subscribing to the streamed data can be used to perform continuous processing andanalysis of real-time data as it is received.
Parameter
Description
on_features
callback function that is called every time features are streamedto the client.
on_open
callback function called when the connection to the streaming serveris created.
on_disconnect
callback function called when the connection to the streaming serveris closed.
on_error
callback function called if the connection recieves an error.
Velocity
- classarcgis.realtime.Velocity(url:str,gis:GIS)
Provides access to real-time analytics, big data analytics, and feeds in ArcGIS Velocity.
Parameter
Description
url
URL of the ArcGIS Velocity organization.
gis
an authenticated
arcigs.gis.GIS
object.# Connect to a Velocity instance:gis=GIS(url="url",username="username",password="password",)velocity=gis.velocityvelocity
# UsageExample:fromarcgis.gisimportGISgis=GIS(url="url",username="username",password="password",)velocity=gis.velocityvelocity
- propertybigdata_analytics:BigDataAnalyticsManager
Provides access to the resource manager for managing configured big data analytic tasks in ArcGIS Velocity.
- Returns:
# Get instance of bigdata_analytics from `velocity`:bigdata_analytics=velocity.bigdata_analyticsbigdata_analytics
- propertyfeeds:FeedsManager
Provides access to the resource manager for managing configured feeds in ArcGIS Velocity.
- Returns:
# Get instance of feeds from `velocity`:feeds=velocity.feedsfeeds
- propertyrealtime_analytics:RealTimeAnalyticsManager
Provides access to the resource manager for managing configured real-time analytic tasks in ArcGIS Velocity.
- Returns:
# Get instance of realtime_analytics from `velocity`:realtime_analytics=velocity.realtime_analyticsrealtime_analytics
FeedsManager
- classarcgis.realtime.velocity.FeedsManager(url:str,gis:GIS)
Used to manage a feed item.
Parameter
Description
url
URL of the ArcGIS Velocity organization.
gis
An authenticated
GIS
object.- create(feed=None)→Feed
Creates a new feed configuration.
Parameter
Description
feed
An instance of a feed such as RSS or HTTP Poller.
- Returns:
Id and label of the newly created feed
# Usage Example of creating a feature layer feed# Connect to a Velocity instancefromarcgisimportGISfromarcgis.realtime.velocity.feeds_managerimportFeedgis=GIS(url="https://url.link",username="user_name",password="user_password",)velocity=gis.velocityfeeds=gis.velocity.feedsfeeds# Configure the Feature Layer Feedfromarcgis.realtime.velocity.feedsimportFeatureLayerfromarcgis.realtime.velocity.http_authentication_typeimport(NoAuth,BasicAuth,CertificateAuth,)fromarcgis.realtime.velocity.input.formatimportDelimitedFormatfromarcgis.realtime.velocity.feeds.geometryimportXYZGeometry,SingleFieldGeometryfromarcgis.realtime.velocity.feeds.timeimportTimeInterval,TimeInstantfromarcgis.realtime.velocity.feeds.run_intervalimportRunInterval# feature layer propertiesname="feature_layer_name"description="feature_layer_description"url="feature_layer_url"extent={"spatialReference":{"latestWkid":3857,"wkid":102100},"xmin":"xmin","ymin":"ymin","xmax":"xmax","ymax":"ymax"}# Set time fieldtime=TimeInterval(interval_start_field="start_field",interval_end_field="end_field"# time instant# time = TimeInstant(time_field="pubDate")# feature_layer_config.set_time_config(time=time))# Set recurrencerun_interval=RunInterval(cron_expression="0 * * ? * * *",timezone="America/Los_Angeles")# Set geometry field - configuring X,Y and Z fieldsgeometry=XYZGeometry(x_field="x",y_field="y",wkid=4326)# a single field geometry could also be configured# geometry = SingleFieldFeometry(# geometry_field="geometry_field"# geometry_type="esriGeometryPoint",# geometry_format="esrijson",# wkid=4326# )# feature_layer.set_geometry_config(geometry=geometry)feature_layer_config=FeatureLayer(label=name,description=description,query="1=1",fields="*",outSR=4326,url=url,extent=extent,time_stamp_field=time)# Manipulate the schema - rename or remove fields, change field data-typefeature_layer_config.rename_field("org_field_name","new_field_name")feature_layer_config.remove_field("description")# Set track idfeature_layer_config.set_track_id("track_id")# Set recurrencefeature_layer_config.run_interval=RunInterval(cron_expression="0 * * ? * * *",timezone="America/Los_Angeles")# Create the feed and start itfeature_layer_feed=feeds.create(feature_layer_config)feature_layer_feed.start()feeds.items
- get(id)→Feed
Get feed by ID.
Parameter
Description
id
Unique ID of a feed.
- Returns:
endpoint response of feed for the given id and label.
# Get feed by id# Method: <item>.get(id)sample_feed=feeds.get("id")
- propertyitems:List[Feed]
Get all feeds.
- Returns:
returns a collection of all configured feed tasks with feed id and feed label.
# Get all feeds itemall_feeds=feeds.itemsall_feeds
RealTimeAnalyticsManager
- classarcgis.realtime.velocity.RealTimeAnalyticsManager(url:str,gis:GIS)
Used to manage real-time analytic items.
Parameter
Description
url
URL of the ArcGIS Velocity organization.
gis
an authenticated
arcigs.gis.GIS
object.- get(id)→RealTimeAnalytics
Get real-time analytic item by ID.
Parameter
Description
id
Unique ID of a real-time analytic.
- Returns:
endpoint response of real-time analytics for the given id and label
# Get real-time analytics by id# Method: <item>.get(id)sample_realtime_task=realtime_analytics.get("id")
- propertyitems:List[RealTimeAnalytics]
Get all real-time analytic items.
- Returns:
returns a collection of all real-time analytics items with id and label.
# Get all real-time analytics itemsall_realtime_analytics=realtime_analytics.itemsall_realtime_analytics
BigDataAnalyticsManager
- classarcgis.realtime.velocity.BigDataAnalyticsManager(url:str,gis:GIS)
Used to manage big data analytic items.
Parameter
Description
url
URL of the ArcGIS Velocity organization.
gis
An authenticated
arcigs.gis.GIS
object.- get(id)→BigDataAnalytics
Get big data analytic items by ID.
Parameter
Description
id
Unique ID of a big data analytic task.
- Returns:
endpoint response of Big Data Analytics for the given id and label
# Get big data analytics by id# Method: <item>.get(id)sample_bigdata_task=bigdata_analytics.get("id")
- propertyitems:List[BigDataAnalytics]
Get all big data analytic items.
- Returns:
returns a collection of all configured Big Data Analytics items
# Get all big data analyticsall_bigdata_analytics=bigdata_analytics.itemsall_bigdata_analytics
Feed
- classarcgis.realtime.velocity.Feed(gis:GIS,util:_Util,item:Dict|None=None)
The
Feed
class implements Task and provides public facing methods to access Feed API endpoints.- delete()→bool
Deletes an existing Feed instance.
- Returns:
A boolean containing True (for success) orFalse (for failure) a dictionary with details is returned.
# Delete a feed# Method: <item>.delete()sample_feed.delete()
- propertymetrics:Dict
Get the metrics of the running Feed for the given ID.
- Returns:
response of feed metrics
# Method: <item>.metrics# Retrieve metrics of sample_feedmetrics=sample_feed.metricsmetrics
- start()→Dict
Start the Feed for the given ID.
- Returns:
response of feed start
# start feed# Method: <item>.startsample_feed.start()
RealTimeAnalytics
- classarcgis.realtime.velocity.RealTimeAnalytics(gis:GIS,util:_Util,item:Dict|None=None)
the
RealTimeAnalytics
class implements Task and provides public facing methods toaccess RealTimeAnalytics API endpoints.- delete()→bool
Deletes an existing Real-Time Analytics task instance.
- Returns:
A boolean containing True (for success) or False (for failure) a dictionary with details is returned.
# Delete a real-time analytics# Method: <item>.delete()sample_realtime_task.delete
- propertymetrics:Dict
Get the metrics of the running Real-Time Analytics for the given ID.
- Returns:
response of Real-Time Analytics metrics
# Retrieve metrics of real-time analytics task# Property: <item>.metrics()metrics=sample_realtime_task.metricsmetrics
- start()→Dict
Start the Real-Time Analytics for the given ID.
- Returns:
response of realtime_analytics start
# Start real-time analytics# Method: <item>.start()sample_realtime_task.start()
BigDataAnalytics
- classarcgis.realtime.velocity.BigDataAnalytics(gis:GIS,util:_Util,item:Dict|None=None)
The
BigDataAnalytics
class implements Task and provides public facing methods toaccess BigDataAnalytics API endpoints.- delete()→bool
Deletes an existing Big Data Analytics instance.
- Returns:
A boolean containing True (for success) orFalse (for failure) a dictionary with details is returned.
# Delete a big data analytics# Method: <item>.delete()sample_bigdata_task.delete
- propertymetrics:Dict
Get the metrics of the running Big Data Analytics for the given ID.
- Returns:
response of Big Data Analytics metrics
# Retrieve metrics of big data analytics task# Property: <item>.metrics()metrics=sample_bigdata_task.metricsmetrics
- start()→Dict
Start the Big Data Analytics for the given ID.
- Returns:
response of bigdata_analytics start
# Start big data analytics# Method: <item>.start()sample_bigdata_task.start()
BasicAuth
CertificateAuth
- classarcgis.realtime.velocity.CertificateAuth(pfx_file_http_location:str,password:str)
This dataclass is used to specify a Basic HTTP Authentication scenario using username and password.
Parameter
Description
pfx_file_http_location
String. HTTP path of the PFX file.
password
String. Password for certificate authentication.
NoAuth
Submodules
- arcgis.realtime.velocity.feeds module
- arcgis.realtime.velocity.input module