cvts package¶
Subpackages¶
Submodules¶
cvts.models module¶
Module providing an ORM for objects of interest.
- class cvts.models.Base(**kwargs)¶
Bases:
sqlalchemy.orm.decl_api.Base
The location a vehicle is garraged.
- id¶
- lat¶
- lon¶
- vehicle¶
- vehicle_id¶
- class cvts.models.Stop(**kwargs)¶
Bases:
sqlalchemy.orm.decl_api.Base
The location a vehicle is garraged.
- end_lat¶
- end_lon¶
- end_time¶
- id¶
- n_stationary¶
- start_end_dist¶
- start_lat¶
- start_lon¶
- start_time¶
- vehicle¶
- vehicle_id¶
- class cvts.models.Traversal(**kwargs)¶
Bases:
sqlalchemy.orm.decl_api.Base
A traversal of a
Segment
.- count¶
- dow¶
- doy¶
- edge¶
- hour¶
- id¶
- speed¶
- timestamp¶
- trip¶
- trip_id¶
- vehicle¶
- vehicle_id¶
- woy¶
- class cvts.models.Trip(**kwargs)¶
Bases:
sqlalchemy.orm.decl_api.Base
The location a vehicle is garraged.
- end¶
- end_id¶
- id¶
- start¶
- start_id¶
- vehicle¶
- vehicle_id¶
cvts.settings module¶
- cvts.settings.BOUNDARIES_PATH = '/home/kna012/.cvts/boundaries'¶
Directory for shape files for geographies.
- cvts.settings.CONFIG_PATH = '/home/kna012/.cvts/config'¶
Directory containing
VALHALLA_CONFIG_FILE
- cvts.settings.DEBUG = False¶
Are we debugging. Can be set via the environment variable CVTS_DEBUG.
- cvts.settings.EARTH_RADIUS = 6371000¶
Radius of the Earth in meters.
- cvts.settings.LAKE_FLAG = 'lake'¶
String used to denote stuff from the lake
- cvts.settings.MIN_DISTANCE_BETWEEN_STOPS = 50¶
The distance between two stops below which they are considered to be the same location.
- cvts.settings.MIN_MOVE_DISTANCE = 50¶
The minimum distance a vehicle can move between two (potentially non-adjacent) GPS points to not be considered ‘moving’ in meters.
- cvts.settings.MIN_MOVING_SPEED = 4¶
The minimum speed a vehicle can be moving to be considered ‘moving’ in kilometers per hour.
- cvts.settings.MIN_STOP_TIME = 480¶
The minimum time a vehicle must not move for to be considered ‘stopped’ in seconds.
- cvts.settings.OUT_PATH = '~/.cvts/output'¶
Root directory for outputs.
- cvts.settings.POSTGRES_CONNECTION_STRING = None¶
The connection string for PostGRE. Read from the environment variable CVTS_POSTGRES_CONNECTION_STRING.
- cvts.settings.RAW_DATA_FILE_EXTENSIONS = ['.csv']¶
Extensions for the input files to keep. Only used if RAW_DATA_FORMAT is RawDataFormat.CSV or RawDataFormat.GZIP.
- cvts.settings.RAW_DATA_FORMAT = RawDataFormat.CSV¶
The format the raw data is stored in.
- cvts.settings.RAW_PATH = '/home/kna012/.cvts/raw'¶
Root directory for input files.
- cvts.settings.SEQ_PATH = '~/.cvts/output/seq'¶
Output directory for trip outputs.
- cvts.settings.SPEED_PATH = '~/.cvts/output/speed'¶
Output directory for speed outputs.
- cvts.settings.SRC_DEST_PATH = '~/.cvts/output/src_dest'¶
Output directory for source/destination outputs.
- cvts.settings.STOP_PATH = '~/.cvts/output/stop'¶
Output directory for stop points.
- cvts.settings.VALHALLA_CONFIG_FILE = '/home/kna012/.cvts/config/valhalla.json'¶
Path to Valhalla configuration file.
- cvts.settings.WORK_PATH = '~/.cvts'¶
Default root directory
- cvts.settings.setup_logging(level=20)¶
Module contents¶
- cvts.distance(x0, y0, x1, y1)¶
Quick and adequate distance calculation for for small distances in meters between two lon/lats.
This should be adequate for the purpose of measuring points between points in the kinds of GPS traces we are working with, where the typical sampling interval is around 15 seconds (i.e., differences in latitude between y0 and y1 are (very) small).
- cvts.json2geojson(data, shape_only)¶
Convert the output from Valhalla to a GeoJSON object.
On the command line, the call would look like:
valhalla_service <config-file> trace_attributes <input-file>
- cvts.jsonfile2geojsonfile(infile, outfile)¶
- cvts.points_to_polys(points, shapedata)¶
Calculate which geometry each point in points lie within.
- Parameters
points (
NDArray
) – Two column numpy array containing the longitudes and latitudes of the address points.shapedata (
str
) – tuple containing geometry IDs, polygions and bounding boxes for a geography.
- Return type
NDArray
- Returns
The geometry ID for each point.
- cvts.rawfiles2jsonchunks(input_descriptor, split_trips, dates)¶
Create a generator over all the data for a single vehicle from data in a csv or iterable of csvs.
- Parameters
- Return type
- Returns
A geenerator over a dicts that contain information about each GPS point. Each dict looks like:
{ 'lat': float(row['Longitude']), 'lon': float(row['Latitude']), 'time': float(row['Time']), 'heading': float(row['Orientation']), 'speed': float(row['speed']), 'heading_tolerance': 45, 'type': 'via' }
- cvts.rawfiles2jsonfile(csv_file, out_file)¶
Call
rawfiles2jsonchunks()
, passing csv_files and False, and write the result to out_file.
- cvts.read_shapefile(filename, geometry_id_field)¶
Load the data from a shapefile.
- cvts.vehicle_ids()¶