Python Folium Library
Folium is a Python Library that allow us to visualize spatial data (geographical data) in an interactive manner (you can drag, zoom, click on the map ).Manipulate your data in Python, then visualize it in on a Leaflet map via folium.
Geographical Data: All kinds of data that contain geographical (latitude, longitude, altitude, shape) as part of its feature. (Maps!).
Note that to see the position of any place (place in city, city, district, state, country etc…) on the map, we need latitude and longitude.
Installation of folium
Installation is same as other libraries in python
$ pip install folium
How do you use(Install) Folium in Jupyter Notebook or Anaconda?
$ conda install folium -c conda-forge
What are tile styles of Folium maps?
Before getting started let’s understand what is tiles and zooming in map
Tiles are 256x256 pixels. At the outer most zoom level, 0, the entire world can be rendered in a single map tile (consider world map as one tile).Each zoom level doubles in both dimensions, so a single tile is replaced by 4 tiles when zooming in.
This means that about 22 zoom levels are sufficient for most practical purposes. (You can also see it by doing it on Google map, try it just open your google map start with maximum zoom and see the map after 22 zooms.)
Most tiled web maps follow certain Google Maps conventions.
For clarification see the image below where you can see that how tiles and zooms work in a map.
To create a basic map, simply pass your starting coordinates (longitude and latitude) to Folium map function.
#Creating simple map
#saving a map in folium (create a html page)
Note : We have not done much here, just pass the position/location (longitude and latitude) in the folium map function and we got our map. We can save the map in Folium. The map will be saved in the form of html file (that you can use later).
Markers and Popup
There are numerous marker types (see the google map), start with simple style location marker with popup.
#creating a simple marker
folium.Marker([28.609140,77.234138], popup=’India Gate’, tooltip=”click me for more”).add_to(marker)
Note: As you can see from the output we have created a simple marker on location of India gate Delhi with popup message ‘India Gate’.
Plotting Geojson/ json and Topojson file on map
TopoJSON: An extension of GeoJSON is TopoJSON that is smaller in size and encodes geospatial topology.
Here we used Indian states json file to define the state boundaries and multiple layers can be visualized on the same map. Link of Indian states Geo json file ( click here ).used here.
#plotting Geojson data on map
Note: Here we just Indian state Geojson file to define Indian state boundaries.
Note: I am sure you must have learned something new in this article. Click here to see the full version of this article.
Thank You for reading !
Folium - Folium 0.11.0 documentation
builds on the data wrangling strengths of the Python ecosystem and the mapping strengths of the library. Manipulate…
Folium Library in Python (Interactive Maps in Python)
Folium is a Python Library that allow us to visualize spatial data (geographical data) in an interactive manner (you…
Latitude and Longitude Finder
Just like every actual house has its address (which includes the number, the name of the street, city, etc), every…