HOW TO

Automatically generate point features at the endpoint of line features using an attribute rule in ArcGIS Pro

Last Published: February 25, 2025

Summary

In ArcGIS Pro, it is possible to automatically generate point features at the endpoint of line features when line features are added to the map. This functionality can be implemented using an attribute rule that triggers when a line feature is added. Automating this process ensures consistent data generation and minimizes the risk of human error.

This article provides the workflow to automatically generate point features at the endpoint of line features using an attribute rule in ArcGIS Pro.

Procedure

Note:
An ArcGIS Pro Standard license or higher is required to create and manage attribute rules.
  1. Open the project with the line and point feature layers in ArcGIS Pro.
Note:
The feature layer requires Global IDs to add an attribute rule.
  1. Add the Global ID field to the attribute table of the line feature layer using the Add Global IDs tool. Refer to ArcGIS Pro: Add Global IDs (Data Management) for more information.
  2. In the Contents pane, right-click the line feature layer and click Data Design > Attribute Rules. The Attribute Rules view opens.
  3. In the Attribute Rules view, on the Calculation tab, click the Add Rule drop-down list and select Immediate Calculation.
  4. In the New Rule pane, specify a name for Rule Name. In this example, 'Generate points at the end of lines' is used.
  5. In the Expression box, specify the following Arcade expressions.
    1. Define the variable of the point feature layer. Replace <Field_Name> with the name of the point feature layer.
var point_class = "<Field_Name>";
    1. Create a function to retrieve the endpoint of the line feature.
function get_endpoints(line) {
    var geom = Geometry(line);
    if (Count(geom["paths"]) > 0) {
        var last_point = Point(Geometry(line)["paths"][-1][-1]);
        return [last_point];
    }
    return [];
}
    1. Define an array to store the new points and get the endpoint of the line feature.
var new_points = [];
var endpoints = get_endpoints($feature);
    1. Create a new point feature if an endpoint exists.
if (Count(endpoints) > 0) {
    for (var idx in endpoints) {
        push(new_points, {
            'geometry': endpoints[idx]
        });
    }
}
    1. Return nothing if there is no new point feature.
if (Count(new_points) == 0) {
    return;
}
    1. Prepare the payload for editing the point feature and return the edit payload.
var edit_payload = [{
    'className': point_class,
    'adds': new_points
}];
return {
    "edit": edit_payload
}

The code below shows the example of the full working script:

var point_class = "Test_point";
function get_endpoints(line) {
    var geom = Geometry(line);
    if (Count(geom["paths"]) > 0) {
        var last_point = Point(Geometry(line)["paths"][-1][-1]);
        return [last_point];
    }
    return [];
}
var new_points = [];
var endpoints = get_endpoints($feature);
if (Count(endpoints) > 0) {
    for (var idx in endpoints) {
        push(new_points, {
            'geometry': endpoints[idx]
        });
    }
}
if (Count(new_points) == 0) {
    return;
}
var edit_payload = [{
    'className': point_class,
    'adds': new_points
}];
return {
    "edit": edit_payload
}
  1. Under Triggers, check the Insert check box.
  2. Under Execution, check the Exclude from application evaluation check box.
  3. On the Attribute Rules tab, in the Manage Edits group, click Save.

The following image shows point features are automatically generated at the endpoints of newly created line features.

The points features automatically generated when new line features are created to the map.gif

Article ID: 000034800

Software:
  • ArcGIS Pro 3 3
  • ArcGIS Pro 3 2
  • ArcGIS Pro 3 4

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Related Information

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options