From a table containing location names (countries, cities, addresses, etc) and an indicator (a numerical value) for each location, this code creates a world map with each country colored according to the indicator.
This code uses GeoPandas 🤩
Clone the project:
git clone [email protected]:GeoffroyGit/abeona.git
I recommend you to create a fresh virtual environment
Create a python3 virtualenv and activate it:
cd abeona
pyenv virtualenv abeona
pyenv local abeona
Upgrade pip if needed:
pip install --upgrade pip
Install the dependancies:
pip install -r requirements.txt
Create a Jupyter notebook
jupyter notebook
Inside your notebook, run the following python code
Import GeoLoc
from geoloc import GeoLoc
Open your pandas dataframe
df = pd.read_csv("/path/to/your/file.csv")
or create a dummy dataframe
df = pd.DataFrame({
"location" : ["Nantes", "Singapore", "Santiago", "New York", "Tokyo", "London", "Barcelona", "Nantes"],
"indicator" : [7.0, 6.5, 5.5, 5.0, 4.7, 2.3, 1.0, 8.0]
})
Create an instance of the class GeoLoc
geo_locator = GeoLoc(df)
Finally, plot the world map
geo_locator.plot();