Exporting the Generated Data

The generated data can be exported, for example, in CSV format using the following queries.

COPY (SELECT InstantId, Instant FROM Instants ORDER BY InstantId)
  TO '/home/mobilitydb/data/instants.csv' CSV HEADER DELIMITER ',';
COPY (SELECT LicenceId, Licence, VehId FROM Licences ORDER BY LicenceId)
  TO '/home/mobilitydb/data/licences.csv' CSV HEADER DELIMITER ',';
COPY (SELECT PeriodId, lower(Period) AS StartP, upper(Period) AS EndP FROM Periods ORDER BY PeriodId)
  TO '/home/mobilitydb/data/periods.csv' CSV HEADER DELIMITER ',';
COPY (SELECT PointId, ST_X(Geom) AS PosX, ST_Y(Geom) AS PosY FROM Points ORDER BY PointId)
  TO '/home/mobilitydb/data/points.csv' CSV HEADER DELIMITER ',';
COPY (
  SELECT RegionId, (dp).path[2] AS PointID, ST_X((dp).geom) AS PosX,
    ST_Y((dp).geom) AS PosY
  FROM (SELECT RegionId, ST_DumpPoints(ST_Transform(geom, 4326)) AS dp FROM Regions) AS T
  ) TO '/home/mobilitydb/data/regions.csv' CSV HEADER DELIMITER ',';
COPY (
  WITH Temp1 AS (
    SELECT TripId, VehId, unnest(instants(trip)) AS Inst FROM Trips ),
  Temp2 AS (
    SELECT TripId, VehId, ST_Transform(getValue(Inst),4326) AS Point,
      getTimestamp(Inst) AS T FROM Temp1 )
  SELECT TripId, VehId, ST_X(Point) AS PosX, ST_Y(Point) AS PosY, T
  FROM Temp2
  ORDER BY TripId, VehId, T
  ) TO '/home/mobilitydb/data/trips.csv' CSV HEADER DELIMITER ',';
COPY (SELECT VehId, Licence, Type, Model FROM SELECT Vehicles ORDER BY VehicleId)
  TO '/home/mobilitydb/data/vehicles.csv' CSV HEADER DELIMITER ',';

Actually, the data we used in Chapter 1, MobilityDB Tutorial was exported by running the BerlinMOD generator with OSM data for Brussels with the scale factor 0.005.