|
27 | 27 | ],
|
28 | 28 | "source": [
|
29 | 29 | "import branca\n",
|
| 30 | + "import folium\n", |
30 | 31 | "import geopandas as gpd\n",
|
31 | 32 | "import intake\n",
|
32 |
| - "import ipywidgets as widgets\n", |
33 | 33 | "import pandas as pd\n",
|
34 | 34 | "\n",
|
35 | 35 | "from IPython.display import Markdown, HTML\n",
|
36 | 36 | "\n",
|
37 | 37 | "import setup_corridors_stats\n",
|
38 | 38 | "from create_parallel_corridors import IMG_PATH, DATA_PATH\n",
|
39 |
| - "from shared_utils import geography_utils\n", |
40 |
| - "from shared_utils import calitp_color_palette as cp\n", |
| 39 | + "from calitp_data_analysis import calitp_color_palette as cp\n", |
41 | 40 | "\n",
|
42 | 41 | "catalog = intake.open_catalog(\"./*.yml\")"
|
43 | 42 | ]
|
|
145 | 144 | " cp.CALITP_CATEGORY_BRIGHT_COLORS[0], #blue\n",
|
146 | 145 | " cp.CALITP_CATEGORY_BRIGHT_COLORS[1] # orange\n",
|
147 | 146 | " ],\n",
|
148 |
| - " )\n", |
149 |
| - " \n", |
150 |
| - " # Instead of using county centroid, calculate centroid from transit_df\n", |
151 |
| - " # Otherwise, it's too zoomed out from where transit routes are\n", |
152 |
| - " transit_centroid = (to_map\n", |
153 |
| - " .to_crs(geography_utils.WGS84).geometry.centroid\n", |
154 |
| - " .iloc[0]\n", |
155 |
| - " )\n", |
156 |
| - "\n", |
157 |
| - " LAYERS_DICT = {\n", |
158 |
| - " \"Highways\": {\"df\": hwy_df,\n", |
159 |
| - " \"plot_col\": \"Route\",\n", |
160 |
| - " \"popup_dict\": hwys_popup_dict, \n", |
161 |
| - " \"tooltip_dict\": hwys_popup_dict,\n", |
162 |
| - " \"colorscale\": hwys_color,\n", |
163 |
| - " },\n", |
164 |
| - " \"Transit Routes\": {\"df\": to_map,\n", |
165 |
| - " \"plot_col\": \"parallel\",\n", |
166 |
| - " \"popup_dict\": transit_popup_dict, \n", |
167 |
| - " \"tooltip_dict\": transit_popup_dict,\n", |
168 |
| - " \"colorscale\": colorscale,\n", |
169 |
| - " },\n", |
170 |
| - " }\n", |
| 147 | + " ) \n", |
171 | 148 | " \n",
|
172 | 149 | " LEGEND_URL = (\n",
|
173 | 150 | " \"https://github.com/cal-itp/data-analyses/raw/\"\n",
|
174 | 151 | " \"main/bus_service_increase/\"\n",
|
175 | 152 | " \"img/legend_intersecting_parallel.png\"\n",
|
176 | 153 | " )\n",
|
177 |
| - " \n", |
178 |
| - " LEGEND_DICT = {\n", |
179 |
| - " \"legend_url\": LEGEND_URL,\n", |
180 |
| - " \"legend_bottom\": 85,\n", |
181 |
| - " \"legend_left\": 5,\n", |
182 |
| - " }\n", |
183 | 154 | " \n",
|
| 155 | + " fig = hwy_df.explore(\n", |
| 156 | + " \"Route\", tiles = \"CartoDB Positron\",\n", |
| 157 | + " cmap = colorscale, tooltip = list(hwys_popup_dict.keys()),\n", |
| 158 | + " name = \"Highways\",\n", |
| 159 | + " )\n", |
184 | 160 | " \n",
|
185 |
| - " fig = map_utils.make_folium_multiple_layers_map(\n", |
186 |
| - " LAYERS_DICT,\n", |
187 |
| - " fig_width = 700, fig_height = 700, \n", |
188 |
| - " zoom=11, \n", |
189 |
| - " centroid = [round(transit_centroid.y,2), \n", |
190 |
| - " round(transit_centroid.x, 2)], \n", |
191 |
| - " title=f\"Parallel vs Intersecting Lines for {to_map.itp_id.iloc[0]}\",\n", |
192 |
| - " legend_dict = LEGEND_DICT\n", |
| 161 | + " fig = to_map.explore(\"parallel\",\n", |
| 162 | + " m=fig, cmap = colorscale, name=\"Transit Routes\",\n", |
| 163 | + " tooltip = list(transit_popup_dict.keys())\n", |
193 | 164 | " )\n",
|
194 | 165 | " \n",
|
| 166 | + " folium.LayerControl().add_to(fig)\n", |
| 167 | + "\n", |
195 | 168 | " display(fig)\n",
|
196 | 169 | " #fig.save(f\"{IMG_PATH}parallel_{operator_name}.html\")\n",
|
197 | 170 | " #print(f\"{operator_name} map saved\")"
|
|
0 commit comments