<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Godwin Murithi on Medium]]></title>
        <description><![CDATA[Stories by Godwin Murithi on Medium]]></description>
        <link>https://medium.com/@g_murithi?source=rss-b80ab8b5155e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*iYVdCmPe4lxCpPeAx6LFLw.jpeg</url>
            <title>Stories by Godwin Murithi on Medium</title>
            <link>https://medium.com/@g_murithi?source=rss-b80ab8b5155e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 17:36:51 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@g_murithi/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[GeoPandas Tutorial - Part 2: Spatial Relationships]]></title>
            <link>https://python.plainenglish.io/geopandas-tutorial-geospatial-data-handling-and-visualization-part-2-0739233d1403?source=rss-b80ab8b5155e------2</link>
            <guid isPermaLink="false">https://medium.com/p/0739233d1403</guid>
            <category><![CDATA[geopandas]]></category>
            <category><![CDATA[gis]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Godwin Murithi]]></dc:creator>
            <pubDate>Tue, 31 Oct 2023 09:55:24 GMT</pubDate>
            <atom:updated>2023-11-01T02:14:07.787Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/509/1*ATlyfIaH36m4qfFyXNKS4Q.png" /><figcaption>Park Areas</figcaption></figure><h3>Spatial Relationships with GeoPandas</h3><p>Geospatial data analysis involves understanding the spatial relationships between datasets. GeoPandas utilizes the functionalities of pandas and shapely packages for various spatial operations. In this section, we’ll explore two primary methods of combining datasets: attribute joins and spatial joins.</p><h4>Attribute Joins</h4><p>Attribute joins enable the merging of two GeoDataFrames based on non-geometry variables, similar to regular joins in pandas. The standard method for attribute joins is using the <em>pandas.merge()</em> function. For a deeper dive into pandas joins, refer to pandas.</p><p>To illustrate, let’s consider enhancing our GeoDataFrame from <a href="https://medium.com/python-in-plain-english/geopandas-tutorial-geospatial-data-handling-and-visualization-0f02e9b23993">part 1</a> by incorporating the<a href="https://github.com/godwinmurithi/GeoPandas-Spatial-data-Data-Handling-and-Visualization/blob/main/Part%202/2023_pop.csv"> population data</a> for Barcelona in 2022.</p><pre>pop =pd.read_csv(&#39;/Part 2/2023_pop.csv&#39;)<br>pop</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/1*CBTOlYD0nRt3LJuIB9J-iA.png" /><figcaption>Population data overview</figcaption></figure><p>To perform an attribute join between the district data and the population, we must ensure that the district name column in both datasets contains identical values. In the districts dataset, the districts are currently represented by their respective codes. To align them with the population dataset, we’ll convert these codes to district names. After this transformation, we can proceed with the merge operation based on the shared district name column.</p><p>First, read the district data then renameDISTRCTE column to district_name</p><pre>districts = gpd.read_file(&quot;/GeoPandas-Spatial-data-Data-Handling-and-Visualization/Part 1/districtes.geojson&quot;)<br><br>#the following code views the district code<br>districts.DISTRICTE</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/625/1*vAMvyQHsrOSIg5EuMAnUSg.png" /><figcaption>District Codes</figcaption></figure><p>Next, we rename the DISTRICTE Column to district_name, and, map district names to the district code using a dictionary.</p><pre>districts.rename(columns={&#39;DISTRICTE&#39;: &#39;district_name&#39;}, inplace=True)<br>districts.district_name</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/625/1*iIwt6c2qUwIG47k-6ovUgA.png" /><figcaption>The DISTRICT column has been renamed to district_name</figcaption></figure><p>Now, we create a dictionary with the district code as the key and district name as the value and use it to map names to the codes in our new column.</p><pre>#dictionary<br>district_mapping = {<br>    &#39;01&#39;: &#39;Old City&#39;,<br>    &#39;02&#39;: &#39;Eixample&#39;,<br>    &#39;03&#39;: &#39;Sants-Montjuïc&#39;,<br>    &#39;04&#39;: &#39;Les Corts&#39;,<br>    &#39;05&#39;: &#39;Sarrià-Sant Gervasi&#39;,<br>    &#39;06&#39;: &#39;Gràcia&#39;,<br>    &#39;07&#39;: &#39;Horta-Guinardó&#39;,<br>    &#39;08&#39;: &#39;Nou Barris&#39;,<br>    &#39;09&#39;: &#39;Sant Andreu&#39;,<br>    &#39;10&#39;: &#39;Sant Martí&#39;<br>}<br><br>#replacing the codes with the names<br>districts[&#39;district_name&#39;] = districts[&#39;district_name&#39;].replace(district_mapping)<br><br>#view if district names <br>districts.district_name</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/625/1*ftL0ogJwuKyoSBGOy3zFXg.png" /><figcaption>The names of the districts are on the district_name column</figcaption></figure><p>Now we can merge the district data and the population data.</p><pre>pop = pd.DataFrame(pop.groupby(&#39;Nom_Districte&#39;)[&#39;Valor&#39;].sum()).reset_index()<br>pop.columns=[&#39;district_name&#39;,&#39;population_22&#39;]<br>districts = districts.merge(pop)<br>districts</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yngAC27gEe-uFBQY6_E4uw.png" /><figcaption>Districts and Population merged dataset</figcaption></figure><h3>GeoPandas Overlay operations</h3><p>GeoPandas Overlay operations enable the comparison of two GeoDataFrames that contain polygon or multi-polygon geometries. The result is a new GeoDataFrame that incorporates the spatial combination of these geometries along with merged properties. This process allows for the analysis of relationships between geographic features. As an example, consider the scenario where the Barcelona City Council aims to establish new local parks to address pollution and enhance community well-being. One approach is to create expansive, circular parks within a 500-meter radius of each district’s center. This simulation involves generating a buffer around the centroid of each district to represent potential park locations.</p><pre>parks = gpd.GeoDataFrame(districts.centroid.buffer(500), geometry=0)<br><br>parks.plot()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*6wmUBiHjx_-gVO99x53Zaw.png" /><figcaption>Centroid Buffers</figcaption></figure><p>Now, let’s proceed with overlay operations. For instance, to visualize the specific regions within the districts where parks would be situated, we can employ the GeoPandas.overlay() method:</p><pre>parks_intersection = districts.overlay(parks, how=&#39;intersection&#39;)<br>ax = parks_intersection.plot(alpha=0.5, edgecolor=&#39;black&#39;, column=&#39;district_name&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*G5O8LWH1K6L8sheM7Xb-sg.png" /><figcaption>Parks Projected Areas</figcaption></figure><p>Alternatively, if our objective is to observe the districts excluding the regions occupied by the envisioned parks, we can achieve this by modifying the “how” parameter to execute a different overlay operation.</p><pre>parks_difference = districts.overlay(parks, how=&#39;difference&#39;)<br>ax = parks_difference.plot(alpha=0.5, edgecolor=&#39;black&#39;, column=&#39;district_name&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/509/1*ATlyfIaH36m4qfFyXNKS4Q.png" /><figcaption>Remaining district Area</figcaption></figure><p>I hope you enjoyed this GeoPandas tutorial. Spatial analysis is personally one of my favorite domains in data science, offering endless opportunities to enrich analyses with location-based information. If you appreciate my work, <a href="https://medium.com/@g_murithi">follow me</a> for more, or consider supporting it by <a href="https://www.buymeacoffee.com/godiewyn54r">buying me a coffee</a>. Happy Coding!</p><p>Resources for this tutorial</p><p>Codes and Data: <a href="https://github.com/godwinmurithi/GeoPandas-Spatial-data-Data-Handling-and-Visualization">https://github.com/godwinmurithi/GeoPandas-Spatial-data-Data-Handling-and-Visualization</a></p><h3>In Plain English</h3><p><em>Thank you for being a part of our community! Before you go:</em></p><ul><li><em>Be sure to </em><strong><em>clap</em></strong><em> and </em><strong><em>follow</em></strong><em> the writer! 👏</em></li><li><em>You can find even more content at </em><a href="https://plainenglish.io/"><strong><em>PlainEnglish.io</em></strong></a><strong><em> 🚀</em></strong></li><li><em>Sign up for our </em><a href="http://newsletter.plainenglish.io/"><strong><em>free weekly newsletter</em></strong></a><em>. 🗞️</em></li><li><em>Follow us: </em><a href="https://twitter.com/inPlainEngHQ"><strong><em>Twitter</em></strong></a><strong><em>(X</em></strong>), <a href="https://www.linkedin.com/company/inplainenglish/"><strong><em>LinkedIn</em></strong></a>, <a href="https://www.youtube.com/channel/UCtipWUghju290NWcn8jhyAw"><strong><em>YouTube</em></strong></a>, <a href="https://discord.gg/in-plain-english-709094664682340443"><strong><em>Discord</em></strong></a><strong><em>.</em></strong></li><li><em>Check out our other platforms: </em><a href="https://stackademic.com/"><strong><em>Stackademic</em></strong></a>, <a href="https://cofeed.app/"><strong><em>CoFeed</em></strong></a>, <a href="https://venturemagazine.net/"><strong><em>Venture</em></strong></a>.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0739233d1403" width="1" height="1" alt=""><hr><p><a href="https://python.plainenglish.io/geopandas-tutorial-geospatial-data-handling-and-visualization-part-2-0739233d1403">GeoPandas Tutorial - Part 2: Spatial Relationships</a> was originally published in <a href="https://python.plainenglish.io/">Python in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GeoPandas Tutorial — Part 1: Geospatial Data Handling and Visualization]]></title>
            <link>https://python.plainenglish.io/geopandas-tutorial-geospatial-data-handling-and-visualization-0f02e9b23993?source=rss-b80ab8b5155e------2</link>
            <guid isPermaLink="false">https://medium.com/p/0f02e9b23993</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[gis]]></category>
            <category><![CDATA[geopandas]]></category>
            <dc:creator><![CDATA[Godwin Murithi]]></dc:creator>
            <pubDate>Sat, 21 Oct 2023 10:54:12 GMT</pubDate>
            <atom:updated>2023-10-31T10:22:25.677Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*A3dQmQG8vaVc2fS9EKeLyQ.png" /><figcaption>A map of Barcelona Districts</figcaption></figure><p>Spatial data, encompassing Earth Observation, GPS, and mapping information, plays a significant role in our daily data landscape. Each data point in spatial datasets is associated with a specific location, enabling mapping on a coordinate reference system, like geographical coordinates.</p><p>This tutorial focuses on GeoPandas, a Python open-source package tailored for geospatial data science. Built on pandas and other popular Python data science tools like matplotlib, GeoPandas extends data manipulation capabilities to include spatial operations on geometric types. This seamless integration allows Python-savvy data professionals to effortlessly delve into GeoPandas syntax for spatial data exploration and analysis.</p><h3>Installing Python GeoPandas</h3><p>To harness the spatial capabilities of GeoPandas in Python, the initial step involves installation, much like any other Python library. It’s noteworthy that GeoPandas relies on a suite of open-source geospatial libraries — shapely, fiona, pyproj, and rtree — to unlock its full potential. Ensuring the installation of these dependencies is crucial for optimal GeoPandas performance.</p><p>To tap into GeoPandas’ spatial capabilities in Python, we begin by installing it along with key dependencies like shapely, fiona, pyproj, and rtree using the pip package manager. This straightforward approach ensures a hassle-free installation and sets the stage for seamless geospatial data exploration and analysis across various operating systems.</p><pre>pip install geopandas</pre><p>If you encounter any challenges during the GeoPandas installation process, refer to the documentation for detailed guidance.</p><p>After successfully installing the package, you’re ready to commence GeoPandas usage. Simply import it into your Python environment, commonly done using the alias ‘gpd’. This sets the stage for your geospatial data exploration and analysis endeavors.</p><pre>import geopandas as gpd</pre><h3>Reading and writing spatial data</h3><p>In this section, we delve into fundamental operations with GeoPandas, unveiling key concepts in geospatial analysis such as spatial data types, formats, and coordinate reference systems (CRS). Analogous to pandas transforming input data into dataframes, GeoPandas reads spatial data and transforms it into GeoDataFrames.</p><p>Spatial data comes in two main types: vector and raster. Vector data represents geographic features through discrete geometries — Points, Lines, and Polygons. On the other hand, raster data encodes the world as a continuous surface represented by a grid. Both types often accompany non-spatial attributes, such as the name or address of a location. GeoPandas is adept at working with vector data, seamlessly integrating with other Python packages like rasterio for raster data.</p><p>Now, to read spatial data, GeoPandas offers the powerful `geopandas.read_file()` function. This function automatically handles various vector-based spatial data formats. Common formats include Shapefiles, an industry-standard comprising shape geometry and attributes, and GeoJSON, a newer format released in 2016 known for its simplicity. Below is an example using GeoPandas to read a GeoJSON file containing geospatial data about Barcelona’s districts:</p><pre><br>import geopandas as gpd<br>districts = gpd.read_file(&quot;/GeoPandas-Spatial-data-Data-Handling-and-Visualization/Part 1/districtes.geojson&quot;)<br>districts</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/1*U8dwwvwwS_QTso76nlymxA.png" /><figcaption>District Attributes</figcaption></figure><p>This snippet fetches and reads a GeoJSON file from GitHub, creating a GeoDataFrame named `districts` for further geospatial exploration and analysis.</p><h3>Spatial Data Exploration</h3><p>GeoDataFrames, akin to traditional pandas data frames, offer a familiar structure, as GeoDataFrame is a subclass of pandas.DataFrame, inheriting methods, and attributes. A distinctive trait is the ability to store a geometry column (GeoSeries) for spatial operations. While a GeoDataFrame can have multiple GeoSeries, one column serves as the active geometry, the basis for spatial operations.</p><p>Each GeoSeries in a GeoDataFrame carries crucial Coordinate Reference System (CRS) information. CRS informs GeoPandas about the location of coordinates on Earth, crucial for accurate spatial analysis. There are two primary CRS categories: Geographic coordinates (e.g., EPSG:4326) in degrees, widely used in GPS, and Projected coordinates for two-dimensional maps, allowing convenient unit representation (e.g., meters).</p><p>In GeoPandas, CRS information is accessed through the `crs` attribute:</p><pre>districts.crs</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*ETC1yvg1U-a5N2e79fGMrw.png" /><figcaption>Coordinate reference system information</figcaption></figure><p>To facilitate analysis in meters, the GeoDataFrame can be transformed using the `to_crs()` method. For instance, converting to EPSG:2062, the standard projected CRS for Spain, is achieved with:</p><pre>districts.to_crs(epsg=2062, inplace=True)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/462/1*MdMUxk0rzmEFBQAl2Xk0aw.png" /><figcaption>Coordinate reference system change</figcaption></figure><p>This transformation aligns the GeoDataFrame for spatial calculations in meters. With the right projected CRS set, the GeoDataFrame is poised for further attribute exploration.</p><h3>Spatial Data Attributes Exploration</h3><p>GeoPandas inherits several valuable methods and attributes from the shapely package. Here, we’ll explore four key attributes:</p><h4>Area</h4><p>The `area` attribute calculates the area of a geometry. To add this area (converted to km²) to our dataset, we create a new column:</p><pre>districts[&#39;area&#39;] = districts.area / 1000000</pre><h4>Boundary</h4><p>The `boundary` attribute captures the boundary of a polygon. We incorporate this information into our dataset:</p><pre>districts[&#39;boundary&#39;] = districts.boundary</pre><h4>Distance</h4><p>Utilizing the `distance` method, we calculate the minimum distance from the famous Sagrada Familia church to the centroids of every district in Barcelona. The distances (in kilometers) are then stored in a new column:</p><pre>from shapely.geometry import Point<br>sagrada_fam = Point(2.1743680500855005, 41.403656946781304)<br> sagrada_fam = gpd.GeoSeries(sagrada_fam, crs=4326).to_crs(epsg=2062)<br> districts[&#39;sagrada_fam_dist&#39;] = [float(sagrada_fam.distance(centroid)) / 1000 for centroid in districts.centroid]</pre><pre>districts[[&#39;area&#39;, &#39;boundary&#39;, &#39;sagrada_fam_dist&#39;]]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/607/1*X6gt7Iinr70Ip69OkyKNcQ.png" /><figcaption>The area, distance, and boundary columns have been added to the attributes</figcaption></figure><p>These operations enrich the dataset, providing insights into the area, boundaries, and distances of the spatial features.</p><h3>Plotting with GeoPandas</h3><p>Visualizing your spatial data with GeoPandas enhances the insights gained from spatial operations. Creating a GeoPandas plot is effortlessly achieved by invoking the GeoDataFrame.plot() function, built on Python’s matplotlib package.</p><p>For a basic visualization of Barcelona districts:</p><pre>ax= districts.plot(figsize=(10,6))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/611/1*v4GXO8CqXZMSCUQgj8lavA.png" /><figcaption>Map of Barcelona Districts</figcaption></figure><p>To add more information, color each district and include a legend:</p><pre>ax= districts.plot(column=&#39;DISTRICTE&#39;, figsize=(10,6), edgecolor=&#39;black&#39;, legend=True)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/611/1*tqJRmyPpnu3N2t7JNljIMA.png" /><figcaption>Coloured map of the Districts</figcaption></figure><p>Finally, we can add the centroids of the districts and the Sagrada Familia to our map, as well as a title. Equally, to make the plot more compelling, we can use the nice contextily package to add a tile map of the actual city of Barcelona.</p><pre>ax= districts.plot(column=&#39;DISTRICTE&#39;, figsize=(10,6), alpha=0.5, edgecolor=&#39;black&#39;, legend=False)<br>contextily.add_basemap(ax, crs=districts.crs.to_string())</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*A3dQmQG8vaVc2fS9EKeLyQ.png" /><figcaption>Basemap, and the districts</figcaption></figure><p>Exciting, isn’t it? This is just the beginning, and there’s so much more you can explore to create stunning spatial visualizations. Stay tuned for our next blog, on advanced data handling and visualization techniques in GeoPandas where we’ll dive deeper and uncover advanced techniques to elevate your visualization skills to new heights.</p><p>The codes for this section can be found <a href="https://github.com/godwinmurithi/GeoPandas_Intro">here</a></p><p>I hope this guide inspires you to embark on your Python programming journey. If you appreciate my work, <a href="https://medium.com/@g_murithi">follow me</a> for more, or consider supporting it by <a href="https://www.buymeacoffee.com/godiewyn54r">buying me a coffee</a>. Happy Coding!</p><h3>In Plain English</h3><p><em>Thank you for being a part of our community! Before you go:</em></p><ul><li><em>Be sure to </em><strong><em>clap</em></strong><em> and </em><strong><em>follow</em></strong><em> the writer! 👏</em></li><li><em>You can find even more content at </em><a href="https://plainenglish.io/"><strong><em>PlainEnglish.io</em></strong></a><strong><em> 🚀</em></strong></li><li><em>Sign up for our </em><a href="http://newsletter.plainenglish.io/"><strong><em>free weekly newsletter</em></strong></a><em>. 🗞️</em></li><li><em>Follow us: </em><a href="https://twitter.com/inPlainEngHQ"><strong><em>Twitter</em></strong></a><strong><em>(X</em></strong>), <a href="https://www.linkedin.com/company/inplainenglish/"><strong><em>LinkedIn</em></strong></a>, <a href="https://www.youtube.com/channel/UCtipWUghju290NWcn8jhyAw"><strong><em>YouTube</em></strong></a>, <a href="https://discord.gg/in-plain-english-709094664682340443"><strong><em>Discord</em></strong></a><strong><em>.</em></strong></li><li><em>Check out our other platforms: </em><a href="https://stackademic.com/"><strong><em>Stackademic</em></strong></a>, <a href="https://cofeed.app/"><strong><em>CoFeed</em></strong></a>, <a href="https://venturemagazine.net/"><strong><em>Venture</em></strong></a>.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0f02e9b23993" width="1" height="1" alt=""><hr><p><a href="https://python.plainenglish.io/geopandas-tutorial-geospatial-data-handling-and-visualization-0f02e9b23993">GeoPandas Tutorial — Part 1: Geospatial Data Handling and Visualization</a> was originally published in <a href="https://python.plainenglish.io/">Python in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Crafting Compelling Interactive Maps with Python and Folium]]></title>
            <link>https://python.plainenglish.io/crafting-compelling-interactive-visualizations-with-python-and-folium-99a95d41219b?source=rss-b80ab8b5155e------2</link>
            <guid isPermaLink="false">https://medium.com/p/99a95d41219b</guid>
            <category><![CDATA[folium]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[gis]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Godwin Murithi]]></dc:creator>
            <pubDate>Mon, 16 Oct 2023 14:09:04 GMT</pubDate>
            <atom:updated>2024-04-09T12:25:01.965Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_YXubAjbN8JMseeggZyshg.png" /><figcaption>Web Map</figcaption></figure><p>Unlocking the power of data through engaging visualizations is a transformative skill. When it comes to geospatial data, interactive maps stand out as an effective means of conveying complex information. In this tutorial, we’ll delve into the creation of an interactive map using Python and the Folium library.</p><p>Our map will feature two layers: one showcasing volcano locations and elevations, and another revealing country population densities. This dynamic visualization allows readers to intuitively explore the spatial relationships between volcanoes and global human populations.</p><p>You can access the complete code on my <a href="https://github.com/godwinmurithi/Crafting-Compelling-Interactive-Maps-with-Python-and-Folium">GitHub repository</a>. Take a closer look at the interactive map, gain insights, fork it for your projects, and kickstart your journey.</p><p>Let’s begin by walking through the Python implementation using Folium and Pandas. This involves reading datasets, data preparation, configuring map parameters, adding layers and markers, and ultimately saving the visualization.</p><h3>Implementation</h3><p>We start by importing the necessary libraries:</p><pre>import folium<br>import pandas as pd</pre><p>Next, we read the raw data on volcano locations and population estimates:</p><pre>data = pd.read_csv(&#39;Volcanoes.txt&#39;)</pre><p>This yields a Pandas data frame containing latitude, longitude, and elevation information for over 1,500 volcanoes globally.</p><p>For country population data, we’ll use the GeoJSON file ‘world.json,’ a format well-suited for mapping libraries like Folium. We extract key columns from the volcano data frame:</p><pre>lat = list(data[&quot;LAT&quot;])<br>lon = list(data[&quot;LON&quot;])<br>ele = list(data[&quot;ELEV&quot;])</pre><p>Now, let’s define a function to color volcano markers based on elevation:</p><pre>def color_marker(elevation):<br>    if elevation &lt; 1000:<br>        return &#39;red&#39;<br>    elif 1000 &lt;= elevation &lt; 3000:<br>        return &#39;orange&#39;<br>    else:<br>        return &#39;green&#39;</pre><p>With data prepared, we create the base Folium map centered on North America:</p><pre>map = folium.Map(location=[38.58, -99.08], zoom_start=6, tiles=&#39;OpenStreetMap&#39;)</pre><p>We add two FeatureGroup layers for volcanoes and population data:</p><pre>f = folium.FeatureGroup(name=&quot;Volcanoes&quot;)<br>fg = folium.FeatureGroup(name=&quot;Population&quot;)</pre><p>Now, let’s populate these layers with markers and overlays. For volcanoes:</p><pre>for lt, ln, el in zip(lat, lon, ele):<br>    f.add_child(folium.CircleMarker(location=[lt, ln], radius=6, popup=str(el)+&quot; m&quot;,<br>    fill_color=color_marker(el), color=&#39;grey&#39;, fill=True, fill_opacity=0.7))</pre><p>For population data:</p><pre>fg.add_child(folium.GeoJson(data=open(&#39;world.json&#39;, &#39;r&#39;, encoding=&#39;utf-8-sig&#39;).read(), <br>    style_function=lambda x: {&#39;fillColor&#39;:&#39;green&#39; if x[&#39;properties&#39;][&#39;POP2005&#39;] &lt; 10000000 <br>     else &#39;orange&#39; if 10000000 &lt;= x[&#39;properties&#39;][&#39;POP2005&#39;] &lt; 20000000 else &#39;red&#39;}))</pre><p>Finally, we add the layers to the map with a layer control:</p><pre>map.add_child(f)<br>map.add_child(fg)  <br>map.add_child(folium.LayerControl())</pre><p>Save the finished map to an HTML file for local viewing:</p><pre>map.save(&quot;Population_Volcanoes.html&quot;)</pre><h4>Insights and Analysis</h4><p>The resulting visualization offers a global perspective on volcano locations, elevations, and nearby population densities. Key insights include:</p><ul><li>Concentration of volcanoes around tectonic plate boundaries, like the Pacific Ring of Fire.</li><li>High-elevation volcanoes along active continental boundaries.<br>Lower elevation intraplate hotspots, e.g., Hawaii and Yellowstone.</li><li>Volcanic risk in densely populated areas like Mexico, Colombia, and Indonesia.</li><li>Toggleable layers enable focused exploration of volcano patterns, while color schemes aid in visual queries.</li></ul><h4>Conclusion</h4><p>This tutorial showcased the versatility of Python and Folium for crafting impactful interactive maps. Beyond volcanoes, this approach can be extended for diverse applications, from real-time earthquake data to demographic information.</p><p>Python’s rich ecosystem, including libraries like Folium, GeoPandas, Descartes, and Contextily, empowers users to create tailored mapping solutions. Interactive maps, with their storytelling potential, provide valuable insights across various domains.</p><p>I hope this guide inspires you to embark on your Python programming journey. If you appreciate my work, consider supporting it by <a href="https://www.buymeacoffee.com/godiewyn54r">buying me a coffee.</a> Happy Coding!</p><h3>In Plain English</h3><p><em>Thank you for being a part of our community! Before you go:</em></p><ul><li><em>Be sure to </em><strong><em>clap</em></strong><em> and </em><strong><em>follow</em></strong><em> the writer! 👏</em></li><li><em>You can find even more content at </em><a href="https://plainenglish.io/"><strong><em>PlainEnglish.io</em></strong></a><strong><em> 🚀</em></strong></li><li><em>Sign up for our </em><a href="http://newsletter.plainenglish.io/"><strong><em>free weekly newsletter</em></strong></a><em>. 🗞️</em></li><li><em>Follow us on </em><a href="https://twitter.com/inPlainEngHQ"><strong><em>Twitter</em></strong></a><strong><em>(X</em></strong>), <a href="https://www.linkedin.com/company/inplainenglish/"><strong><em>LinkedIn</em></strong></a>, <a href="https://www.youtube.com/channel/UCtipWUghju290NWcn8jhyAw"><strong><em>YouTube</em></strong></a>, and <a href="https://discord.gg/in-plain-english-709094664682340443"><strong><em>Discord</em></strong></a><strong><em>.</em></strong></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=99a95d41219b" width="1" height="1" alt=""><hr><p><a href="https://python.plainenglish.io/crafting-compelling-interactive-visualizations-with-python-and-folium-99a95d41219b">Crafting Compelling Interactive Maps with Python and Folium</a> was originally published in <a href="https://python.plainenglish.io/">Python in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Folium]]></title>
            <link>https://medium.com/@g_murithi/folium-8e388dad7ed9?source=rss-b80ab8b5155e------2</link>
            <guid isPermaLink="false">https://medium.com/p/8e388dad7ed9</guid>
            <dc:creator><![CDATA[Godwin Murithi]]></dc:creator>
            <pubDate>Wed, 11 Oct 2023 09:44:29 GMT</pubDate>
            <atom:updated>2023-10-11T09:44:29.520Z</atom:updated>
            <content:encoded><![CDATA[<p>Folium, a Python library built around Leaflet.js, offers a streamlined approach to creating interactive maps. It simplifies the process of visualizing data with a geographic component, making it accessible to users with varying levels of programming expertise. Facilitating the creation of dynamic maps, Folium allows users to embed markers, popups, and tooltips to represent specific locations. It also supports overlays of GeoJSON data, making it versatile for displaying geographic features and boundaries. This ease of use extends to customization, enabling users to tailor the appearance of maps, markers, and other elements to suit their specific needs.</p><p>One of Folium’s notable strengths lies in its seamless integration with Jupyter Notebooks, making it a valuable tool for data scientists and researchers. The library’s high-level, declarative interface ensures a quick learning curve, allowing users to prototype and visualize geographic data efficiently. Moreover, Folium enhances the interactivity of maps, enabling users to pan, zoom, and manipulate visualizations directly in the browser. This flexibility extends to the creation of heatmaps and choropleth maps, empowering mappers to convey the intensity and distribution of data across geographical areas.</p><p>Mappers gravitate toward Folium for its ability to expedite the visualization process without the need for extensive web development knowledge. Whether used for rapid prototyping or seamlessly integrated into a data analysis workflow, Folium stands out as a versatile and user-friendly tool for creating engaging and informative interactive maps in Python. Its strength lies not only in its robust feature set but also in its capacity to democratize the creation of dynamic geographic visualizations.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8e388dad7ed9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mapping Libraries for Web GIS Development]]></title>
            <link>https://medium.com/@g_murithi/mapping-libraries-for-web-gis-development-961803a9fd15?source=rss-b80ab8b5155e------2</link>
            <guid isPermaLink="false">https://medium.com/p/961803a9fd15</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[mapping]]></category>
            <category><![CDATA[gis]]></category>
            <dc:creator><![CDATA[Godwin Murithi]]></dc:creator>
            <pubDate>Tue, 10 Oct 2023 08:37:04 GMT</pubDate>
            <atom:updated>2023-10-16T14:13:21.070Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sr1QLBdwnLQz5mHHopdu8Q.jpeg" /></figure><p>In the dynamic landscape of web GIS development, a comprehensive toolkit often involves a combination of various mapping libraries and geospatial tools. Among the notable players are Folium, GeoPandas, Leaflet.js, Mapbox GL JS, Google Maps JavaScript API, OpenLayers, and CesiumJS, each contributing distinct strengths to the developer’s arsenal.</p><p><strong>Folium:</strong> serves as a Pythonic interface to the Leaflet.js mapping library, offering simplicity and ease of use for interactive map creation. It excels in scenarios where quick data visualization on maps is essential, providing a seamless bridge between Python and Leaflet.js.</p><p><strong>GeoPandas: </strong>extends the capabilities of Pandas to spatial data, simplifying tasks related to the manipulation and analysis of geospatial datasets. It seamlessly integrates into Python workflows, allowing data scientists and developers to leverage the power of Pandas for spatial data tasks.</p><p><strong>Leaflet.js</strong>: is a lightweight, open-source JavaScript library that provides a simple yet powerful API for embedding interactive maps on web pages. Its versatility and ease of use make it an excellent choice for beginners and for projects requiring quick map implementation.</p><p><strong>Mapbox GL JS:</strong> is a robust library for creating customizable and interactive maps using vector tiles. Its support for dynamic styling and high-performance rendering makes it suitable for applications demanding advanced visualization and customization.</p><p><strong>The Google Maps JavaScript API</strong>: stands as a widely-used mapping library, offering comprehensive mapping functionalities, geocoding, and routing services. It is known for its extensive documentation and user-friendly integration, making it a popular choice for a broad range of applications.</p><p><strong>OpenLayers</strong>, an open-source mapping library, is designed for complex mapping applications, supporting various data formats and map projections. It provides fine-grained control over map rendering and behavior, making it suitable for projects with specific mapping requirements.</p><p><strong>CesiumJS</strong>: specializes in creating 3D globes and maps, offering advanced features like terrain rendering and time-dynamic data. It is particularly valuable for applications requiring a three-dimensional representation of geographic data.</p><p>This comprehensive combination of tools empowers developers to address a wide spectrum of web GIS challenges, from simple map visualizations with Folium to complex 3D representations with CesiumJS, all while seamlessly handling spatial data manipulation and analysis with GeoPandas.</p><p>I hope this guide inspires you to embark on your Python programming journey. If you appreciate my work, consider supporting it by <a href="https://www.buymeacoffee.com/godiewyn54r">buying me a coffee.</a> Happy Coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=961803a9fd15" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HydroSHEDS GIS Data For Water Management]]></title>
            <link>https://medium.com/@g_murithi/hydrosheds-gis-data-for-water-management-8be33574311d?source=rss-b80ab8b5155e------2</link>
            <guid isPermaLink="false">https://medium.com/p/8be33574311d</guid>
            <category><![CDATA[mapping]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[hydrosheds]]></category>
            <category><![CDATA[water]]></category>
            <category><![CDATA[gis]]></category>
            <dc:creator><![CDATA[Godwin Murithi]]></dc:creator>
            <pubDate>Fri, 21 Jul 2023 10:44:26 GMT</pubDate>
            <atom:updated>2023-07-21T10:44:26.636Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*E_h-MEso0LWmaQsPMNbURw.jpeg" /><figcaption>River Network</figcaption></figure><p><a href="https://www.hydrosheds.org/">HydroSHEDS</a> (Hydrological data and maps based on SHuttle Elevation Derivatives at multiple Scales) is a global hydrological dataset developed by the World Wildlife Fund (WWF) and the United States Geological Survey (USGS). It provides high-resolution information on river networks, watershed boundaries, and flow direction that can be used for various water management applications. HydroSHEDS data is freely available and widely used by researchers, policymakers, and practitioners in water resources management and environmental studies.</p><p>The key components of the HydroSHEDS dataset include:</p><p>1. <strong>River Network</strong>: HydroSHEDS provides information on the location and connectivity of rivers and streams at different scales. This data can be crucial for understanding the flow of water within a region and identifying the main river channels and their tributaries.</p><p>2. <strong>Watershed Boundaries</strong>: The dataset delineates watershed boundaries based on topographic information, enabling the identification of catchment areas for specific river segments. This is essential for managing water resources, as it helps in defining the areas that contribute to the flow of water in a given river.</p><p>3. <strong>Flow Direction</strong>: HydroSHEDS uses digital elevation models (DEMs) to determine the direction of water flow in the landscape. This information is vital for modeling hydrological processes and understanding how water moves through a region.</p><p>HydroSHEDS data is typically available in Geographic Information System (GIS) compatible formats like raster and vector data. You can access and download HydroSHEDS data from various sources, including the WWF website and the USGS EarthExplorer platform.</p><p>Applications of HydroSHEDS data in water management include:</p><p>- <strong>Water Resources Assessment</strong>: HydroSHEDS data can be used to assess the availability of water resources in a region, such as estimating streamflow, identifying potential water sources, and analyzing water availability over time.</p><p>- <strong>Floodplain Mapping</strong>: The dataset can assist in mapping flood-prone areas, which is vital for disaster management and land-use planning.</p><p>- <strong>Water Quality Modeling</strong>: HydroSHEDS data, combined with other environmental data, can be utilized to model water quality parameters, aiding in the assessment of pollution and potential impacts on aquatic ecosystems.</p><p>-<strong> Infrastructure Planning</strong>: When planning water-related infrastructure, such as dams, reservoirs, or irrigation systems, HydroSHEDS data can provide essential information on the river network and watershed characteristics.</p><p>- <strong>Biodiversity Conservation</strong>: Understanding river networks and watersheds is crucial for preserving aquatic biodiversity, as these habitats support a wide range of aquatic species.</p><p>It’s important to note that while <a href="https://www.hydrosheds.org/">HydroSHEDS </a>provides valuable information for water management, it may require further validation and integration with local data, especially for site-specific applications.</p><p>If you enjoyed this article and want to read more from me, make sure to <a href="https://t.co/zOur9Gi6Xm">follow me</a> here on Medium! I’ll be sharing more insights and helpful content that you won’t want to miss</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8be33574311d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Normalized Difference Vegetation Index]]></title>
            <link>https://medium.com/@g_murithi/normalized-difference-vegetation-index-cf38e3fbb745?source=rss-b80ab8b5155e------2</link>
            <guid isPermaLink="false">https://medium.com/p/cf38e3fbb745</guid>
            <category><![CDATA[aı]]></category>
            <category><![CDATA[remote-sensing]]></category>
            <category><![CDATA[gis]]></category>
            <category><![CDATA[image-classification]]></category>
            <category><![CDATA[ndvi]]></category>
            <dc:creator><![CDATA[Godwin Murithi]]></dc:creator>
            <pubDate>Thu, 20 Jul 2023 07:38:05 GMT</pubDate>
            <atom:updated>2023-07-20T07:39:33.564Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/973/1*Xx9fZn_bcsAKxjXMMSsVhA.jpeg" /><figcaption>NDVI at different times of the day</figcaption></figure><p>NDVI is a calculation between the near-infrared light reflected by vegetation and the visible light. Healthy vegetation absorbs more visible light and reflects more near-infrared light.</p><p>What many do not know, is that NDVI was not designed to measure plant vigor. It was designed to simply detect living vegetation and distinguish it from other matter like rocks, soil, or dead vegetation. With that in mind, it isn’t hard to understand why as an index for measuring vine vigor, NDVI is loaded with potential errors and inaccuracies</p><h3>Inherent shortcomings of NDVI</h3><p>One of the most important shortcomings of NDVI is its dependency on the time of day at which the aerial images are taken. Since NDVI does not correct for changes in solar incidence angle (the angle at which the sun shines on the leaves) NDVI produces vastly different results throughout the day.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf38e3fbb745" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding the Universal Traverse Mercator (UTM)]]></title>
            <link>https://medium.com/@g_murithi/understanding-the-universal-traverse-mercator-utm-28123e841dbb?source=rss-b80ab8b5155e------2</link>
            <guid isPermaLink="false">https://medium.com/p/28123e841dbb</guid>
            <category><![CDATA[gis]]></category>
            <category><![CDATA[utm]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[surveying]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Godwin Murithi]]></dc:creator>
            <pubDate>Thu, 20 Jul 2023 07:31:29 GMT</pubDate>
            <atom:updated>2023-07-20T07:31:29.027Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8I0oPXR3CqJ11mq_9J0ISQ.jpeg" /><figcaption>UTM zones</figcaption></figure><p>In layman’s terms, the Universal Traverse Mercator (UTM) is a system used to represent locations on the Earth’s surface in a simple and convenient way. It’s like a grid system that divides the world into small rectangles, and each rectangle is assigned a unique set of coordinates.”Unraveling Earth’s Hidden Grid: The Universal Traverse Mercator (UTM) Demystified This makes it easier to find and communicate specific locations accurately.</p><p>Here’s how it works:</p><p><strong>Grid Division</strong></p><p>Imagine you have a huge piece of paper covering the entire Earth’s surface. The UTM divides this paper into a grid of rectangles. Each rectangle represents a specific portion of the Earth, and they are numbered for easy identification.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/335/1*_n4D8QAt8hB3CecImsqQCg.jpeg" /><figcaption>zones</figcaption></figure><p><strong>Zones</strong></p><p>The Earth is divided into 60 horizontal bands, called “zones,” each approximately 6 degrees of longitude wide. These zones are numbered from 1 to 60, starting from the International Date Line in the Pacific Ocean.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/228/1*pa-6xCOOS4m_ARXii5fKxg.jpeg" /><figcaption>Horizontal bands</figcaption></figure><p><strong>Coordinate System</strong></p><p>Within each zone, a coordinate system is used to pinpoint locations. This system is based on two values: easting and northing. Easting measures how far east or west a location is from a central meridian within the zone. Nothing measures how far north or south a location is from the Equator.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/256/1*6-fxfFfGovSmHeALzXDRqA.jpeg" /></figure><p><strong>Units</strong></p><p>The units used for easting and northing are typically in meters. So, instead of using degrees, which are used in latitude and longitude, we use meters for more precise measurements.</p><p><strong>Coordinates for Locations</strong></p><p>When you want to describe a specific location using the UTM system, you provide the zone number and its easting and northing values. For example, you might say a location is in Zone 33, with an easting of 500,000 meters and nothing of 4,000,000 meters.</p><p>UTM is widely used for navigation, mapping, and surveying purposes because it provides a standard and accurate way to communicate locations regardless of where you are on Earth. It’s much simpler to use than latitude and longitude and is especially helpful for tasks that require precise measurements and calculations on a local scale.</p><p>If you enjoyed this article and want to read more from me, make sure to <a href="https://medium.com/@g_murithi">follow me</a> here on Medium! I’ll be sharing more insights and helpful content that you won’t want to miss.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=28123e841dbb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Publish web maps in QGIS: QGIS2WEB plugin]]></title>
            <link>https://medium.com/@g_murithi/how-to-publish-web-maps-in-qgis-qgis2web-plugin-9fd37298a810?source=rss-b80ab8b5155e------2</link>
            <guid isPermaLink="false">https://medium.com/p/9fd37298a810</guid>
            <category><![CDATA[qgis]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[writing]]></category>
            <category><![CDATA[gis]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Godwin Murithi]]></dc:creator>
            <pubDate>Sat, 08 Jul 2023 17:13:20 GMT</pubDate>
            <atom:updated>2023-10-16T14:10:06.870Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/756/1*0mIEQZjhPKTBZJfqc4-UbQ.jpeg" /><figcaption>QGIS2WEB</figcaption></figure><p><a href="https://plugins.qgis.org/plugins/qgis2web/">QGIS2Web</a> takes your desktop GIS so you publish it interactively for the web. If you have your own server, then this plugin creates all the supporting files you need without any server-side software installed.</p><p>Not only does it replicate the symbology and cartographic aspects of your current QGIS Desktop, but you have the option to export a web map to either OpenLayers, Leaflet, or Mapbox GL JS.</p><p>Additionally, you can set the web map to have popups, clusters, and a variety of properties and widgets to make them more appealing to your audience.</p><h4>Install the QGIS2Web Plugin</h4><p>First, you need to download and install the QGIS plugin. You can download a plugin by going to the “Plugins” menu at the top of QGIS Desktop.</p><p>Plugins &gt; Manage and Install Plugins…</p><p>Search for the QGIS2Web plugin. Once you find the plugin in the repository, download, install, and activate it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/984/1*aLInoJ8mCpzjEUWyAikVcA.png" /></figure><h3>How to use the QGIS2Web Plugin</h3><p>Basically, the purpose of this plugin is to take all of the layers in your map and create all the supporting files to build a web map. If you have your own server, then all you have to do is upload them.</p><p>To access the QGIS2Web plugin, you will be able to find it in the top horizontal menu under “Web”.</p><p>Web &gt; QGIS2Web &gt; Create web map</p><p>This will prompt a form that you need to fill in. There is a whole of customizations that are available including the following:</p><p>Layers and groups to display<br>A radio button for either OpenLayers or Leaflet type of map<br>Basemap choice<br>Data export path<br>Popup fields labels<br>Scale/zoom levels</p><p>In addition, there are several widgets available as well to add to your web map. For example, this includes everything from a measuring tool, layer search, layer list, address search, show pop-ups, and highlight on hover.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2pyIDznANoIKY0RLVXFTcg.png" /></figure><p>Once you’re OK with all the settings, click “Export”. Next, it will build a web map package to the folder location you select. After it finishes exporting, it packages all the contents and settings you selected into a folder.</p><p>The folder contains all of the supporting files and folders. For example, it also contains any images, layers, resources, and styles. But it also has an index file, which has all of the HTML that gets presented on the screen.</p><p>If you double-click the index.html file, this will open your browser and display everything from your setup from the QGIS2Web plugin. From here, you will have to upload the contents from QGIS2Web into your web server so the public can view your new web map.</p><p>I hope this guide inspires you to embark on your Python programming journey. If you appreciate my work, consider supporting it by <a href="https://www.buymeacoffee.com/godiewyn54r">buying me a coffee</a>. Happy Coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9fd37298a810" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Geocode Data in R]]></title>
            <link>https://medium.com/@g_murithi/how-to-geocode-data-in-r-f13e52b7c9cb?source=rss-b80ab8b5155e------2</link>
            <guid isPermaLink="false">https://medium.com/p/f13e52b7c9cb</guid>
            <category><![CDATA[r-language]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Godwin Murithi]]></dc:creator>
            <pubDate>Thu, 22 Jun 2023 23:44:37 GMT</pubDate>
            <atom:updated>2023-10-16T14:14:25.599Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/883/1*zamlsT2ZgnUpk5DrY9otHA.png" /><figcaption>Geocoded points</figcaption></figure><p>Geocoding is the process of converting addresses into geographic coordinates (latitude and longitude) that can be plotted on a map. In this tutorial, we’ll explore how to geocode data using R and visualize the results using the leaflet package.</p><p><strong>Step 1: Loading the Required Libraries</strong></p><p>The tidyverse is a collection of R packages designed to make data manipulation and analysis easier and more efficient. It promotes a consistent and tidy data format and provides a set of tools that work seamlessly together.</p><p>dplyr is a core package within the tidyverse that provides a set of functions for data manipulation and transformation. It introduces a grammar of data manipulation, allowing you to express complex data operations in a concise and readable manner.</p><p>tidygeocoder is an R package that provides geocoding functionality, allowing you to convert addresses into geographic coordinates (latitude and longitude). It leverages various geocoding services and APIs to retrieve the geolocation information.</p><p>Finally, leaflet is an R package that provides an interactive and flexible mapping environment. It allows you to create interactive maps with various layers, markers, pop-ups, and other visual elements, making it an excellent tool for data visualization and exploration.</p><pre>library(tidyverse)<br>library(dplyr, warn.conflicts = FALSE)<br>library(tidygeocoder)<br>library(leaflet)</pre><p><strong>Step 2: Reading the Data</strong></p><p>Assuming you have a CSV file named “test.csv” containing address information, you can read the data using the read_csv function from the tidyverse package:</p><pre>data &lt;- read_csv(“test.csv”)</pre><p><strong>Step 3: Geocoding the Data</strong></p><p>To geocode the addresses, we’ll use the geocode function from the tidygeocoder package. This function takes the address field as input and returns the latitude and longitude values.</p><pre>addr &lt;- as.data.frame(data)<br><br>lat_longs &lt;- addr %&gt;%<br> geocode(author_location, method = ‘osm’, lat = latitude, long = longitude, full_results = TRUE)</pre><p>Here, author_location should be replaced with the name of the address column in your data, and latitude and longitude should be the names of the new columns where you want to store the geocoded coordinates.</p><p><strong>Step 4: Cleaning the Data</strong></p><p>It’s common to encounter null or missing values during the geocoding process. To remove these null values from the geocoded data, we can subset the dataframe using the subset function.</p><pre>new_DF &lt;- subset(lat_longs, lat_longs$latitude != “”)</pre><p><strong>Step 5: Saving the Geocoded Data</strong></p><p>To save the geocoded data as a new CSV file, you can use the `write.csv` function.</p><pre>write.csv(new_DF, file = “new_DF.csv”)</pre><h4>Step 6: Visualizing the Geocoded Data</h4><p>To visualize the geocoded data on a map, we’ll utilize the leaflet package. The leaflet package provides an interactive mapping environment.</p><pre>m &lt;- leaflet(new_DF) %&gt;%<br> addTiles() %&gt;%<br> addCircleMarkers(lng = new_DF$longitude, lat = new_DF$latitude, clusterOptions = markerClusterOptions())<br><br>m # Print the map</pre><p>The code above creates a map using the geocoded data and adds circle markers for each location. You can customize the map appearance and markers according to your preference.</p><p>I hope this guide inspires you to embark on your Python programming journey. If you appreciate my work, consider supporting it by <a href="https://www.buymeacoffee.com/godiewyn54r">buying me a coffee</a>. Happy Coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f13e52b7c9cb" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>