Files changed (2) hide show
  1. app.py +20 -5
  2. requirements.txt +17 -0
app.py CHANGED
@@ -8,8 +8,6 @@ import scipy.spatial as sp
8
  import streamlit as st
9
  import folium
10
  from streamlit.components.v1 import html
11
-
12
-
13
  from haversine import haversine, Unit
14
 
15
 
@@ -228,6 +226,10 @@ def search_geonames(toponym, df):
228
 
229
  lat=[]
230
  lon=[]
 
 
 
 
231
 
232
  if 'geonames' in data:
233
  for place_info in data['geonames']:
@@ -236,6 +238,11 @@ def search_geonames(toponym, df):
236
 
237
  lat.append(latitude)
238
  lon.append(longitude)
 
 
 
 
 
239
 
240
  print(latitude)
241
  print(longitude)
@@ -261,6 +268,11 @@ def search_geonames(toponym, df):
261
 
262
  df['lat'] = lat
263
  df['lon'] = lon
 
 
 
 
 
264
  result = torch.cat(result, dim=1).detach().numpy()
265
  return result
266
 
@@ -275,6 +287,7 @@ def get50Neigbors(locationID, dataset, k=50):
275
 
276
  lat, lon, geohash,name = input_row['Latitude'], input_row['Longitude'], input_row['Geohash'], input_row['Name']
277
 
 
278
  filtered_dataset = dataset.loc[dataset['Geohash'].str.startswith(geohash[:7])].copy()
279
 
280
  filtered_dataset['distance'] = filtered_dataset.apply(
@@ -414,17 +427,20 @@ def showing(df):
414
  size_scale = 100
415
  color_scale = 255
416
  for i in range(len(df)):
417
- lat, lon, prob = df.iloc[i]['lat'], df.iloc[i]['lon'], df.iloc[i]['prob']
418
 
419
  size = int(prob**2 * size_scale )
420
  color = int(prob**2 * color_scale)
 
 
421
 
422
  folium.CircleMarker(
423
  location=[lat, lon],
424
  radius=size,
425
  color=f'#{color:02X}0000',
426
  fill=True,
427
- fill_color=f'#{color:02X}0000'
 
428
  ).add_to(m)
429
 
430
  m.save("map.html")
@@ -486,7 +502,6 @@ def mapping(selected_place,locations, sentence_info):
486
  def show_on_map():
487
 
488
 
489
-
490
  input = st.text_area("Enter a sentence:", height=200)
491
 
492
  st.button("Submit")
 
8
  import streamlit as st
9
  import folium
10
  from streamlit.components.v1 import html
 
 
11
  from haversine import haversine, Unit
12
 
13
 
 
226
 
227
  lat=[]
228
  lon=[]
229
+ name=[]
230
+ country=[]
231
+ fcodeName=[]
232
+ population=[]
233
 
234
  if 'geonames' in data:
235
  for place_info in data['geonames']:
 
238
 
239
  lat.append(latitude)
240
  lon.append(longitude)
241
+ name.append(place_info.get('name', ''))
242
+ country.append(place_info.get('countryName', ''))
243
+ fcodeName.append(place_info.get('fcodeName', ''))
244
+ population.append(place_info.get('population', ''))
245
+
246
 
247
  print(latitude)
248
  print(longitude)
 
268
 
269
  df['lat'] = lat
270
  df['lon'] = lon
271
+ df['name']=name
272
+ df['country']=country
273
+ df['fcodeName']=fcodeName
274
+ df['population']=population
275
+
276
  result = torch.cat(result, dim=1).detach().numpy()
277
  return result
278
 
 
287
 
288
  lat, lon, geohash,name = input_row['Latitude'], input_row['Longitude'], input_row['Geohash'], input_row['Name']
289
 
290
+
291
  filtered_dataset = dataset.loc[dataset['Geohash'].str.startswith(geohash[:7])].copy()
292
 
293
  filtered_dataset['distance'] = filtered_dataset.apply(
 
427
  size_scale = 100
428
  color_scale = 255
429
  for i in range(len(df)):
430
+ lat, lon, prob, name, country,fcodeName,population = df.iloc[i]['lat'], df.iloc[i]['lon'], df.iloc[i]['prob'],df.iloc[i]['name'],df.iloc[i]['country'],df.iloc[i]['fcodeName'],df.iloc[i]['population']
431
 
432
  size = int(prob**2 * size_scale )
433
  color = int(prob**2 * color_scale)
434
+
435
+ popup_info= f"<strong>Name:</strong>{name} <br/><strong>Country:</strong> {country}<br/> <strong>fcodeName:</strong> {fcodeName} <br/><strong>population:</strong>{population}"
436
 
437
  folium.CircleMarker(
438
  location=[lat, lon],
439
  radius=size,
440
  color=f'#{color:02X}0000',
441
  fill=True,
442
+ fill_color=f'#{color:02X}0000',
443
+ popup=popup_info
444
  ).add_to(m)
445
 
446
  m.save("map.html")
 
502
  def show_on_map():
503
 
504
 
 
505
  input = st.text_area("Enter a sentence:", height=200)
506
 
507
  st.button("Submit")
requirements.txt ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ streamlit==0.89.0
2
+ torch==2.1.0
3
+ transformers @ git+https://github.com/zekun-li/transformers@geolm
4
+ scipy
5
+ rank_bm25
6
+ scikit-image
7
+ geopandas
8
+ pandas
9
+ numpy
10
+ requests==2.26.0
11
+ folium
12
+ rasterio
13
+ streamlit_folium
14
+ opencv-python
15
+ torchvision
16
+ matplotlib
17
+ haversine