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 from the GIS to perform continuous processing and analysis. It includes support for stream layers that allow Python scripts to 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

class arcgis.realtime.StreamLayer(url, gis=None)

Allows Python scripts to subscribe to the feature data streamed from the GIS, using ArcGIS GeoEvent Server or ArcGIS Velocity, or to broadcast updates and alerts. This class can be used to perform continuous processing and analysis on streaming data as it is received.

property filter

Get/Set property used for filtering the streamed features so they meet spatial and SQL like criteria, and return the specified fields.

property out_sr

Get/Set the spatial reference of the streamed features.

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 ArcGIS GeoEvent Server or ArcGIS Velocity. Subscribing to the streamed data can be used to perform continuous processing and analysis of real-time data as it is received.

Parameter

Description

on_features

callback function that is called every time features are streamed to the client.

on_open

callback function called when the connection to the streaming server is created.

on_disconnect

callback function called when the connection to the streaming server is closed.

on_error

callback function called if the connection recieves an error.

Velocity

class arcgis.realtime.Velocity(url, 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.velocity
velocity
# UsageExample:

from arcgis.gis import GIS
gis = GIS(url="url",username="username",password="password",)

velocity = gis.velocity
velocity
property bigdata_analytics

Provides access to the resource manager for managing configured big data analytic tasks in ArcGIS Velocity.

Returns

BigDataAnalyticsManager

# Get instance of bigdata_analytics from `velocity`:

bigdata_analytics = velocity.bigdata_analytics
bigdata_analytics
property feeds

Provides access to the resource manager for managing configured feeds in ArcGIS Velocity.

Returns

FeedsManager

# Get instance of feeds from `velocity`:

feeds = velocity.feeds
feeds
property realtime_analytics

Provides access to the resource manager for managing configured real-time analytic tasks in ArcGIS Velocity.

Returns

RealTimeAnalyticsManager

# Get instance of realtime_analytics from `velocity`:

realtime_analytics = velocity.realtime_analytics
realtime_analytics

FeedsManager

class arcgis.realtime.velocity.FeedsManager(url, gis)

Used to manage a feed item.

Parameter

Description

url

URL of the ArcGIS Velocity organization.

gis

An authenticated GIS object.

create(feed=None)

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 instance

from arcgis import GIS
from arcgis.realtime.velocity.feeds_manager import Feed

gis = GIS(
    url="https://url.link",
    username="user_name",
    password="user_password",
)

velocity = gis.velocity
feeds = gis.velocity.feeds
feeds

# Configure the Feature Layer Feed

from arcgis.realtime.velocity.feeds import FeatureLayer
from arcgis.realtime.velocity.http_authentication_type import (
    NoAuth,
    BasicAuth,
    CertificateAuth,
)

from arcgis.realtime.velocity.input.format import DelimitedFormat
from arcgis.realtime.velocity.feeds.geometry import XYZGeometry, SingleFieldGeometry
from arcgis.realtime.velocity.feeds.time import TimeInterval, TimeInstant
from arcgis.realtime.velocity.feeds.run_interval import RunInterval

# feature layer properties

name = "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 field

time = 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 recurrence

run_interval = RunInterval(
    cron_expression="0 * * ? * * *",
    timezone="America/Los_Angeles"
)

# Set geometry field - configuring X,Y and Z fields

geometry = 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-type

feature_layer_config.rename_field("org_field_name", "new_field_name")
feature_layer_config.remove_field("description")

# Set track id

feature_layer_config.set_track_id("track_id")

# Set recurrence

feature_layer_config.run_interval = RunInterval(
    cron_expression="0 * * ? * * *", timezone="America/Los_Angeles"
)

# Create the feed and start it
feature_layer_feed = feeds.create(feature_layer_config)
feature_layer_feed.start()
feeds.items
get(id)

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")
property items

Get all feeds.

Returns

returns a collection of all configured feed tasks with feed id and feed label.

# Get all feeds item

all_feeds = feeds.items
all_feeds

RealTimeAnalyticsManager

class arcgis.realtime.velocity.RealTimeAnalyticsManager(url, 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)

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")
property items

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 items

all_realtime_analytics = realtime_analytics.items
all_realtime_analytics

BigDataAnalyticsManager

class arcgis.realtime.velocity.BigDataAnalyticsManager(url, 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)

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")
property items

Get all big data analytic items.

Returns

returns a collection of all configured Big Data Analytics items

# Get all big data analytics

all_bigdata_analytics = bigdata_analytics.items
all_bigdata_analytics

Feed

class arcgis.realtime.velocity.Feed(gis, util, item=None)

The Feed class implements Task and provides public facing methods to access Feed API endpoints.

delete()

Deletes an existing Feed instance.

Returns

A boolean containing True (for success) or False (for failure) a dictionary with details is returned.

# Delete a feed

# Method: <item>.delete()

sample_feed.delete()
property metrics

Get the metrics of the running Feed for the given ID.

Returns

response of feed metrics

# Method: <item>.metrics

# Retrieve metrics of sample_feed

metrics = sample_feed.metrics
metrics
start()

Start the Feed for the given ID.

Returns

response of feed start

# start feed

# Method: <item>.start

sample_feed.start()
property status

Get the status of the running Feed for the given ID. :return: response of Feed status

# Retrieve status of sample_feed

# Method: <item>.status

Sample_feed = feeds.get("id")
status = sample_feed.status
status
stop()

Stop the Feed for the given ID. Return True if the Feed was successfully stopped.

Returns

boolean

# stop feed

# Method: <item>.stop

sample_feed.stop()

RealTimeAnalytics

class arcgis.realtime.velocity.RealTimeAnalytics(gis, util, item=None)

the RealTimeAnalytics class implements Task and provides public facing methods to access RealTimeAnalytics API endpoints.

delete()

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
property metrics

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.metrics
metrics
start()

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()
property status

Get the status of the running Real-Time Analytics for the given ID.

Returns

response of Real-Time Analytics status

# Retrieve status of real-time analytics task

# Property: <item>.status()

status = sample_realtime_task.status
status
stop()

Stop the Real-Time Analytics for the given ID. Return True if the the Real-Time Analytics was successfully stopped.

Returns

boolean

# Stop real-time analytics

# Method: <item>.stop()

sample_realtime_task.stop()

BigDataAnalytics

class arcgis.realtime.velocity.BigDataAnalytics(gis, util, item=None)

The BigDataAnalytics class implements Task and provides public facing methods to access BigDataAnalytics API endpoints.

delete()

Deletes an existing Big Data Analytics instance.

Returns

A boolean containing True (for success) or False (for failure) a dictionary with details is returned.

# Delete a big data analytics

# Method: <item>.delete()

sample_bigdata_task.delete
property metrics

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.metrics
metrics
start()

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()
property status

Get the status of the running Big Data Analytics for the given ID.

Returns

response of Big Data Analytics status

# Retrieve status of big data analytics task

# Property: <item>.status()

status = sample_bigdata_task.status
status
stop()

Stop the Big Data Analytics for the given ID. Return True if the Big Data Analytics was successfully stopped.

Returns

boolean

# Stop big data analytics

# Method: <item>.stop()

sample_bigdata_task.stop()

BasicAuth

class arcgis.realtime.velocity.BasicAuth(username, password)

This dataclass is used to specify a Basic HTTP Authentication scenario using username and password.

Parameter

Description

username

String. Username for basic authentication.

password

String. Password for basic authentication.

password: str
username: str

CertificateAuth

class arcgis.realtime.velocity.CertificateAuth(pfx_file_http_location, password)

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.

password: str
pfx_file_http_location: str

NoAuth

class arcgis.realtime.velocity.NoAuth

This dataclass is used to specify the no HTTP authentication scenario.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.