This is my first story in medium. Everyday I work as an android developer at Kasir Pintar.
But one day, I was curious and idle about the data on this startup. Therefore I am trying now to ‘play’ with the data.
The thing that is very easy to do is to play EDA (exploratory data analysis) on that data. But here I will not provide an explanation of how to process the data (because this is confidential data)
Here I will provide information about visualizing the data on the map using FOLIUM in python
what is folium?
taken from this article https://blog.dominodatalab.com/creating-interactive-crime-maps-with-folium/
Folium is a powerful Python library that helps you create several types of Leaflet maps. The fact that the Folium results are interactive makes this library very useful for dashboard building. To get an idea, just zoom/click around on the next map to get an impression
well, that was fun right ! very attractive and colorful visualization
Now let’s begin
So this is very easy to set up the code for this visualization
first we need geo json file for the country ( I use Indonesia geo json map, thanks to https://github.com/rifani/geojson-political-indonesia for providing this sources )
after we get this geo json file we need to prepare our data. So this data is only contains 2 columns. First column is the name of the ‘city’ and second is ‘total users’ ( pandas format )
First we need to import the library
import folium
after that we need to call the geo json file
that’s my code in jupyter notebook
location = [-2 , 118] is latitute and longitute for region of Indonesia
You can change this for any location if you want
Then we need to set attributes on folium to initialize map
What is choropleth?
wikipedia :
A choropleth map (from Greek χῶρος “area/region” and πλῆθος “multitude”) is a thematic map in which areas are shaded or patterned in proportion to the measurement of the statistical variable being displayed on the map, such as population density or per-capita income.
let’s continue ~
At first I was confused to read the documentation of folium. Until it takes about 1 hour to get enlightenment (for searching the right geo json and understand the context). So this is the explanation for some attribute:
geo_data : is for geo json data that we just call before
data : is for ‘pandas’ data for our data
columns : contains two columns ( first is the key for bonding in geojson attribute, second is the values on the map )
key_on : is attribute on json that we use to bond with first columns
and the others is just same as the name
Then we need to add to our map model (which is the ‘m’ varible)
Now, for the final round ! We call the map
So easy, right ? now our visualization looks awesome and colorful
So this is the end for this first story, I hope I can share more about my experiences especially about data, thank you
If you have any question or feedback or just want to get in touch with me, just contact me through this linkedin