Map of observations
This module provides rendering of observations on an interactive map, with a variety of tilesets available.
Note: OSM, ESRI, and CartoDB map tiles are served without authentication/tokens, and so render correctly on the huggingface deployment. The Stamen tiles render on localhost but require a token to present on a 3rd-party site.
create_map(tile_name, location, zoom_start=7)
Create a folium map with the specified tile layer
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tile_name
|
str
|
The name of the tile layer to use. Options include: 'Open Street Map', 'Esri Ocean', 'Esri Images', 'Stamen Toner', 'Stamen Watercolor', 'CartoDB Positron', 'CartoDB Dark_Matter'. |
required |
location
|
Tuple
|
Coordinates (lat, lon) of the map center, as floats. |
required |
zoom_start
|
int
|
The initial zoom level for the map. Default is 7. |
7
|
Returns:
Type | Description |
---|---|
Map
|
folium.Map: A folium Map object with the specified settings. |
Source code in src/obs_map.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
|
present_obs_map(dataset_id='Saving-Willy/Happywhale-kaggle', data_files='data/train-00000-of-00001.parquet', dbg_show_extra=False)
Render map plus tile selector, with markers for whale observations
This function loads whale observation data from a specified dataset and file, creates a pandas DataFrame compliant with Folium/Streamlit maps, and renders an interactive map with markers for each observation. The map allows users to select a tileset, and displays markers with species-specific colors.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset_id
|
str
|
The ID of the dataset to load from Hugging Face. Default is "Saving-Willy/Happywhale-kaggle". |
'Saving-Willy/Happywhale-kaggle'
|
data_files
|
str
|
The path to the data file to load. Default is "data/train-00000-of-00001.parquet". |
'data/train-00000-of-00001.parquet'
|
dbg_show_extra
|
bool
|
If True, add a few extra sample markers for visualization. Default is False. |
False
|
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
Selected data from the Folium/leaflet.js interactions in the browser. |
Source code in src/obs_map.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
|