HOW TO

Create point features from line feature vertices using ArcPy in ArcGIS Pro

Last Published: December 23, 2024

Summary

In ArcGIS Pro, creating point features from line feature vertices is useful in capturing detailed spatial data, for instance, extracting precise coordinates or examining vertex connectivity. This method is beneficial in network analysis, as it helps identify intersections and directional changes along line features such as roads or rivers. In ArcGIS Pro, the Feature Vertices To Points tool available with an ArcGIS Desktop Advanced license can be used for this purpose.

However, point features can also be generated from line feature vertices using ArcPy, which provides greater flexibility for automating and customizing the workflow. This article outlines the workflow to achieve this using ArcPy.

Procedure

  1. Open the ArcGIS Pro project.
  2. Open the Python window. Refer to ArcGIS Pro: Python window for instructions and more information.
  3. Run the following script.
    1. To import the necessary module:
import arcpy
  1. To specify the workspace environment:
arcpy.env.workspace = r"<geodatabase_path>"
  1. To specify the input line feature class:
input_fc = "<line_layer>"
  1. To specify the output point feature class:
output_fc = "<point_output>"
  1. To create an empty point feature class to store the vertices:
arcpy.CreateFeatureclass_management(arcpy.env.workspace, output_fc, "POINT", spatial_reference=input_fc)
  1. To start an edit session:
edit = arcpy.da.Editor(arcpy.env.workspace)
edit.startEditing(False, True)
edit.startOperation()
  1. To iterate through the input features and extract vertices:
with arcpy.da.SearchCursor(input_fc, ["SHAPE@"]) as cursor: 
 with arcpy.da.InsertCursor(output_fc, ["SHAPE@"]) as ins_cursor:; 
  for row in cursor: 
   for part in row[0]: 
     for pnt in part: 
       ins_cursor.insertRow([pnt])
  1. To stop the edit session and save edits:
edit.stopOperation()
edit.stopEditing(True)

print("Vertices extracted and saved as points successfully.")
    1. Place the cursor at the end of the script and press Enter twice to run the script.

The code below demonstrates the full working script.

import arcpy

arcpy.env.workspace = r"C:\Users\user123\Documents\ArcGIS\Projects\MyProject95\MyProject95.gdb"

input_fc = "PTest" output_fc = "PTest_Points" arcpy.CreateFeatureclass_management(arcpy.env.workspace, output_fc, "POINT", spatial_reference=input_fc) edit = arcpy.da.Editor(arcpy.env.workspace) edit.startEditing(False, True) edit.startOperation() with arcpy.da.SearchCursor(input_fc, ["SHAPE@"]) as cursor: with arcpy.da.InsertCursor(output_fc, ["SHAPE@"]) as ins_cursor: for row in cursor: for part in row[0]: for pnt in part: ins_cursor.insertRow([pnt]) edit.stopOperation() edit.stopEditing(True) print("Vertices extracted and saved as points successfully.")

The map below displays the points created from the line feature vertices.

Points created from the vertices of line features

Article ID: 000034191

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