City Geo Trips

CityGeoTrips class

class CityGeoTrips(city_name, trips_data_source_id, year, month)

This abstract class deals with managing geographic travel information (e.g. departure, arrival, distance, etc.). This class is implemented by the other classes of this module. The constructor method takes as parameters:

Parameters
  • city_name (str) – City name. The name also serves to determine the timezone to which the city belongs

  • trips_data_source_id (str) – Data source from which the information is taken. This allows us to have multiple data sources associated with the same city (for example from different operators)

  • year (int) – year expressed as a four-digit number (e.g. 1999)

  • month (int) – month expressed as a number (e.g. for November the method expects to receive 11)

get_trips_od_gdfs()

This method is used to store the movements, using the Shapely library. The normalized data is loaded (—-> reference to save_norm magari<—–) and the method builds three GeoDataFrame. The trips are encoded using an object of the LineString class from the Shapely library. They are described as a segment having the coordinates of departure and arrival as extremes. In addition, two more GeoDataFrames are created, using objects of the Shapely.Point class to describe departures and arrivals.

Returns

nothing

load()

Load from memory, using the pickle file created by the save methods, the three GeoDataFrame

Returns

nothing

save_points(points, filename)

Support method to save_data_points. It stores the points passed to it as a parameter both on csv file and on pickle.

Parameters
  • points (geopandas.GeoDataFrame) – A GeoDataFrame describing the information of points to be saved

  • filename (str) – Filename

Returns

nothing

save_points_data()

Stores the points representing start and finish on file

Returns

nothing

save_trips()

It stores on file the segments that represent the path between start and finish

Returns

nothing