<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Adeoluwa Adeboye</title>
    <description>The latest articles on DEV Community by Adeoluwa Adeboye (@jugg097).</description>
    <link>https://dev.to/jugg097</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F365202%2F9adf392e-b65e-4445-b40b-ccfa0ec0827e.jpeg</url>
      <title>DEV Community: Adeoluwa Adeboye</title>
      <link>https://dev.to/jugg097</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jugg097"/>
    <language>en</language>
    <item>
      <title>DATA VISUALIZATION: CHOROPLETH INTERACTIVE MAP WITH PYTHON USING FOLIUM</title>
      <dc:creator>Adeoluwa Adeboye</dc:creator>
      <pubDate>Sun, 26 Apr 2020 00:30:39 +0000</pubDate>
      <link>https://dev.to/jugg097/data-visualization-choropleth-interactive-map-with-python-using-folium-3684</link>
      <guid>https://dev.to/jugg097/data-visualization-choropleth-interactive-map-with-python-using-folium-3684</guid>
      <description>&lt;h2&gt;
  
  
  WHAT IS A CHOROPLETH MAP
&lt;/h2&gt;

&lt;p&gt;A choropleth map is a map which uses differences in shading, colouring, or the placing of symbols within predefined areas to indicate the average values of a particular quantity in those areas (&lt;em&gt;from oxford dictionary&lt;/em&gt;) as seen in the image below:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F923bb1buhmea16qsiarf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F923bb1buhmea16qsiarf.png" alt="Choropleth map"&gt;&lt;/a&gt;&lt;br&gt;
In this article, I will try to walk you through the process of creating a choropleth map with python using the &lt;strong&gt;folium&lt;/strong&gt; package. Visualization with choropleth map helps to give insight to data and is visually attractive.&lt;br&gt;
I will divide the processes into four short steps which will be followed sequentially.&lt;/p&gt;

&lt;h2&gt;
  
  
  STEP 1: SOURCING FOR SHAPEFILE IN &lt;em&gt;.KML&lt;/em&gt; FORMAT
&lt;/h2&gt;

&lt;p&gt;Inorder to generate a map visualization with &lt;strong&gt;folium&lt;/strong&gt; we require a shapefile of the area of the world map we want to work with.&lt;br&gt;
In this article I will be creating a visualization of the Nigeria map area, so the need to source for a shapefile in &lt;strong&gt;.KML&lt;/strong&gt; format of the Nigeria map area having polygon coordinates of each state.&lt;br&gt;
There are a lot of sites out there that simply supply this resource for free, for this visualization I got my shape file from &lt;a href="https://www.igismap.com/download-nigeria-shapefile-free-administrative-boundary-state-city-map/" rel="noopener noreferrer"&gt;IGISMAP&lt;/a&gt;, they also offer shapefiles for other countries.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fcmc7jrhdiod50iq2h6yt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fcmc7jrhdiod50iq2h6yt.png" alt="Igismap Site"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  STEP 2: CONVERSION OF SHAPEFILE TO A GEOJSON
&lt;/h2&gt;

&lt;p&gt;Moving on from step 1, let us convert the &lt;strong&gt;.KML&lt;/strong&gt; file to a &lt;strong&gt;Geojson&lt;/strong&gt; file.&lt;br&gt;
I used an online cloud resource to convert my &lt;strong&gt;.KML&lt;/strong&gt; to a &lt;strong&gt;Geojson&lt;/strong&gt; file, the name of the online resource is &lt;a href="https://mygeodata.cloud/converter/kml-to-geojson" rel="noopener noreferrer"&gt;MYGEODATA&lt;/a&gt;.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fppwm98yyhokzhudwrnie.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fppwm98yyhokzhudwrnie.png" alt="Mygeodata Site"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  STEP 3: INTEGRATION OF OUR GEOJSON WITH THE DATA
&lt;/h2&gt;

&lt;p&gt;From this step forward we get hands on with some &lt;strong&gt;Python&lt;/strong&gt; codes.&lt;br&gt;
We start by installing Python &lt;strong&gt;Pandas&lt;/strong&gt; and &lt;strong&gt;GeoPandas&lt;/strong&gt; packages to help us integrate the data we need to visualize into the geojson file.&lt;br&gt;
In this article I am visualizing the COVID-19 confirmed cases distribution across the states of Nigeria using data gotten from the NCDC site (&lt;em&gt;note: data might not be up to date  by the time you are reading this publication&lt;/em&gt;).&lt;br&gt;
The Jupyter notebook containing the well commented code for this step can be found in my &lt;a href="https://github.com/JUGG097/folium-chloropleth-map/tree/master/Notebooks" rel="noopener noreferrer"&gt;GitHub Repo&lt;/a&gt;.&lt;br&gt;
Below is a screenshot of the final dataframe after integrating the &lt;strong&gt;COVID-19&lt;/strong&gt; data with the Geojson file using &lt;strong&gt;Pandas&lt;/strong&gt; and &lt;strong&gt;Geopandas&lt;/strong&gt;.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F035zzmxytnsmqguo8z6m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F035zzmxytnsmqguo8z6m.png" alt="Integrated DataFrame"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  STEP 4: GENERATION OF INTERACTIVE CHOROPLETH MAP WITH FOLIUM
&lt;/h2&gt;

&lt;p&gt;To the final step which is the visualization of the choropleth map with &lt;strong&gt;Folium&lt;/strong&gt;.&lt;br&gt;
We will be using the &lt;strong&gt;folium.Choropleth&lt;/strong&gt; module, so we need to install the Folium package for this using &lt;em&gt;conda install /pip install&lt;/em&gt;.&lt;br&gt;
The Jupyter notebook containing the well commented code for this step can be found in my &lt;a href="https://github.com/JUGG097/folium-chloropleth-map/tree/master/Notebooks" rel="noopener noreferrer"&gt;GitHub Repo&lt;/a&gt;.&lt;br&gt;
Below is a screenshot of our generated Choropleth interactive map.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F2j69uokluo8zexaqj3hr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F2j69uokluo8zexaqj3hr.png" alt="Generated Map"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  PARTING WORDS...
&lt;/h3&gt;

&lt;p&gt;Other forms of map visualization are possible using the &lt;strong&gt;Folium&lt;/strong&gt; package check out the &lt;a href="https://python-visualization.github.io/folium/modules.html" rel="noopener noreferrer"&gt;Folium documentation&lt;/a&gt; for more info on that.&lt;br&gt;
The generated map can be saved as an &lt;strong&gt;.html&lt;/strong&gt; file which can be embedded to a webpage.&lt;br&gt;
I hope you find this article helpful and insightful, if so kindly leave a star on my &lt;a href="https://github.com/JUGG097/folium-chloropleth-map" rel="noopener noreferrer"&gt;GitHub Repo&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>datascience</category>
      <category>python</category>
      <category>jupyter</category>
      <category>github</category>
    </item>
  </channel>
</rss>
