How to plot a world map with cities in the right locations?


The data source is a CSV with cities in various countries in the world, each city has some numeric data associated with it. df.columns looks like:

['Continent', 'Country', 'City', 'data']

I want to make a map with all these cities, shown in the right location. I want a color bar with at least some of the cities ordered by the numeric data column. On the map, the cities should be marked with the same color as in the color bar.

Probably something like Plotly could draw the map. But:

  • how to get the geolocations of each city based on the first 3 columns?
  • how to plot dots or disks (with color attributes) in Plotly based on lat/long pairs?

The idea is similar to this, but with cities instead of countries:

enter image description here

Florin Andrei

Posted 2020-02-05T00:41:09.033

Reputation: 681

Use some external API/data dump to get the latitudes and longitudes – Aditya – 2020-02-05T01:59:48.240

@Aditya Well, yeah, that's obvious, I was hoping to get a useful example. – Florin Andrei – 2020-02-05T02:26:11.390

To grab the data, I am not sure but I think you can use Open Street Map? Sorry me no expert in geospatial but plotting them back is not gonna be difficult I think – Aditya – 2020-02-05T18:25:58.637

No answers