fromcarlostocosta commited on
Commit
ed140c5
1 Parent(s): 93dbbce

Initial commit

Browse files
Files changed (2) hide show
  1. app.py +96 -0
  2. requirements.txt +5 -0
app.py ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import random
4
+ import plotly.express as px
5
+ from geopy.distance import geodesic
6
+
7
+ # Define the DMO names
8
+ dmo_names = ["DMO" + str(i) for i in range(1, 31)]
9
+
10
+ # Dictionary of large European cities with their coordinates
11
+ cities = {
12
+ "London": (51.5074, -0.1278),
13
+ "Paris": (48.8566, 2.3522),
14
+ "Berlin": (52.5200, 13.4050),
15
+ "Madrid": (40.4168, -3.7038),
16
+ "Rome": (41.9028, 12.4964),
17
+ "Vienna": (48.2082, 16.3738),
18
+ "Amsterdam": (52.3667, 4.8945),
19
+ "Athens": (37.9838, 23.7275),
20
+ "Stockholm": (59.3293, 18.0686),
21
+ "Brussels": (50.8503, 4.3517),
22
+ "Helsinki": (60.1699, 24.9384),
23
+ "Warsaw": (52.2297, 21.0122),
24
+ "Copenhagen": (55.6761, 12.5683),
25
+ "Lisbon": (38.7223, -9.1393),
26
+ "Dublin": (53.3498, -6.2603),
27
+ "Budapest": (47.4979, 19.0402),
28
+ "Prague": (50.0755, 14.4378),
29
+ "Sofia": (42.6977, 23.3219),
30
+ "Bucharest": (44.4396, 26.0963),
31
+ "Luxembourg": (49.6116, 6.1319),
32
+ "Riga": (56.9496, 24.1052),
33
+ "Valletta": (35.8989, 14.5146),
34
+ "Vilnius": (54.6872, 25.2797),
35
+ "Bratislava": (48.1486, 17.1077),
36
+ "Ljubljana": (46.0569, 14.5058),
37
+ "Nicosia": (35.1856, 33.3823),
38
+ "Tallinn": (59.4370, 24.7536),
39
+ "Zagreb": (45.8150, 15.9819),
40
+ "Nicosia": (35.1856, 33.3823),
41
+ "Valletta": (35.8989, 14.5146)
42
+ }
43
+
44
+ # Coordinates of beach and mountain areas
45
+ beach_coordinates = (45.0, 10.0) # Example beach coordinates
46
+ mountain_coordinates = (48.0, 10.0) # Example mountain coordinates
47
+
48
+ # Function to determine the area based on proximity to beach or mountain
49
+ def determine_area(latitude, longitude):
50
+ city_coordinates = (latitude, longitude)
51
+ beach_distance = geodesic(city_coordinates, beach_coordinates).km
52
+ mountain_distance = geodesic(city_coordinates, mountain_coordinates).km
53
+
54
+ if beach_distance <= 200:
55
+ return "Beach"
56
+ elif mountain_distance <= 200:
57
+ return "Mountain"
58
+ else:
59
+ return "City"
60
+
61
+ # Create an empty DataFrame
62
+ df = pd.DataFrame(columns=["DMO", "City", "Latitude", "Longitude", "Area", "Environmental", "Cultural",
63
+ "Community", "Socio-economic", "Infrastructure", "Stakeholder",
64
+ "Visitor_education", "Monitoring"])
65
+
66
+ # Populate the DataFrame
67
+ for i in range(30):
68
+ dmo = dmo_names[i]
69
+ city = random.choice(list(cities.keys()))
70
+ latitude, longitude = cities[city]
71
+ area = determine_area(latitude, longitude)
72
+ environmental = round(random.uniform(0, 10), 2)
73
+ cultural = round(random.uniform(0, 10), 2)
74
+ community = round(random.uniform(0, 10), 2)
75
+ socio_economic = round(random.uniform(0, 10), 2)
76
+ infrastructure = round(random.uniform(0, 10), 2)
77
+ stakeholder = round(random.uniform(0, 10), 2)
78
+ visitor_education = round(random.uniform(0, 10), 2)
79
+ monitoring = round(random.uniform(0, 10), 2)
80
+
81
+ df.loc[i] = [dmo, city, latitude, longitude, area, environmental, cultural, community,
82
+ socio_economic, infrastructure, stakeholder, visitor_education, monitoring]
83
+
84
+ df.loc[df['DMO'].isin(['DMO14', 'DMO19', 'DMO27', 'DMO15', 'DMO20', 'DMO21']), 'Area'] = 'Beach'
85
+ df.loc[df['DMO'].isin(['DMO4', 'DMO23', 'DMO8']), 'Area'] = 'Mountain'
86
+
87
+ fig = px.scatter_mapbox(df, lat="Latitude", lon="Longitude", hover_name="DMO", hover_data=["Environmental", "Cultural",
88
+ "Community", "Socio-economic",
89
+ "Infrastructure", "Stakeholder",
90
+ "Visitor_education", "Monitoring"],
91
+ color="Area", color_discrete_sequence=["blue", "green", "red"], zoom=3)
92
+
93
+ fig.update_layout(mapbox_style="open-street-map")
94
+ fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
95
+
96
+ st.plotly_chart(fig, use_container_width=True)
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ geopy
2
+ joblib
3
+ pandas
4
+ plotly
5
+ scikit-learn==1.0.2