Show location of coordinates on google maps using Python
Question:
I wrote a code for data science and I got some coordinates that I want to plot on google maps. These are the coordinates, and all of these coordinates are in capitol city of Serbia called Belgrade.
X Y
20.657460 44.490140
20.510760 44.652443
20.510540 44.884460
20.471758 44.788613
20.359841 44.742405
20.472120 44.763520
20.610525 44.676290
How can I plot these data on google maps so that I can see locations of these coordinates on google maps?
I tried with matplotlib, and with some Santdex tutorials and with pygmaps
but I failed. I could not intall pygmaps
Answers:
You can use gmplot to plot data with Google Maps.
To do so, install with pip install gmplot
.
Then, the code should look like :
from gmplot import gmplot
# Initialize the map at a given point
gmap = gmplot.GoogleMapPlotter(37.766956, -122.438481, 13)
# Add a marker
gmap.marker(37.770776, -122.461689, 'cornflowerblue')
# Draw map into HTML file
gmap.draw("my_map.html")
You can see gmplot repo to see how to use it.
I was able to generate a hmtl file with the code which displays the map on a browser but my plotted points on the map are not displaying
I wrote a code for data science and I got some coordinates that I want to plot on google maps. These are the coordinates, and all of these coordinates are in capitol city of Serbia called Belgrade.
X Y
20.657460 44.490140
20.510760 44.652443
20.510540 44.884460
20.471758 44.788613
20.359841 44.742405
20.472120 44.763520
20.610525 44.676290
How can I plot these data on google maps so that I can see locations of these coordinates on google maps?
I tried with matplotlib, and with some Santdex tutorials and with pygmaps
but I failed. I could not intall pygmaps
You can use gmplot to plot data with Google Maps.
To do so, install with pip install gmplot
.
Then, the code should look like :
from gmplot import gmplot
# Initialize the map at a given point
gmap = gmplot.GoogleMapPlotter(37.766956, -122.438481, 13)
# Add a marker
gmap.marker(37.770776, -122.461689, 'cornflowerblue')
# Draw map into HTML file
gmap.draw("my_map.html")
You can see gmplot repo to see how to use it.
I was able to generate a hmtl file with the code which displays the map on a browser but my plotted points on the map are not displaying