Geospatial histogram visualization using folium

Note: You need to have the ``folium`` package installed to run this notebook.

“Bagging” the munros into rectangular bins

A Munro (About this sound listen (help·info)) is a mountain in Scotland with a height over 3,000 feet (914 m). Munros are named after Sir Hugh Munro, 4th Baronet (1856–1919), who produced the first list of such hills, known as Munro’s Tables, in 1891… says Wikipedia, more in https://en.wikipedia.org/wiki/Munro.

Let’s show the possibility to plot histograms in the maps with the help of folium library.

[1]:
# Necessary import evil
import pandas as pd
import numpy as np
import physt
import physt.plotting
physt.plotting.set_default_backend("folium")
[2]:
# Read the data
import pandas as pd
munros = pd.read_csv("../physt/examples/munros.csv")
munros.head()
[2]:
name height long lat
0 Ben Nevis 1344.0 -5.003526 56.796834
1 Ben Macdui [Beinn Macduibh] 1309.0 -3.669100 57.070386
2 Braeriach 1296.0 -3.728581 57.078177
3 Cairn Toul 1291.0 -3.710790 57.054415
4 Sgor an Lochain Uaine 1258.0 -3.725797 57.058378
[3]:
# How many of them are there? Wikipedia says 282 (as of 2017)
munros.shape
[3]:
(282, 4)

How many munros are in each 10’ rectangle?

[4]:
hist = physt.h2(munros["lat"], munros["long"], "fixed_width", bin_width=1 / 6)
[5]:
map = hist.plot()
map
[5]:
Make this Notebook Trusted to load map: File -> Trust Notebook
[6]:
# Now, let's combine this information with positions of the 20 tallest
import folium
map = hist.plot()
for i, row in munros.iloc[:20].iterrows():
    marker = folium.Marker([row["lat"], row["long"]], popup="{0} ({1} m)".format(row["name"], row["height"]))
    marker.add_to(map)
map
[6]:
Make this Notebook Trusted to load map: File -> Trust Notebook