File tree 4 files changed +33
-15
lines changed
4 files changed +33
-15
lines changed Original file line number Diff line number Diff line change @@ -5,12 +5,12 @@ Prototype data dashboard for analyzing telemetry data.
5
5
## How it works
6
6
7
7
For full dashboard functionality, upload a CSV or XLS file with the following columns:
8
- - ` lat ` * : Latitude at which image was taken or specimen was collected.
9
- - ` lon ` * : Longitude at which image was taken or specimen was collected.
8
+ - ` lat ` * : Latitude at which image was taken or specimen was collected: number in [ -90,90 ] .
9
+ - ` lon ` * : Longitude at which image was taken or specimen was collected: number in [ -180,180 ] .
10
10
11
11
12
12
*** Note:**
13
- - ` lat ` and ` lon ` columns are not required to utilize the dashboard, but there will be no map view if they are not included .
13
+ - Blank (or null) entries are recorded as ` unknown ` , and thus excluded from map view.
14
14
15
15
## Running Dashboard
16
16
Original file line number Diff line number Diff line change 15
15
{'label' : 'Descending' , 'value' : 'sum descending' }]
16
16
17
17
DOCS_URL = "https://github.com/Imageomics/telemetry-dashboard/tree/dev#how-it-works"
18
+ DOCS_LINK = html .A ("documentation" ,
19
+ href = DOCS_URL ,
20
+ target = '_blank' ,
21
+ style = ERROR_STYLE )
18
22
19
23
def get_hist_div (cat_list ):
20
24
'''
@@ -212,20 +216,24 @@ def get_error_div(error_dict):
212
216
html .H3 ("Source data does not have '" + feature + "' column. " ,
213
217
style = ERROR_STYLE ),
214
218
html .H4 (["Please see the " ,
215
- html .A ("documentation" ,
216
- href = DOCS_URL ,
217
- target = '_blank' ,
218
- style = ERROR_STYLE ),
219
+ DOCS_LINK ,
219
220
" for list of required columns." ],
220
221
style = ERROR_STYLE )
221
222
])
223
+ elif 'mapping' in error_dict .keys ():
224
+ error_msg = error_dict ['mapping' ]
225
+ error_div = html .Div ([
226
+ html .H4 ("Latitude or longitude columns have non-numeric values: " + error_msg + "." ,
227
+ style = ERROR_STYLE ),
228
+ html .H4 (["Please see the " ,
229
+ DOCS_LINK ,
230
+ "." ],
231
+ style = ERROR_STYLE )
232
+ ])
222
233
elif 'type' in error_dict .keys ():
223
234
error_div = html .Div ([
224
235
html .H4 (["The source file is not a valid CSV format, please see the " ,
225
- html .A ("documentation" ,
226
- href = DOCS_URL ,
227
- target = '_blank' ,
228
- style = ERROR_STYLE ),
236
+ DOCS_LINK ,
229
237
"." ],
230
238
style = ERROR_STYLE )
231
239
])
Original file line number Diff line number Diff line change @@ -99,10 +99,9 @@ def get_points_in_radius(df, radius):
99
99
min_lon = lon - rad_deg
100
100
max_lon = lon + rad_deg
101
101
102
- filtered_df = filtered_df .loc [filtered_df ['lat' ].astype (float ) > min_lat ]
103
- filtered_df = filtered_df .loc [filtered_df ['lat' ].astype (float ) < max_lat ]
104
- filtered_df = filtered_df .loc [filtered_df ['lon' ].astype (float ) > min_lon ]
105
- filtered_df = filtered_df .loc [filtered_df ['lon' ].astype (float ) < max_lon ]
102
+ filtered_df = filtered_df .loc [filtered_df ['lat' ].astype (float ).between (min_lat , max_lat )]
103
+ filtered_df = filtered_df .loc [filtered_df ['lon' ].astype (float ).between (min_lon , max_lon )]
104
+
106
105
num_samples = len (filtered_df )
107
106
108
107
pts_per_lat_lon .append (num_samples )
Original file line number Diff line number Diff line change @@ -84,6 +84,17 @@ def parse_contents(contents, filename):
84
84
else :
85
85
included_features = list (df .columns )
86
86
87
+ # Check for lat/lon bounds & type
88
+ try :
89
+ # Check lat and lon within appropriate ranges (lat: [-90, 90], lon: [-180, 180])
90
+ valid_lat = df ['lat' ].astype (float ).between (- 90 , 90 )
91
+ df .loc [~ valid_lat , 'lat' ] = 'unknown'
92
+ valid_lon = df ['lon' ].astype (float ).between (- 180 , 180 )
93
+ df .loc [~ valid_lon , 'lon' ] = 'unknown'
94
+ except ValueError as e :
95
+ print (e )
96
+ return json .dumps ({'error' : {'mapping' : str (e )}})
97
+
87
98
# get dataset-determined static data:
88
99
# the dataframe and categorical features - processed for map view if mapping is True
89
100
# all possible species, subspecies
You can’t perform that action at this time.
0 commit comments