I created a model in ModelBuilder to take a set GPS coordinates (containing latitude, longitude, timestamp, user_id) from different users, create a polyline feature class, and then split the polyline to get segments between each point for a given user. Think of it as getting the individual legs of a trip, for an individual user.

Is it possible, when creating the line segments, to maintain the attributes from the vertices of the points in which a segment was created (e.g. coordinates and the timestamp of the beginning and ending vertices)?

The purpose is to eventually calculate the velocity of an individual on a given segment of their trip.

Below is my model in python:

import arcpy

#Local variables:
infc = "C:\Path\infc" #input feature class
points2line = "C:\Path\infc_points2line" #polyline feature class
points2line_split = "C:\Path\infc_points2line_split" #line split feature class
points2line_split = "C:\Path\infc_points2line_split"

#Points to line
arcpy.PointsToLine_management(infc, points2line,"user_id", "timestamp", "NO CLOSE")

#Split Line at Vertices
arcpy.SplitLine_management(points2line, points2line_split)

#Add Field for distance conversion
arcpy.AddField_management(points2line_split, "distance_km", "DOUBLE", "", "", "", "", "NULLABLE", "NON_REQUIRED", "")

#Calculate Field, convert Shape_Length from DD to KM
arcpy.Calculate_management(points2line_split, "distance_km", "[Shape_Length] * 111.32", "VB", "")

#Line Density
arcpy.gp.LineDensity_sa(points2line_split, "NONE", infc + "linedensity", "0.3", "0.1", "SQUARE MAP UNITS")
#Cell Size and Search Radius = decimal degree - convert to meters: 1.0(111.32km), 0.1(11.132km), 0.01(1.1132km), 0.001(111.32m), 0.0001(11.132m), 0.00001(1.1132m)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.