Wednesday, May 18, 2016

Web-Based Mapping with Python

Python programming language has been vastly utilized in different aspects of Geographic Information System (GIS) including web-based GIS aka web or internet mapping.

In this article, I will demonstrate how to use a python web mapping library called Folium to visualize the map of ABU Zaria Samaru Campus, in Kaduna state Nigerian (coordinate location=[11.15246, 7.65322]). So go and get the coordinate of the your place of interest if you don't want display the above location.

Note: other notable python web mapping libraries sort by descending level of simplicity includes:–

GeoDjango: To manage data in a dynamic web site
FeatureServer: More server side oriented but an OpenLayers demo
MapFish: Based on now outdated Pylons
Papyrus: the Mapfish integration in Pyramid, a well-known Python framework
GeoPandas: Based on Pandas data visualization library



Folium is an awesome python library that makes it easy to visualize data that has been manipulated in python on an interactive web map using the leaflet javascript library.

Folium = Python + LeafLetJS


Installation

Download Folium at: https://github.com/python-visualization/folium

Then from the extracted folder, run “python setup.py install” on the command line. Or better still run “pip install folium” from the command line.


Displaying a map of ABU Zaria Samaru Campus

To create this base map, we simply pass our starting coordinates [11.15246, 7.65322] to Folium. The code below will create a html file "abu_map.html" containing the map at size 400 by 500.

import folium

# Creates the map Object
map_abu = folium.Map( location=[11.15246, 7.65322], width=400, height=500, zoom_start=13 )

# Creates HTML file for the Map
map_abu.save('abu_map.html')

Read the Folium Getting Started for more.

That is it.
Thanks for reading.

No comments:

Post a Comment