

{"id":22883,"date":"2018-07-26T04:00:14","date_gmt":"2018-07-26T04:00:14","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=22883"},"modified":"2026-04-29T12:51:26","modified_gmt":"2026-04-29T07:21:26","slug":"python-geographic-maps-graph-data","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/python-geographic-maps-graph-data\/","title":{"rendered":"Python Geographic Maps &amp; Graph Data"},"content":{"rendered":"<p><span style=\"font-weight: 400\">Today, in this <a href=\"https:\/\/data-flair.training\/blogs\/python-tutorial-for-beginners\/\" target=\"_blank\" rel=\"noopener\"><strong>Python tutorial<\/strong><\/a>, we will discuss Python Geographic Maps and Graph Data. Moreover, we will see how to handle geographical and graph data using <a href=\"https:\/\/data-flair.training\/blogs\/python-library\/\" target=\"_blank\" rel=\"noopener\"><strong>Python and its libraries<\/strong><\/a>. We will use <strong><a href=\"https:\/\/data-flair.training\/blogs\/python-matplotlib-tutorial\/\" target=\"_blank\" rel=\"noopener\">Matplotlib<\/a><\/strong> and Cartopy, among other libraries, to plot Geographic Maps and Graph Data.<\/span><\/p>\n<p>So, let&#8217;s start exploring Python Geographic Maps.<\/p>\n<h3><strong>Prerequisites for Python Geographic Maps and Graph Data<\/strong><\/h3>\n<p><strong><a href=\"https:\/\/data-flair.training\/blogs\/python-heatmap-word-cloud\/\" target=\"_blank\" rel=\"noopener\">Do you know about Python Heatmap<\/a><\/strong><br \/>\n<span style=\"font-weight: 400\">We need the following libraries for this Python Geographic Maps and Graph Data-<\/span><\/p>\n<h4><strong>a. Cartopy in Python<\/strong><\/h4>\n<div id=\"attachment_22892\" style=\"width: 1210px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/1-1-1.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-22892\" class=\"wp-image-22892 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/1-1-1.png\" alt=\"Python Geographic maps\" width=\"1200\" height=\"600\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/1-1-1.png 1200w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/1-1-1-150x75.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/1-1-1-300x150.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/1-1-1-768x384.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/1-1-1-1024x512.png 1024w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><p id=\"caption-attachment-22892\" class=\"wp-caption-text\">Python Geographic Maps &#8211; Cartopy<\/p><\/div>\n<p><span style=\"font-weight: 400\">Cartopy is a <a href=\"https:\/\/data-flair.training\/blogs\/python-packages\/\"><strong>Python package<\/strong><\/a> for cartography. It will let you process geospatial data, analyze it, and produce maps. As a Python package, it uses<a href=\"https:\/\/data-flair.training\/blogs\/python-numpy-tutorial\/\"><strong> NumPy<\/strong><\/a>, PROJ.4, and Shapely, and stands on top of Matplotlib. Some of its key features-<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Object-oriented projection definitions.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Publication-quality maps.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Ability to transform points, lines, polygons, vectors, and images.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400\">You can install it using pip-<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">pip install Cartopy<\/pre>\n<p><span style=\"font-weight: 400\">Note that you may need to install Microsoft Visual C++ Build Tools 14.0 or higher for this.<\/span><br \/>\n<span style=\"font-weight: 400\">You can import it as-<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; import cartopy<\/pre>\n<h4><strong>b. Other modules in Python Matplotlib<\/strong><\/h4>\n<p><span style=\"font-weight: 400\">There are some other modules we will use here-<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">pip install Matplotlib<\/pre>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; import matplotlib.pyplot as plt<\/pre>\n<p><span style=\"font-weight: 400\">We will import other modules on the way as we\u2019ll need them.<\/span><\/p>\n<h3><strong>Python Geographic Maps<\/strong><\/h3>\n<p><span style=\"font-weight: 400\">Python will let us draw Geographical maps. Let\u2019s see how.<\/span><\/p>\n<h4><strong>a. A simple map<\/strong><\/h4>\n<p><span style=\"font-weight: 400\">Let\u2019s first simply draw a map and fill it in later.<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; import cartopy.crs as ccrs\r\n&gt;&gt;&gt; ax=plt.axes(projection=ccrs.PlateCarree()) #Using the PlateCarree projection\r\n&gt;&gt;&gt; ax.coastlines() #Display the coastlines<\/pre>\n<p><strong>&lt;cartopy.mpl.feature_artist.FeatureArtist object at 0x06DA3DF0&gt;<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.show()<\/pre>\n<div id=\"attachment_22886\" style=\"width: 508px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/2-2-1.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-22886\" class=\"wp-image-22886 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/2-2-1.png\" alt=\"Python Geographic maps\" width=\"498\" height=\"250\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/2-2-1.png 498w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/2-2-1-150x75.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/2-2-1-300x151.png 300w\" sizes=\"auto, (max-width: 498px) 100vw, 498px\" \/><\/a><p id=\"caption-attachment-22886\" class=\"wp-caption-text\">Python Geographic Maps &#8211; Simple Map<\/p><\/div>\n<h4><strong>b. Other projections<\/strong><\/h4>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; ax=plt.axes(projection=ccrs.Orthographic())\r\n&gt;&gt;&gt; ax.stock_img() #Add the stock world map image to the plot<\/pre>\n<p><strong>&lt;matplotlib.image.AxesImage object at 0x07427410&gt;<\/strong><br \/>\n<strong><a href=\"https:\/\/data-flair.training\/blogs\/python-data-science-environment-setup\/\" target=\"_blank\" rel=\"noopener\">Learn Python data Science environment Setup<\/a><\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.show()<\/pre>\n<div id=\"attachment_22888\" style=\"width: 433px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/3-2-1.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-22888\" class=\"wp-image-22888 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/3-2-1.png\" alt=\"Python Geographic Maps\" width=\"423\" height=\"431\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/3-2-1.png 423w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/3-2-1-147x150.png 147w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/3-2-1-294x300.png 294w\" sizes=\"auto, (max-width: 423px) 100vw, 423px\" \/><\/a><p id=\"caption-attachment-22888\" class=\"wp-caption-text\">Python Geographic Maps<\/p><\/div>\n<p><span style=\"font-weight: 400\">We have several other projections like Mollweide, Robinson, Sinusoidal, and Gnomonic, among many others.<\/span><\/p>\n<h4><strong>c. Adding data<\/strong><\/h4>\n<p><span style=\"font-weight: 400\">Let\u2019s try to plot Romania to Indore, India on a map.<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; ax=plt.axes(projection=ccrs.AlbersEqualArea())\r\n&gt;&gt;&gt; ax.stock_img()<\/pre>\n<p><strong>&lt;matplotlib.image.AxesImage object at 0x077466B0&gt;<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; ro_lon,ro_lat=25,46 #Coordinates\/ longitude and latitude\r\n&gt;&gt;&gt; ind_lon,ind_lat=75.8,22.7\r\n&gt;&gt;&gt; plt.plot([ro_lon,ind_lon],[ro_lat,ind_lat], color='green',linewidth=2,marker='*',transform=ccrs.Geodetic(),) #Green line<\/pre>\n<p><strong>[&lt;matplotlib.lines.Line2D object at 0x077469B0&gt;]<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.plot([ro_lon,ind_lon],[ro_lat,ind_lat], color='gray',linestyle='--',transform=ccrs.PlateCarree(),) #Gray, dashed line<\/pre>\n<p><strong>[&lt;matplotlib.lines.Line2D object at 0x07746E10&gt;]<\/strong><br \/>\n<strong><a href=\"https:\/\/data-flair.training\/blogs\/pandas-tutorial\/\" target=\"_blank\" rel=\"noopener\">Let&#8217;s revise Python Pandas<\/a><\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.text(ro_lon-3,ro_lat-12,'Romania',\r\n    horizontalalignment='right',\r\n    transform=ccrs.Geodetic()) #Text- Romania<\/pre>\n<p><strong>Text(22,34,&#8217;Romania&#8217;)<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.text(ind_lon+3,ind_lat-12,'Indore',\r\n    horizontalalignment='right',\r\n    transform=ccrs.Geodetic()) #Text- Indore<\/pre>\n<p><strong>Text(78.8,10.7,&#8217;Indore&#8217;)<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.show()<\/pre>\n<div id=\"attachment_22889\" style=\"width: 551px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/4-3-1.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-22889\" class=\"wp-image-22889 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/4-3-1.png\" alt=\"Python Geographic Maps\" width=\"541\" height=\"390\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/4-3-1.png 541w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/4-3-1-150x108.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/4-3-1-300x216.png 300w\" sizes=\"auto, (max-width: 541px) 100vw, 541px\" \/><\/a><p id=\"caption-attachment-22889\" class=\"wp-caption-text\">Python Geographic Maps &#8211; Adding Data<\/p><\/div>\n<p><span style=\"font-weight: 400\">The Geodetic coordinate system is spherical, but since we use AlbersEqualArea, that makes the green line appear straight on the plot. Similarly, the gray line is a PlateCarree but appears spherical.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Now, let\u2019s try adding sky blue pins to a map.<\/span><br \/>\n<strong><a href=\"https:\/\/data-flair.training\/blogs\/scipy-tutorial\/\" target=\"_blank\" rel=\"noopener\">Let&#8217;s discuss Python Scipy Tutorial<\/a><\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; fig=plt.figure(figsize=(16,12))\r\n&gt;&gt;&gt; ax=fig.add_subplot(1,1,1,projection=ccrs.PlateCarree())\r\n&gt;&gt;&gt; ax.set_extent((10,144,70,-30))\r\n&gt;&gt;&gt; ax.stock_img()<\/pre>\n<p><strong>&lt;matplotlib.image.AxesImage object at 0x06D75D90&gt;<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; ax.coastlines()<\/pre>\n<p><strong>&lt;cartopy.mpl.feature_artist.FeatureArtist object at 0x06D75C70&gt;<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; ax.tissot(facecolor='skyblue',alpha=0.6)<\/pre>\n<p><strong>&lt;cartopy.mpl.feature_artist.FeatureArtist object at 0x06D7E210&gt;<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.show()<\/pre>\n<div id=\"attachment_22890\" style=\"width: 542px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/5-2-1.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-22890\" class=\"wp-image-22890 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/5-2-1.png\" alt=\"Python Geographic maps\" width=\"532\" height=\"546\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/5-2-1.png 532w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/5-2-1-146x150.png 146w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/5-2-1-292x300.png 292w\" sizes=\"auto, (max-width: 532px) 100vw, 532px\" \/><\/a><p id=\"caption-attachment-22890\" class=\"wp-caption-text\">Python Geographic Maps &#8211; Adding Data<\/p><\/div>\n<h4><strong>d. Contour plots<\/strong><\/h4>\n<p><span style=\"font-weight: 400\">A contour plot represents a 3D surface on a 2D format by plotting contours (constant z slices). Let\u2019s try making one.<\/span><br \/>\n<strong><a href=\"https:\/\/data-flair.training\/blogs\/data-wrangling-with-python\/\" target=\"_blank\" rel=\"noopener\">Learn Aggregation with Python<\/a><\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; from netCDF4 import Dataset as netcdf_dataset\r\n&gt;&gt;&gt; import numpy as np\r\n&gt;&gt;&gt; from cartopy import config\r\n&gt;&gt;&gt; import os\r\n&gt;&gt;&gt; fname=os.path.join(config[\"repo_data_dir\"],\r\n                    'netcdf', 'HadISST1_SST_update.nc'\r\n                    )\r\n&gt;&gt;&gt; dataset=netcdf_dataset(fname)\r\n&gt;&gt;&gt; sst=dataset.variables['sst'][0,:,:]\r\n&gt;&gt;&gt; lats=dataset.variables['lat'][:]\r\n&gt;&gt;&gt; lons=dataset.variables['lon'][:]\r\n&gt;&gt;&gt; ax=plt.axes(projection=ccrs.PlateCarree())\r\n&gt;&gt;&gt; plt.contourf(lons,lats,sst,60,\r\n            transform=ccrs.PlateCarree())<\/pre>\n<p><strong>&lt;matplotlib.contour.QuadContourSet object at 0x0B39E830&gt;<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; ax.coastlines()<\/pre>\n<p><strong>&lt;cartopy.mpl.feature_artist.FeatureArtist object at 0x0BC6BBD0&gt;<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.show()<\/pre>\n<div id=\"attachment_22891\" style=\"width: 509px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/6-2-1.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-22891\" class=\"wp-image-22891 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/6-2-1.png\" alt=\"Python Geographic Maps\" width=\"499\" height=\"245\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/6-2-1.png 499w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/6-2-1-150x74.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/6-2-1-300x147.png 300w\" sizes=\"auto, (max-width: 499px) 100vw, 499px\" \/><\/a><p id=\"caption-attachment-22891\" class=\"wp-caption-text\">Python Geographic Maps &#8211; Contour Plus<\/p><\/div>\n<h3><strong>Python Graph Data<\/strong><\/h3>\n<p><span style=\"font-weight: 400\">Moving on to graph data, let\u2019s see how Python will let us represent a compressed sparse graph. This is abbreviated as CSGraph. Let\u2019s talk about a few concepts it encompasses.<\/span><br \/>\n<strong><a href=\"https:\/\/data-flair.training\/blogs\/nosql-database-in-python\/\" target=\"_blank\" rel=\"noopener\">Let&#8217;s discuss how to work with NoSQL database<\/a><\/strong><\/p>\n<h4><strong>a. Sparse graphs<\/strong><\/h4>\n<p><span style=\"font-weight: 400\">A sparse graph is a set of nodes that are linked together. Such a graph can represent anything of social network connections to points in a high-dimensional distribution.<\/span><br \/>\n<span style=\"font-weight: 400\">To represent such data, we can use a sparse matrix G. Let\u2019s keep it size NxN. The value of the connection between any two notes i and j will be G[i,j]. Now, a sparse graph will hold zeros for most of its members. This means that for most of its nodes, there exist only a few connections.<\/span><br \/>\n<span style=\"font-weight: 400\">Some algorithms we use for this are-<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\"><strong>Isomap-<\/strong> This is a manifold learning algorithm that needs to find the shortest paths in a graph<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\"><strong>Hierarchical clustering-<\/strong> This is a clustering algorithm and is based on minimum spanning trees<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\"><strong>Spectral decomposition-<\/strong> This is a projection algorithm and is based on sparse graph laplacians<\/span><\/li>\n<\/ul>\n<h4><strong>b. Example &#8211; Word Ladder<\/strong><\/h4>\n<p><span style=\"font-weight: 400\">This is a word game by Lewis Carroll. In this game, players switch letters in words to get from one word to another; they do this one letter at once. Let\u2019s take an example.<\/span><br \/>\n<strong>wade-&gt; fade-&gt; faze-&gt; gaze-&gt; gate-&gt; date-&gt; hate<\/strong><br \/>\n<span style=\"font-weight: 400\">In cases like such, when we want to find the shortest possible path from one word to another, we can use the sparse graph submodule.<\/span><br \/>\n<strong><a href=\"https:\/\/data-flair.training\/blogs\/python-data-file-formats\/\" target=\"_blank\" rel=\"noopener\">Do you Know about Python Data File Formats<\/a><\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; wordlist=\"hello how are you can you read this without punctuation do you think this is something what is the meaning of life\".split()\r\n&gt;&gt;&gt; wordlist=[word for word in wordlist if len(word) == 3]\r\n&gt;&gt;&gt; wordlist=[word for word in wordlist if word[0].islower()]\r\n&gt;&gt;&gt; wordlist=[word for word in wordlist if word.isalpha()]\r\n&gt;&gt;&gt; wordlist = list(map(str.lower, wordlist))\r\n&gt;&gt;&gt; len(wordlist)<\/pre>\n<p><strong>7<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; import numpy as np\r\n&gt;&gt;&gt; wordlist=np.asarray(wordlist)\r\n&gt;&gt;&gt; wordlist.dtype<\/pre>\n<p><strong>dtype<span style=\"font-family: Verdana, Geneva, sans-serif\">(&#8216;&lt;U3&#8217;)<\/span><\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; wordlist.sort()\r\n&gt;&gt;&gt; i1=wordlist.searchsorted('wade')\r\n&gt;&gt;&gt; i2=wordlist.searchsorted('hate')\r\n&gt;&gt;&gt; wordlist[i1]<\/pre>\n<p><strong>&#8216;you&#8217;<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; wordlist[i2]<\/pre>\n<p><strong>&#8216;how&#8217;<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; wordlist<\/pre>\n<p><strong>array([&#8216;are&#8217;, &#8216;can&#8217;, &#8216;how&#8217;, &#8216;the&#8217;, &#8216;you&#8217;, &#8216;you&#8217;, &#8216;you&#8217;], dtype='&lt;U3&#8242;)<\/strong><br \/>\nSo, this was all in Python Geographic Maps. Hope you like our explanation of Python Graphs Data.<\/p>\n<h3><strong>Conclusion<\/strong><\/h3>\n<p><span style=\"font-weight: 400\">Hence, in this Python Geographic Maps tutorial, we discussed graph plotting with Python. Moreover, we discussed Python Graph Data. Some of the libraries we used were Cartopy and Matplotlib.<\/span><br \/>\n<strong>See also &#8211;<\/strong><br \/>\n<strong><a href=\"https:\/\/data-flair.training\/blogs\/python-3-extension-programming\/\" target=\"_blank\" rel=\"noopener\">Python 3 Extension Programming<\/a><\/strong><br \/>\n<a href=\"https:\/\/en.wikipedia.org\/wiki\/\"><strong>For reference<\/strong><\/a><span hidden class=\"__iawmlf-post-loop-links\" data-iawmlf-links=\"[{&quot;id&quot;:1862,&quot;href&quot;:&quot;https:\\\/\\\/en.wikipedia.org\\\/wiki&quot;,&quot;archived_href&quot;:&quot;http:\\\/\\\/web-wp.archive.org\\\/web\\\/20251011050936\\\/https:\\\/\\\/en.wikipedia.org\\\/wiki\\\/%2F%2F&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2025-12-10 05:44:31&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2025-12-13 20:49:55&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2025-12-26 12:23:56&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-03 13:50:35&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-21 06:15:17&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-26 03:56:31&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-30 10:55:15&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-11 10:13:52&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-17 17:57:09&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-06 04:29:49&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-24 05:09:55&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-09 09:00:36&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-15 07:33:32&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-20 15:27:17&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-29 04:56:37&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-13 02:33:26&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-06-05 12:08:03&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-06-11 03:54:01&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-06-25 17:42:06&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-07-01 11:53:33&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-07-12 18:59:12&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-07-17 08:15:54&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-07-24 13:32:32&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-07-28 03:01:06&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-08-02 11:56:58&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-08-08 09:45:12&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-08-12 07:56:51&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-08-16 12:00:44&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-08-21 07:23:19&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-08-30 11:51:45&quot;,&quot;http_code&quot;:200}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-08-30 11:51:45&quot;,&quot;http_code&quot;:200},&quot;process&quot;:&quot;done&quot;}]\"><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today, in this Python tutorial, we will discuss Python Geographic Maps and Graph Data. Moreover, we will see how to handle geographical and graph data using Python and its libraries. We will use Matplotlib&#46;&#46;&#46;<\/p>\n","protected":false},"author":5,"featured_media":22896,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[46],"tags":[2308,5067,5069,5134,5136,8601,10561,10562,10568],"class_list":["post-22883","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-cartopy","tag-geographic-maps","tag-geographical-plotting-with-python","tag-graph-data-in-python","tag-graph-data-with-python","tag-matplotlib","tag-python-geographic-data","tag-python-geographic-plots","tag-python-graph-data"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Python Geographic Maps &amp; Graph Data - DataFlair<\/title>\n<meta name=\"description\" content=\"Let&#039;s discuss Python Geographic Maps and Graph Data. We will see how to handle geographical and graph data using Python and its libraries.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/python-geographic-maps-graph-data\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Geographic Maps &amp; Graph Data - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Let&#039;s discuss Python Geographic Maps and Graph Data. We will see how to handle geographical and graph data using Python and its libraries.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/python-geographic-maps-graph-data\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2018-07-26T04:00:14+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-04-29T07:21:26+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/Geographical-and-Graph-Data-with-Python-01.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python Geographic Maps &amp; Graph Data - DataFlair","description":"Let's discuss Python Geographic Maps and Graph Data. We will see how to handle geographical and graph data using Python and its libraries.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/data-flair.training\/blogs\/python-geographic-maps-graph-data\/","og_locale":"en_US","og_type":"article","og_title":"Python Geographic Maps &amp; Graph Data - DataFlair","og_description":"Let's discuss Python Geographic Maps and Graph Data. We will see how to handle geographical and graph data using Python and its libraries.","og_url":"https:\/\/data-flair.training\/blogs\/python-geographic-maps-graph-data\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2018-07-26T04:00:14+00:00","article_modified_time":"2026-04-29T07:21:26+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/Geographical-and-Graph-Data-with-Python-01.jpg","type":"image\/jpeg"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/python-geographic-maps-graph-data\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/python-geographic-maps-graph-data\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823"},"headline":"Python Geographic Maps &amp; Graph Data","datePublished":"2018-07-26T04:00:14+00:00","dateModified":"2026-04-29T07:21:26+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/python-geographic-maps-graph-data\/"},"wordCount":877,"commentCount":0,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/python-geographic-maps-graph-data\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/Geographical-and-Graph-Data-with-Python-01.jpg","keywords":["Cartopy","Geographic maps","geographical plotting with python","Graph data in python","Graph data With python","Matplotlib","Python Geographic data","Python Geographic plots","Python Graph data"],"articleSection":["Python Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/python-geographic-maps-graph-data\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/python-geographic-maps-graph-data\/","url":"https:\/\/data-flair.training\/blogs\/python-geographic-maps-graph-data\/","name":"Python Geographic Maps &amp; Graph Data - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/python-geographic-maps-graph-data\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/python-geographic-maps-graph-data\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/Geographical-and-Graph-Data-with-Python-01.jpg","datePublished":"2018-07-26T04:00:14+00:00","dateModified":"2026-04-29T07:21:26+00:00","description":"Let's discuss Python Geographic Maps and Graph Data. We will see how to handle geographical and graph data using Python and its libraries.","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/python-geographic-maps-graph-data\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/python-geographic-maps-graph-data\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/python-geographic-maps-graph-data\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/Geographical-and-Graph-Data-with-Python-01.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/Geographical-and-Graph-Data-with-Python-01.jpg","width":1200,"height":628,"caption":"Python Geographic Maps &amp; Graph Data"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/python-geographic-maps-graph-data\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"Python Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/python\/"},{"@type":"ListItem","position":3,"name":"Python Geographic Maps &amp; Graph Data"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"DataFlair Team creates expert-level guides on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our goal is to empower learners with easy-to-understand content. Explore our resources for career growth and practical learning.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam1\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/22883","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=22883"}],"version-history":[{"count":7,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/22883\/revisions"}],"predecessor-version":[{"id":148074,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/22883\/revisions\/148074"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/22896"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=22883"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=22883"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=22883"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}