arcgis.realtime module

The arcgis.velocity module provides API functions mapping to automate the ArcGIS Velocity REST API. ArcGIS Velocity is a real-time and big data processing and analysis capability of ArcGIS Online. It enables you to ingest, visualize, analyze, store, and act upon data from Internet of Things (IoT) sensors.

The arcgis.realtime.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.

StreamLayer

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

Stream layers allow Python scripts to subscribe to the feature data streamed from the GIS using the GeoEvent Processor or broadcast updates or alerts. This class can be used to perform continuous processing and analysis of real-time data as it’s 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 the GeoEvent Processor. Subscribing to the streamed data can be used to perform continuous processing and analysis of real-time data as it’s received. :param on_features: callback function that is called every time features are streamed to the client :param on_open: callback function called when the connection to the streaming server is created :param on_disconnect: callback function called when the connection to the streaming server is closed :param on_error: callback function called if the connection recieves an error

Velocity

class arcgis.realtime.Velocity(url: str, gis: arcgis.gis.GIS)

Provides access to Realtime Analytics, Big data Analytics and Feeds in Velocity

Argument

Description

url

velocity org URL

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 analytics tasks with 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 with 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 analytics tasks with 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: str, gis: arcgis.gis.GIS)

Use to get feeds item

Argument

Description

url

velocity org URL

gis

an authenticated arcigs.gis.GIS object.

create(feed=None) → arcgis.realtime.velocity._feed.Feed

Creates a new feed configuration

Argument

Description

feed

An instance of feed like RSS, HTTP Poller etc.

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) → arcgis.realtime.velocity._feed.Feed

Get Feed by id

Argument

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: str, gis: arcgis.gis.GIS)

Use to get real-time analytics item

Argument

Description

url

velocity org URL

gis

an authenticated arcigs.gis.GIS object.

get(id) → arcgis.realtime.velocity._realtime_analytics.RealTimeAnalytics

Get real-time analytics by id

Argument

Description

id

unique id of a real-time analytics

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 analytics 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: str, gis: arcgis.gis.GIS)

Use to get big data analytics item

Argument

Description

url

velocity org URL

gis

an authenticated arcigs.gis.GIS object.

get(id) → arcgis.realtime.velocity._bigdata_analytics.BigDataAnalytics

Get big data analytics by id

Argument

Description

id

Unique id of a big data 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 analytics 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: arcgis.gis.GIS, util: arcgis.realtime.velocity._util._Util, item: Optional[Dict] = None)

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

delete() → bool

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() → Dict

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() → Dict

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: arcgis.gis.GIS, util: arcgis.realtime.velocity._util._Util, item: Optional[Dict] = None)

RealTimeAnalytics class implements Task and provides public facing methods to access 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
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() → 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()
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() → Dict

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: arcgis.gis.GIS, util: arcgis.realtime.velocity._util._Util, item: Optional[Dict] = None)

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

delete() → bool

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() → 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()
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() → Dict

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: str, password: str)

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

Argument

Description

username

str. Username for basic authentication

password

str. Password for basic authentication

password: str
username: str

CertificateAuth

class arcgis.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.

Argument

Description

pfx_file_http_location

str. HTTP path of the PFX file

password

str. 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.

Submodules