|
6 | 6 | COUNTRY_IDS_FILE_PATH = "data/processed/world-110m-country-names.tsv" |
7 | 7 |
|
8 | 8 | def create_map_plot(year_start, year_end, countries): |
| 9 | + """Create a world map plot with countries colored by no. of tsunami |
| 10 | + hits and with origin points. |
| 11 | +
|
| 12 | + Parameters |
| 13 | + ---------- |
| 14 | + year_start : int |
| 15 | + the lower bound of the range of years selected by user |
| 16 | + year_end : int |
| 17 | + the upper bound of the range of years selected by user |
| 18 | + countries : list |
| 19 | + the list of countries to filter as selected by the user |
| 20 | + |
| 21 | + Returns |
| 22 | + ------- |
| 23 | + LayerChart: |
| 24 | + a world map plot with countries colored by no. of tsunami |
| 25 | + hits and with origin points |
| 26 | + """ |
9 | 27 |
|
10 | 28 | world_map = alt.topo_feature(data.world_110m.url, 'countries') |
11 | 29 | counts, tsunami_events = preprocess_data(year_start, year_end, countries) |
@@ -53,6 +71,24 @@ def create_map_plot(year_start, year_end, countries): |
53 | 71 | return (map + tsunami_spots).to_html() |
54 | 72 |
|
55 | 73 | def preprocess_data(year_start, year_end, countries): |
| 74 | + """Reads and preprocesses the data for the map plot. |
| 75 | +
|
| 76 | + Parameters |
| 77 | + ---------- |
| 78 | + year_start : int |
| 79 | + the lower bound of the range of years selected by user |
| 80 | + year_end : int |
| 81 | + the upper bound of the range of years selected by user |
| 82 | + countries : list |
| 83 | + the list of countries to filter as selected by the user |
| 84 | + |
| 85 | + Returns |
| 86 | + ------- |
| 87 | + counts: |
| 88 | + a dataframe which has the number of tsunami hits by countries |
| 89 | + tsunami_events: |
| 90 | + a dataframe of filtered tsunami events |
| 91 | + """ |
56 | 92 |
|
57 | 93 | tsunami_events = pd.read_csv(PROCESSED_DATA_PATH) |
58 | 94 | country_ids = pd.read_csv(COUNTRY_IDS_FILE_PATH, sep="\t") |
|
0 commit comments