The Wayback Machine - http://web.archive.org/web/20241116023047/https://www.geeksforgeeks.org/python-plotting-google-map-using-gmplot-package/
Open In App

Python | Plotting Google Map using gmplot package

Last Updated : 04 Jun, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

gmplot

is a matplotlib-like interface to generate the HTML and javascript to render all the data user would like on top of Google Maps. Command to install

gmplot

:

pip install gmplot

Code #1 :

To create a Base Map

Python
# import gmplot package
import gmplot

# GoogleMapPlotter return Map object
# Pass the center latitude and
# center longitude
gmap1 = gmplot.GoogleMapPlotter(30.3164945,
                                78.03219179999999, 13 )

# Pass the absolute path
gmap1.draw( "C:\\Users\\user\\Desktop\\map11.html" )

Output :

map11

Code #2 :

Another method To create a Base map

Python
# import gmplot package
import gmplot

# from_geocode method return the
# latitude and longitude of given location .
gmap2 = gmplot.GoogleMapPlotter.from_geocode( "Dehradun, India" )

gmap2.draw( "C:\\Users\\user\\Desktop\\map12.html" )

Output :

map12

Code #3 :

Scatter points on the google map and draw a line in between them .

Python
# import gmplot package
import gmplot

latitude_list = [ 30.3358376, 30.307977, 30.3216419 ]
longitude_list = [ 77.8701919, 78.048457, 78.0413095 ]

gmap3 = gmplot.GoogleMapPlotter(30.3164945,
                                78.03219179999999, 13)

# scatter method of map object 
# scatter points on the google map
gmap3.scatter( latitude_list, longitude_list, '# FF0000',
                              size = 40, marker = False )

# Plot method Draw a line in
# between given coordinates
gmap3.plot(latitude_list, longitude_list, 
           'cornflowerblue', edge_width = 2.5)

gmap3.draw( "C:\\Users\\user\\Desktop\\map13.html" )

Output :

map13

Code #4 :

To Show a heat map plot

Python
# import gmplot package
import gmplot

latitude_list = [30.3358376, 30.307977, 30.3216419, 30.3427904,
                  30.378598, 30.3548185, 30.3345816, 30.387299,
                    30.3272198, 30.3840597, 30.4158, 30.340426,
                             30.3984348, 30.3431313, 30.273471]

longitude_list = [77.8701919, 78.048457, 78.0413095, 77.886958,
                  77.825396, 77.8460573, 78.0537813, 78.090614,
                    78.0355272, 77.9311923, 77.9663, 77.952092,
                            78.0747887, 77.9555512, 77.9997158]

gmap4 = gmplot.GoogleMapPlotter.from_geocode("Dehradun, India")

# heatmap plot heating Type
# points on the Google map
gmap4.heatmap( latitude_list, longitude_list )

gmap4.draw( "C:\\Users\\user\\Desktop\\map14.html" )

Output :

Screenshot-573-copy


Code #5 :

To draw a polygon on the google map

Python
# import gmplot package
import gmplot

latitude_list = [ 30.3358376, 30.307977, 30.3216419 ]
longitude_list = [ 77.8701919, 78.048457, 78.0413095 ]

gmap5 = gmplot.GoogleMapPlotter(30.3164945,
                                78.03219179999999, 13)

gmap5.scatter( latitude_list, longitude_list, '# FF0000',
                                size = 40, marker = False)

# polygon method Draw a polygon with
# the help of coordinates
gmap5.polygon(latitude_list, longitude_list,
                   color = 'cornflowerblue')

gmap5.draw( "C:\\Users\\user\\Desktop\\map15.html" )

Output :

map15


Similar Reads

Plotting Data on Google Map using Python's pygmaps package
pygmaps is a matplotlib-like interface to generate the HTML and javascript to render all the data users would like on top of Google Maps. Command to install pygmaps : pip install pygmaps (on windows)sudo pip3 install pygmaps (on linix / unix)Code #1 : To create a Base Map. [GFGTABS] Python # import required package import pygmaps # maps method retu
3 min read
Python | Plotting Google Map using folium package
Folium is built on the data wrangling strengths of the Python ecosystem and the mapping strengths of the Leaflet.js (JavaScript) library. Simply, manipulate your data in Python, then visualize it on a leaflet map via Folium. Folium makes it easy to visualize data that's been manipulated in Python, on an interactive Leaflet map. This library has a n
2 min read
Plotting ICMR approved test centers on Google Maps using folium package
Folium is a powerful data visualization library in Python that was built primarily to help people visualize geospatial data. With Folium, a map of any location in the world can be created as long as its latitude and longitude values are known. Also, the maps created by Folium are interactive in nature, so that you can zoom in and out after the map
3 min read
Plotting World Map Using Pygal in Python
Pygal is a Python module that is mainly used to build SVG (Scalar Vector Graphics) graphs and charts. SVG is a vector-based graphics in the XML format that can be edited in any editor. Pygal can create graphs with minimal lines of code that can be easy to understand and write. We might want to plot the World Map with country wise boundaries and mig
3 min read
Python | Geographical plotting using plotly
Geographical plotting is used for world map as well as states under a country. Mainly used by data analysts to check the agriculture exports or to visualize such data. plotly is a Python library which is used to design graphs, especially interactive graphs. It can plot various graphs and charts like histogram, barplot, boxplot, spreadplot and many
2 min read
Python | Plotting charts in excel sheet using openpyxl module | Set - 1
Prerequisite: Reading & Writing to excel sheet using openpyxl Openpyxl is a Python library using which one can perform multiple operations on excel files like reading, writing, arithmetic operations and plotting graphs. Let's see how to plot different charts using realtime data. Charts are composed of at least one series of one or more data poi
6 min read
Python | Plotting charts in excel sheet using openpyxl module | Set – 2
Prerequisite: Python | Plotting charts in excel sheet using openpyxl module | Set – 1 Openpyxl is a Python library using which one can perform multiple operations on excel files like reading, writing, arithmetic operations and plotting graphs. Charts are composed of at least one series of one or more data points. Series themselves are comprised of
6 min read
Python | Plotting charts in excel sheet using openpyxl module | Set 3
Prerequisite : Plotting charts in excel sheet using openpyxl module Set - 1 | Set – 2Openpyxl is a Python library using which one can perform multiple operations on excel files like reading, writing, arithmetic operations and plotting graphs. Charts are composed of at least one series of one or more data points. Series themselves are comprised of r
7 min read
3D Wireframe plotting in Python using Matplotlib
To create static, animated and interactive visualizations of data, we use the Matplotlib module in Python. The below programs will depict 3D wireframe. visualization of data in Python. In-order to visualize data using 3D wireframe we require some modules from matplotlib, mpl_toolkits and numpy library. Example 1: C/C++ Code # importing modules from
1 min read
Python | Plotting Area charts in excel sheet using XlsxWriter module
Prerequisite: Create and write on an excel file XlsxWriter is a Python library using which one can perform multiple operations on excel files like creating, writing, arithmetic operations and plotting graphs. Let’s see how to plot different charts using realtime data. Charts are composed of at least one series of one or more data points. Series the
6 min read
Python | Plotting bar charts in excel sheet using XlsxWriter module
Prerequisite: Create and Write on an excel file.XlsxWriter is a Python library using which one can perform multiple operations on excel files like creating, writing, arithmetic operations and plotting graphs. Let’s see how to plot different type of Bar charts using realtime data. Charts are composed of at least one series of one or more data points
6 min read
Python | Plotting Radar charts in excel sheet using XlsxWriter module
Prerequisite:Create and Write on excel file XlsxWriter is a Python library using which one can perform multiple operations on excel files like creating, writing, arithmetic operations and plotting graphs. Let’s see how to plot different type of Radar charts using realtime data. Charts are composed of at least one series of one or more data points.
6 min read
Python | Plotting scatter charts in excel sheet using XlsxWriter module
Prerequisite: Create and Write on an excel file. XlsxWriter is a Python library using which one can perform multiple operations on excel files like creating, writing, arithmetic operations and plotting graphs. Let’s see how to plot different type of Scatter charts using realtime data. Charts are composed of at least one series of one or more data p
10 min read
Python | Plotting column charts in excel sheet using XlsxWriter module
Prerequisite: Create and Write on an excel file.XlsxWriter is a Python library using which one can perform multiple operations on excel files like creating, writing, arithmetic operations and plotting graphs. Let’s see how to plot different type of Column charts using realtime data. Charts are composed of at least one series of one or more data poi
7 min read
Python | Plotting Pie charts in excel sheet using XlsxWriter module
Prerequisite: Create and Write on an excel sheet XlsxWriter is a Python library using which one can perform multiple operations on excel files like creating, writing, arithmetic operations and plotting graphs. Let’s see how to plot different types of pie charts using realtime data. Charts are composed of at least one series of one or more data poin
5 min read
Python | Plotting Doughnut charts in excel sheet using XlsxWriter module
Prerequisite: Create and Write on an excel sheet XlsxWriter is a Python library using which one can perform multiple operations on excel files like creating, writing, arithmetic operations and plotting graphs. Let’s see how to plot different variety of doughnut charts using realtime data. Charts are composed of at least one series of one or more da
7 min read
Python | Plotting Stock charts in excel sheet using XlsxWriter module
Prerequisite: Create and Write on an excel sheet XlsxWriter is a Python library using which one can perform multiple operations on excel files like creating, writing, arithmetic operations and plotting graphs. Let’s see how to plot Stock charts using realtime data. Charts are composed of at least one series of one or more data points. Series themse
3 min read
Python | Plotting Line charts in excel sheet using XlsxWriter module
Prerequisite: Create and Write on an excel sheet XlsxWriter is a Python library using which one can perform multiple operations on excel files like creating, writing, arithmetic operations and plotting graphs. Let’s see how to plot Line charts using realtime data. Charts are composed of at least one series of one or more data points. Series themsel
3 min read
Python | Plotting Combined charts in excel sheet using XlsxWriter module
Prerequisite: Create and Write on an excel sheetXlsxWriter is a Python library using which one can perform multiple operations on excel files like creating, writing, arithmetic operations, and plotting graphs. Let’s see how to plot Combined charts using real-time data. Charts are composed of at least one series of one or more data points. Series th
5 min read
Python | Plotting an Excel chart with pattern fills in column using XlsxWriter module
Prerequisite: Create and Write on an excel sheetXlsxWriter is a Python library using which one can perform multiple operations on excel files like creating, writing, arithmetic operations and plotting graphs. Let’s see how to plot chart with pattern fills, using realtime data.Charts are composed of at least one series of one or more data points. Se
3 min read
Python | Plotting Different types of style charts in excel sheet using XlsxWriter module
Prerequisite: Create and Write on an excel sheet XlsxWriter is a Python library using which one can perform multiple operations on excel files like creating, writing, arithmetic operations and plotting graphs. Let’s see how to plot different types of Style charts, using realtime data. Charts are composed of at least one series of one or more data p
3 min read
Python | Plotting an Excel chart with Gradient fills using XlsxWriter module
Prerequisite: Create and Write on an excel sheetXlsxWriter is a Python library using which one can perform multiple operations on excel files like creating, writing, arithmetic operations, and plotting graphs. Let’s see how to plot a chart with Gradient fills, using real-time data.Charts are composed of at least one series of one or more data point
5 min read
Python | Plotting column charts in excel sheet with data tables using XlsxWriter module
Prerequisite: Create and Write on an excel sheetXlsxWriter is a Python library using which one can perform multiple operations on excel files like creating, writing, arithmetic operations and plotting graphs. Let’s see how to plot charts with Data tables using realtime data.Charts are composed of at least one series of one or more data points. Seri
5 min read
Python | Plotting charts in excel sheet with Data Tools using XlsxWriter module | Set - 1
Prerequisite: Create and Write on an excel sheetXlsxWriter is a Python library using which one can perform multiple operations on excel files like creating, writing, arithmetic operations and plotting graphs. Let’s see how to plot charts with different types of Data Tools using realtime data. Charts are composed of at least one series of one or mor
7 min read
Python | Plotting charts in excel sheet with data tools using XlsxWriter module | Set – 2
Prerequisite: Create and Write on an excel sheetXlsxWriter is a Python library using which one can perform multiple operations on excel files like creating, writing, arithmetic operations and plotting graphs. Let’s see how to plot charts with different types of Data Tools using realtime data.Charts are composed of at least one series of one or more
7 min read
Python | Matplotlib Sub plotting using object oriented API
Plotting using Object Oriented(OO) API in matplotlib is an easy approach to plot graphs and other data visualization methods. The simple syntax to create the class and object for sub-plotting is - class_name, object_name = matplotlib.pyplot.subplots('no_of_rows', 'no_of_columns') Let's take some examples to make it more clear. Example #1: # importi
2 min read
Python | Matplotlib Graph plotting using object oriented API
In object-oriented API, first, we create a canvas on which we have to plot the graph and then we plot the graph. Many people prefer object-oriented API because it is easy to use as compared to functional API. Let's try to understand this with some examples. Example #1: # importing matplotlib library import matplotlib.pyplot as plt # x axis values x
2 min read
3D Contour Plotting in Python using Matplotlib
Matplotlib was introduced keeping in mind, only two-dimensional plotting. But at the time when the release of 1.0 occurred, the 3d utilities were developed upon the 2d and thus, we have 3d implementation of data available today! The 3d plots are enabled by importing the mplot3d toolkit. Let's look at a 3d contour diagram of a 3d cosine function. Th
2 min read
3D Surface plotting in Python using Matplotlib
A Surface Plot is a representation of three-dimensional dataset. It describes a functional relationship between two independent variables X and Z and a designated dependent variable Y, rather than showing the individual data points. It is a companion plot of the contour plot. It is similar to the wireframe plot, but each face of the wireframe is a
4 min read
3D Scatter Plotting in Python using Matplotlib
A 3D Scatter Plot is a mathematical diagram, the most basic version of three-dimensional plotting used to display the properties of data as three variables of a dataset using the cartesian coordinates.To create a 3D Scatter plot, Matplotlib's mplot3d toolkit is used to enable three dimensional plotting.Generally 3D scatter plot is created by using
2 min read
Article Tags :
Practice Tags :
three90RightbarBannerImg