ArcGIS Blog

Real-Time Visualization & Analytics

ArcGIS Pro

Geofencing with Real-Time Data in ArcGIS Pro 2.4

By Tanu Hoque

Geofencing is about triggering an action when one feature comes close to another one. With the availability of smartphones, geofencing in not uncommon to us. We set up alerts to notify us as our kids arrive home from school or to remind us to buy something at the grocery store after work. As a public works official, you may want to be notified as soon as snowplows reach a snowed-in area and as they leave afterward.

This blog describes how you can achieve all that, using stream layers and the new real-time API  in ArcGIS Pro 2.4.

Visualize Features Differently When They Are within a Geofence

This is something that you can do easily using an ArcGIS Arcade expression:

  • Open a map in ArcGIS Pro.
  • Add a stream layer off the following ArcGIS Online item:
    https://arcg.is/00iC0y
  • You should make sure to uncheck the Show Previous Observations option from the Stream Layer | Appearance tab.
  • Open the layer’s Symbology pane.
  • Switch to the Vary symbology by attributes tab, under the Current tab.
  • Expand the Color section and click the Expression button
  • You will see the following Arcade expression:

var polygonJSON = {
'rings' : [[[-122.6818,45.5215], [-122.6801,45.5210], [-122.6806,45.5201], [-122.6822,45.5207], [-122.6818,45.5215]]],
'spatialReference' : {'wkid' : 4326}
};
var geom = Polygon(polygonJSON);
iif(Intersects($feature, geom),1,0);

  • Click OK.
  • Choose a color scheme.
  • Add another feature layer from ArcGIS Online:
    https://arcg.is/0yK9iX
    The coordinates used in the Arcade expression above represent the polygon from this layer.
  • Wait for few moments—you will see the color for these point features change as they move within the polygon.

Please note that this approach only works when features are drawn using Shape marker symbols.

Geofence - use Arcade expression to change symbol as features enter a restricted area
Geofence - use Arcade expression to change symbol as features enter a restricted area

Send Alerts

  • Download a Visual Studio project from https://arcg.is/0jH09i.
  • Open and compile the Visual Studio project—make sure there are no compile time errors.
  • Press F5 to start. ArcGIS Pro opens.
  • Open the ArcGIS Pro project that comes with this project, inside the Data folder.
  • Open the ExploratoryAnalysis—Geo-fence map.
  • Click the Geo-fence command from the Real-time Analysis tab.
  • Wait until a feature moves inside the restricted zone. You will see toast notifications for each feature as they enter the zone.
    • You can also click the Notification command from the upper right corner to see notifications in the Notification pane.
  • Point to one of the notifications and click Clear All if you want to see these notifications all over again.
  • Click the Geo-fence button again to stop listening to the real-time feed.
Geofence - notifications as vehicles enter a restricted area
Geofence - notifications as vehicles enter a restricted area

I have used a stream service that simulates two vehicles moving along streets in Portland, Oregon. The sample code, data, and ArcGIS Pro project can be accessed from https://arcg.is/0jH09i.

Share this article

Subscribe
Notify of
0 Comments
Oldest
Newest
Inline Feedbacks
View all comments