-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
36 lines (27 loc) · 978 Bytes
/
app.py
File metadata and controls
36 lines (27 loc) · 978 Bytes
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
from flask import Flask, render_template
import folium
import rasterio
app = Flask(__name__)
# Path to GeoTIFF file
GEO_TIFF_FILE = 'static/ltl_cayman_BROWSE.tif'
@app.route('/')
def index():
# Use Rasterio to read GeoTIFF file
with rasterio.open(GEO_TIFF_FILE) as src:
bounds = src.bounds # Get bounds of GeoTIFF file
# Calculate center of bounds for map
center = [(bounds.top + bounds.bottom) / 2, (bounds.left + bounds.right) / 2]
# Create a folium map centered on GeoTIFF
my_map = folium.Map(location=center, zoom_start=13)
# Add GeoTIFF file as a layer
folium.raster_layers.ImageOverlay(
image=GEO_TIFF_FILE,
bounds=[[bounds.bottom, bounds.left], [bounds.top, bounds.right]],
opacity=0.6,
interactive=True,
).add_to(my_map)
# Save map as an HTML file
my_map.save('templates/map.html')
return render_template('map.html')
if __name__ == '__main__':
app.run(debug=True)