I would need some help! By now i used this short code to design a map with folium: pyton_folium_test.txt
The next step for me is to learn how to import positions like this from an excel file, but here i got stuck the last two days. I tried to do the import with pandas, xlrd and also OPENPYXL, but i dont fit to the end. Am i right here to find help for it? can someone help me with that?
Excel below will be an example file to import and the screenshot is how the result should look like. Eingabe_Python.xlsx
#Allgemeine Weltkarte
import pandas as pd
import geopandas
import matplotlib.pyplot as plt
##GPS-Daten und Werte
#Hüttensand-Quellen
q = pd.DataFrame(
{'City': ['Voestalpine Donawitz'],
'Amount': [150000],
'Latitude': [47.37831193777984],
'Longitude': [15.066798524137285]})
gq = geopandas.GeoDataFrame(
q, geometry=geopandas.points_from_xy(q.Longitude, q.Latitude))
print(gq.head())
#Hüttensand-Bedarf
b = pd.DataFrame(
{'City': ['Retznei-Zementwerk', 'Peggau-Zementwerk'],
'Amount': [ 98741, 78908],
'Latitude': [ 46.74156539750959, 47.22606763599665],
'Longitude': [ 15.574118966270278, 15.346740145512106]})
gb = geopandas.GeoDataFrame(
b, geometry=geopandas.points_from_xy(b.Longitude, b.Latitude))
print(gb.head())
#Plot Österreich Karte mit Punkten
world = geopandas.read_file(geopandas.datasets.get_path('naturalearth_lowres'))
ax = world[world.name == 'Germany'].plot(
color='white', edgecolor='black')
gq.plot(ax=ax, color='red', legend=True, legend_kwds={'label':'City'})
gb.plot(ax=ax, color='blue')
plt.show()
#Heatmap
import folium
from folium.plugins import HeatMap
max_amount = float(gb['Amount'].max() and gq['Amount'].max())
print('der maximale Wert ist:',max_amount)
hmap = folium.Map(location=[47.070714, 15.439504], zoom_start=8,control_scale=True )
hm_quellen = HeatMap( data=gq[['Latitude', 'Longitude','Amount']],
min_opacity=0.3,
max_val=max_amount,
gradient = {.3: 'yellow', .6: 'orange', 1: 'red'},
radius=20, blur=10,
max_zoom=5,
)
hmap.add_child(hm_quellen)
hm_bedarf = HeatMap( data=gb[['Latitude', 'Longitude','Amount']],
min_opacity=0.3,
max_val=max_amount,
gradient = {.3: 'turquoise', .6: 'blue', 1: 'grey'},
radius=20, blur=15,
max_zoom=1,
)
hmap.add_child(hm_bedarf)
#Markierungen
# Quellen
folium.Marker([47.37831193777984, 15.066798524137285],
popup=folium.Popup('integrierte Hüttenwerk - Donawitz',show=True)).add_to(hmap)
# Bedarf
folium.Marker([46.74156539750959, 15.574118966270278],
popup=folium.Popup('Zementwerk - Retznei',show=True)).add_to(hmap)
folium.Marker([47.22606763599665, 15.346740145512106],
popup=folium.Popup('Zementwerk - Peggau',show=True)).add_to(hmap)
#karte speichern
import os
hmap.save(os.path.join(r'C:\Users\stefa\Desktop\Bachelorarbeit\Daten_Python', 'zement_heatmap.html'))