Data Aggregating

dataagg(data, shape[, col, accuracy])

Aggregate data to traffic zone

odagg_grid(oddata, params[, col, arrow])

Aggregate the OD matrix and generate the grid geometry.

odagg_shape(oddata, shape[, col, params, ...])

Generate the OD aggregation results and the corresponding geometry.

transbigdata.dataagg(data, shape, col=['Lng', 'Lat', 'count'], accuracy=500)

Aggregate data to traffic zone

Parameters:
  • data (DataFrame) – The origin DataFrame

  • shape (GeoDataFrame) – The shape of the traffic zone

  • col (List) – You can either choose to input two columns, i.e., [‘Lng’,’Lat’], or to input three columns, i.e., [‘Lng’,’Lat’,’count’]”, where count means the points count

  • accuracy (number) – The idea is to first implement data gridding and then the aggregation. Here, the grid size will be determined. The less the size is, the higher the accuracy will have.

Returns:

  • aggresult (GeoDataFrame) – Traffic zone. The count column is the output result

  • data1 (DataFrame) – The zone-matched data

transbigdata.odagg_grid(oddata, params, col=['slon', 'slat', 'elon', 'elat'], arrow=False, **kwargs)

Aggregate the OD matrix and generate the grid geometry. The input is the OD matrix (each row represents a trip). The OD will assigned to grids and then aggregated in the form of GeoDataFrame.

Parameters:
  • oddata (DataFrame) – OD data

  • col (List) – The column of the origin/destination location,[‘slon’,’slat’, ’elon’,’elat’]. The default weight is 1 for each column. You can also add the weight parameter, for example, [‘slon’, ’slat’,’elon’,’elat’,’count’].

  • params (List) – Gridding parameters (lonStart,latStart,deltaLon,deltaLat), lonStart and latStart are the lower-left coordinates, deltaLon, deltaLat are the length and width of a single grid

  • arrow (bool) – Whether the generated OD geographic line contains arrows

Returns:

oddata1 – GeoDataFrame of OD after aggregation

Return type:

GeoDataFrame

transbigdata.odagg_shape(oddata, shape, col=['slon', 'slat', 'elon', 'elat'], params=None, round_accuracy=6, arrow=False, **kwargs)

Generate the OD aggregation results and the corresponding geometry. The input is the OD data (each row represents a trip). The OD will assigned to grids and then aggregated in the form of GeoDataFrame.

Parameters:
  • oddata (DataFrame) – OD data

  • shape (GeoDataFrame) – GeoDataFrame of the target traffic zone

  • col (List) – The column of the origin/destination location,[‘slon’,’slat’,’elon’ ,’elat’]. The default weight is 1 for each column. You can also add the weight parameter, for example, [‘slon’,’slat’,’elon’,’elat’, ’count’].

  • params (List (optional)) – Gridding parameters (lonStart,latStart,deltaLon,deltaLat), lonStart and latStart are the lower-left coordinates, deltaLon, deltaLat are the length and width of a single grid If availabel, After the data gridding, the traffic zone will be matched based on the grid center. If not available, then the matching will be processed based on longitude and latitude. When the number of data items is large, the matching efficiency will be improved greatly thanks to data gridding.

  • round_accuracy (number) – The number of decimal for latitude and longitude when implementing aggregation

  • arrow (bool) – Whether the generated OD geographic line contains arrows

Returns:

oddata1 – GeoDataFrame of OD after aggregation

Return type:

GeoDataFrame