Try drawing a map with Python's folium package

There were few Japanese documents about folium, so I tried to summarize the basic usage. (The text is for folium-0.2.1)

What is folium

A package that makes it possible to use a library called Leaflet.js that can create interactive maps from python.

Installation

pip install pandas
pip install folium

Easy usage of folium (leaflet)

  1. Create a map with folium.Map
  2. Generate an object to be displayed in Liz with folium.Marker etc.
  3. Place the object with Map.add_children
  4. Output the map with Map.save

Example of simple mapping

# -*- coding:utf-8 -*-
#Sample when using folium with python

import folium

#Set Akashi City, Hyogo Prefecture as a map standard
japan_location = [35, 135]

#Create a map by specifying the reference point and the initial magnification
map = folium.Map(location=japan_location, zoom_start=5)

#Place a marker at the reference point s
marker = folium.Marker(japan_location, popup='Akashi')
map.add_children(marker)

#Output map in html format
map.save(outfile="map.html")

A map like this will be created スクリーンショット 2016-09-11 22.43.29.png

Remarks

-When creating a map with folium.Map, you can specify map tiles with tiles.

# -*- coding:utf-8 -*-
#Sample of map tile specification
import folium

#Set Akashi City, Hyogo Prefecture as a map standard
japan_location = [35, 135]

#Create a map with map tiles as Stamen Terrian
map = folium.Map(location=japan_location, zoom_start=5, tiles="Stamen Terrain")

#Output map in html format
map.save(outfile="stamen_terrain_map.html")

・ As an object to be installed on the map  CircleMarker, ClickForMarker, RegularPolygonMarker Etc. are available by default.

in conclusion

It is recommended because you can easily make a map that can be moved. Please use it.

reference

https://pypi.python.org/pypi/folium http://www.hexacosa.net/blog/detail/147/ http://sinhrks.hatenablog.com/entry/2015/12/26/231000

Recommended Posts

Try drawing a map with Python's folium package
Try drawing a map with python + cartopy 0.18.0
Try drawing a normal distribution with matplotlib
Folium: Visualize data on a map with Python
Try to dynamically create a Checkbutton with Python's Tkinter
Try programming with a shell!
Try using folium with anaconda
Try mining Bitcoin with Python's hashlib
Try using Python's networkx with AtCoder
Easily draw a map with matplotlib.basemap
How to add a package with PyCharm
[Python] Drawing a swirl pattern with turtle
Try using the camera with Python's OpenCV
Map rent information on a map with python
Make a drawing quiz with kivy + PyTorch
Draw a graph with PyQtGraph Part 1-Drawing
Try TensorFlow RNN with a basic model
Try to implement a binary dict-like internal emulation of Python's standard map type
Location information data display in Python --Try plotting with the map display library (folium)-
Try Tensorflow with a GPU instance on AWS
Try to draw a life curve with python
Try sending a message with Twilio's SMS service
Try to make a "cryptanalysis" cipher with Python
Try to make a dihedral group with Python
Try creating a FizzBuzz problem with a shell program
Visualize grib2 on a map with python (matplotlib)
Try making a simple website with responder and sqlite3
Try drawing a social graph using Twitter API v2
I like Python's comprehension, so I compared it with map
Try embedding Python in a C ++ program with pybind11
[GCP] Try a sample to authenticate users with Firebase
Drawing a tree structure with D3.js in Jupyter Notebook
A sample to try Factorization Machines quickly with fastFM