-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata.py
More file actions
32 lines (25 loc) · 926 Bytes
/
data.py
File metadata and controls
32 lines (25 loc) · 926 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import pandas as pd
import geopandas as gpd
import pickle
import gzip
# Route GeoJSON files
bus_route = gpd.read_file("data/inputs/Bus_Routes.geojson")
transit_route = gpd.read_file("data/inputs/Transit_Routes.geojson")
route_shp = pd.concat([bus_route, transit_route])
# route_shp = route_shp[["OBJECTID", "route_id", "geometry"]]
route_shp_sim = route_shp.copy()
route_shp_sim['geometry'] = route_shp.simplify(0.0001)
route_shp_sim.to_file("data/outputs/routes.geojson", driver="GeoJSON")
# route_shp.to_pickle("data/outputs/routes.pkl")
# with open("data/outputs/routes.pkl", "wb") as f:
# pickle.dump(route_shp, f)
# --------- #
# Trip
trip_df = pd.read_csv("data/inputs/trips.txt")
print(trip_df.columns)
trip_df = trip_df[["trip_id", "trip_headsign"]]
trip_df = trip_df.rename(columns={
"trip_id": "Trip",
"trip_headsign": "Headsign"
})
trip_df.to_csv("data/outputs/trip_compressed.txt", index=False)