Arcpy - Calculate total time, last value minus first value

المشرف العام

Administrator
طاقم الإدارة
For the script tool I've written (below), one of the things I want to do is after user input has pulled tabular data (into a feature class) I want to take the last value of the 'logdt' and subtract it by the first value of the 'logdt'. 'logdt' being a time value in this format '2/1/2014 10:00:11 AM'. The reason being is that I want to determine the total length of time that has passed since the first and last pings for a specific vehicle in a given day. Once I have made this minor calculation I will then use it to determine how many, if any, lost pings occurred that day.

I'm sure it's very simple but I am newer to arcpy/python and cannot think of a way to do the logdt.lastValue - logdt.firstValue subtraction. Any help is greatly appreciated, thanks!

# import arcpy module import arcpy # Ask user to select the Geodatabase workspace to use for data output userWorkspace = arcpy.GetParameterAsText(0) # Set workspace environment based upon user's choice arcpy.env.workspace = userWorkspace # Ask user to select an Oracle dB Connection oracleDB = arcpy.GetParameterAsText(1) # Ask user to name the Query Layer queryLayerName = arcpy.GetParameterAsText(2) # Ask user for an SQL Query Expression to be run against the selected Oracle dB sqlQuery = arcpy.GetParameterAsText(3) # Create spatial reference variable spatialRef = arcpy.SpatialReference("W:\Data_Structure\Vector\Coordinate Systems\WGS 1984.prj") # Process: 'Make Query Layer' - Creates a Query Layer using the user's Oracle dB and SQL query expression # Parameters: (input_database, out_layer_name, query, {oid_fields}, # {shape_type}, {srid}, {spatial_reference}) arcpy.MakeQueryLayer_management(oracleDB, "Temp_Layer", sqlQuery, "WINTER_IDNUM", "POLYLINE", "1050010", spatialRef) # Process: 'Copy Features' - Copies the temporary Query Layer and stores it as a permanent feature class # Parameters: (in_features, out_feature_class, {config_keyword}, # {spatial_grid_1}, {spatial_grid_2}, {spatial_grid_3}) arcpy.CopyFeatures_management("Temp_Layer", queryLayerName) # Process: 'Define Projection' - Defines the projection of queryLayerName feature class output arcpy.DefineProjection_management(queryLayerName, spatialRef)

أكثر...
 
أعلى