-
Notifications
You must be signed in to change notification settings - Fork 3
/
app.py
50 lines (41 loc) · 1.33 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import pandas as pd
import json
import plotly.graph_objects as go
import plotly.express as px
import numpy as np
px.set_mapbox_access_token("pk.eyJ1IjoiZXZhbmRpZXdhbGQiLCJhIjoiY2t5ZDNxZGduMDJnYTJzcDZjbTc0a2k4ZSJ9.40GKtHZlbadpxGMRJD6JBQ")
df = pd.read_csv("static/geojson/oh-trails.csv")
with open("static/geojson/oh-trails.json", "r") as f:
geo = json.load(f)
for g in geo["features"]:
g["id"] = g["properties"]["ObjectID"]
paths = []
for g in geo["features"][:1000]:
if g["geometry"]["type"] == "MultiLineString":
for line in g["geometry"]["coordinates"]:
paths.append({"lat": np.array(line)[:,1],
"lon": np.array(line)[:,0]})
else:
paths.append({"lat": np.array(g["geometry"]["coordinates"])[:, 1],
"lon": np.array(g["geometry"]["coordinates"])[:, 0]})
fig = go.Figure(
data=[
go.Scattermapbox(
lat=p["lat"],
lon=p["lon"],
mode="lines",
line=dict(width=8)
)
for p in paths
]
)
fig.update_layout(
margin={"r":0,"t":0,"l":0,"b":0},
mapbox=go.layout.Mapbox(
style="outdoors",
zoom=6,
),
mapbox_accesstoken="pk.eyJ1IjoiZXZhbmRpZXdhbGQiLCJhIjoiY2t5ZDNxZGduMDJnYTJzcDZjbTc0a2k4ZSJ9.40GKtHZlbadpxGMRJD6JBQ"
)
fig.update_layout(showlegend=False)
fig.show()