Select to view content in your preferred language

Drawing lines using "calculate field" in a Real time analytic

120
2
Thursday
GeoAnalyst
New Contributor

Hello Everyone

I'm fairly new to both Velocity and using arcade, so i really hope someone here can help me.

I have a Marinetraffic HTTPS feed showing the locations of vessels.
I am trying to draw a line from each of these vessels to the nearest point on an international maritime boundary.

From what I understand, you add the feed for the vessels, and the line feature layer to a real-time analytic, then using the "geometry" calculation type in the Field calculator you can draw these lines.

What I am really unsure about is how to write the arcade expression to accomplish this.

Any help will be massively appreciated!

0 Kudos
2 Replies
Nicole_Phaneuf
Esri Contributor

Hey @GeoAnalyst,

We can create polylines from a target point feature to the nearest feature in another feed or data source using a combination of the Calculate Distance tool and Calculate Fields tools. The key piece here will be having the correct geometry fields in place to build out the polyline geometry.

In my case, I have an HTTP Simulator feed that ingests simulated storm data with point geometry that includes both a latitude and a longitude field. I am also using the "World Cities" ArcGIS Living Atlas layer, which has point geometry and does not have latitude/longitude fields. My goal is to create polylines between the simulated storm data points from the feed and the nearest point from the World Cities dataset.

First, I need to create fields from the geometry of my World Cities dataset to represent the X/Y coordinates of each point. This can be done by connecting my World Cities feed to a Calculate Field tool and creating two new fields with the Arcade expressions "return Geometry($feature).X" and "return Geometry($feature).Y".

Nicole_Phaneuf_0-1729259647688.png

Now that I have X/Y fields for both datasets, I can connect the HTTP Simulator storm data feed to the target port and the World Cities feed to the join port of the Calculate Distance tool. When I configure the Calculate Distance tool, I will use my "xcoord" and "ycoord" fields in the Join fields parameter so that the data output from this tool will include the X/Y fields from both datasets.

Nicole_Phaneuf_1-1729260015758.png

Now I can configure a Calculate Fields tool (Add field calculation > Geometry) to create polyline geometry. 

Nicole_Phaneuf_2-1729260214997.png

Following this, we can use any other tools we may need. In my case, I've chosen to output the data directly to a feature layer so that I can visualize it in Map Viewer.

Nicole_Phaneuf_3-1729260366751.png

GeoAnalyst
New Contributor

Thanks @Nicole_Phaneuf 

Your answer seems very thorough!

I have one more question on which I would appreciate your help.

I've added my Static line feature class as a feed, but when I calculate the X and Y coords as an Int 64 data type the field calculator gives me an "Target field type does not match field type returned by Arcade expression" error and I cant continue. Will your methodology work with a line feature?

ms-teams_QAwY4iULlI.png

Thanks again in advance for your answer.

0 Kudos