In this article I want to tell you in 6 small pills how we can use geolocation and maps with Python.

I will teach you to program simple practices for the classroom where we can take the exact location of a place, city or country and play with their coordinates. In this way we can also draw the distance between any two cities of the earth map.

Finally we will finish the last two pills with the Basemap library of Python, which allows us to draw a map, with several properties and I will show you how to place on the map the cities or places that we have previously located.

Libraries needed in python

The libraries that we will use and must have installed are basemap and geopy. Remember that both can be installed using the comnado:

pip install basemap pip install geopy

Well, let's start.

1ª Pildora: take the coordinates of a place through the geopy library, Nominatim.

2ª Pill: Take the coordinates of several places at the same time using a list

3ª Pildora: Know the distance in km between two places using the geopy.distance library

4ª Pill: Create our own recipe (function) to calculate the distance between two places you want.

5ª PILLAR: Use of the Basemap library to draw our map and place the cities by means of coordinates

6ª Pill: Use a list to place on our map different points of places or cities.

Repository with the exercises of the article: