ipeaGIT / gtfs2emis

R package to estimate public transport emissions based on GTFS data
https://ipeagit.github.io/gtfs2emis/
Other
27 stars 2 forks source link

Package structure #9

Closed Joaobazzo closed 3 years ago

Joaobazzo commented 4 years ago

Several ideas about the structure of the package were discussed

Inputs

1) GTFS data

GTFS data should be first import through a prep_data function, so the main function can import only the data of interest. The prep_data function should do the following tasks: i) convert GTFS to GPS; i.1) convert GPS data from POINTS to MULTILINESTRING ii) filter by the hour; iii) filter by shape_id; iv) filter by trip_id;

The main data from GTFS, should de something like

emis(
  veh,
  lkm,
  ef,
  speed,
  agemax = ifelse(is.data.frame(veh), ncol(veh), ncol(veh[[1]])),
  profile,
  simplify = FALSE,
  fortran = FALSE,
  hour = nrow(profile),
  day = ncol(profile),
  verbose = FALSE
)

2) Fleet fleet_data

Ideally, the fleet data should be preprocessed previously and be presented according to the structure route_id ; age; category; fuel

It will require later on a function to check whether or not the table is presented accordingly.

In case of no information, the main function of emis should use general data from a source (which should be defined later on) to estimate the fleet_data

3) Emission factor

The emission factor data should be imported, initially, through vein, especially functions such as vein::ef_hdv_speed(), and so on. In the case of no argument input, perhaps a general emission factor should be provided

4) Output

Ideally, the output of the main function should be as broad as possible. Some post-processing function can be than created to export data such as:

Grids, Age, Lines, Period of the day

rafapereirabr commented 4 years ago

Hi all. This is a draft of the general structure flow I have in mind for the gtfs2emis function:

Inputs:

Steps

These would be the big steps of the gtfs2emis function:

  1. Read gps-like records in data.table

    • if input is a gtfs.zip, then use gtfs2gps::gtfs2gps
    • if input is a data.table , then use data.table::fread
    • outputs object gps_dt
  2. Convert gps_dt into multilinestring

    • outputs object gps_linestring
  3. Merge fleet_data info to gps_linestring

    • assign fleet characteristics to route_ids
  4. Loads emission factors data

    • load these data from the vein package
  5. Calculate transport emissions by combining info from:

    • emission factors
    • gps_linestring with fleet characteristics
    • this step adds a set of new columns [one for each pollutant] to gps_linestring data, where each column presents the amount of emission in each linestring segment
  6. Save outputs

    • organize different types of outputs (spatial, by time of the day, by type of vehicle)
Joaobazzo commented 4 years ago

I would also add as input: local emission_factors: In Brasil we use data from CETESB, but the user can add some local data. We could also provide/suggest general emission factor data used in situations without local information.

age of fleet associated with euro standard: Class data.table/data.frame. It's useful because we can relate a certain technology of a bus to an euro standard, so we can use speed-dependent emission factor. For instance, in Brazil, buses from 2016 have comparable technology to EURO V - which has consequently specific emission factors dependent on speed. We can find a lot of these relationships in https://www.transportpolicy.net/ , so I don't think it will be an issue

terrain_data: If user wants to have slope-dependent emissions. If this data is missing, we don't consider slope.