I have found very easy and useful to load world map from geopandas datasets, as probably many others, for example:
import geopandas as gpd
world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
However, this gives a FutureWarning that dataset module is deprecated and will be removed in the future. There are maps available for download, for example from https://www.naturalearthdata.com/downloads/110m-cultural-vectors/ but the files are zipped and it does not seem like a convinient workflow to either get and process files from there or neither include processed files with the source.
Is there an alternative? What is the best way to do this, especially if I want my code to work with future versions of Geopandas?
You can read it from Nacis :
import geopandas as gpd
url = "https://naciscdn.org/naturalearth/110m/cultural/ne_110m_admin_0_countries.zip"
gdf = gpd.read_file(url)
old answer:
The simplest solution would be to download/store the shapefile somewhere.
That being said, if (for some reason), you need to read it from the source, you can do it this way :
import fsspec
url = "https://www.naturalearthdata.com/http//www.naturalearthdata.com/" \
"download/110m/cultural/ne_110m_admin_0_countries.zip"
with fsspec.open(f"simplecache::{url}") as file:
gdf = gpd.read_file(file)
Output :
featurecla scalerank ... FCLASS_UA geometry
0 Admin-0 country 1 ... None MULTIPOLYGON (((180.00000 -16.0...
1 Admin-0 country 1 ... None POLYGON ((33.90371 -0.95000, 34...
2 Admin-0 country 1 ... None POLYGON ((-8.66559 27.65643, -8...
.. ... ... ... ... ...
174 Admin-0 country 1 ... Unrecognized POLYGON ((20.59025 41.85541, 20...
175 Admin-0 country 1 ... None POLYGON ((-61.68000 10.76000, -...
176 Admin-0 country 1 ... None POLYGON ((30.83385 3.50917, 29....
[177 rows x 169 columns]