In [ ]:
pip install geopandas
Requirement already satisfied: geopandas in /usr/local/lib/python3.12/dist-packages (1.1.1) Requirement already satisfied: numpy>=1.24 in /usr/local/lib/python3.12/dist-packages (from geopandas) (2.0.2) Requirement already satisfied: pyogrio>=0.7.2 in /usr/local/lib/python3.12/dist-packages (from geopandas) (0.11.1) Requirement already satisfied: packaging in /usr/local/lib/python3.12/dist-packages (from geopandas) (25.0) Requirement already satisfied: pandas>=2.0.0 in /usr/local/lib/python3.12/dist-packages (from geopandas) (2.2.2) Requirement already satisfied: pyproj>=3.5.0 in /usr/local/lib/python3.12/dist-packages (from geopandas) (3.7.2) Requirement already satisfied: shapely>=2.0.0 in /usr/local/lib/python3.12/dist-packages (from geopandas) (2.1.2) Requirement already satisfied: python-dateutil>=2.8.2 in /usr/local/lib/python3.12/dist-packages (from pandas>=2.0.0->geopandas) (2.9.0.post0) Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.12/dist-packages (from pandas>=2.0.0->geopandas) (2025.2) Requirement already satisfied: tzdata>=2022.7 in /usr/local/lib/python3.12/dist-packages (from pandas>=2.0.0->geopandas) (2025.2) Requirement already satisfied: certifi in /usr/local/lib/python3.12/dist-packages (from pyogrio>=0.7.2->geopandas) (2025.10.5) Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.12/dist-packages (from python-dateutil>=2.8.2->pandas>=2.0.0->geopandas) (1.17.0)
In [ ]:
pip install geodatasets
Collecting geodatasets Downloading geodatasets-2024.8.0-py3-none-any.whl.metadata (5.4 kB) Requirement already satisfied: pooch in /usr/local/lib/python3.12/dist-packages (from geodatasets) (1.8.2) Requirement already satisfied: platformdirs>=2.5.0 in /usr/local/lib/python3.12/dist-packages (from pooch->geodatasets) (4.5.0) Requirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.12/dist-packages (from pooch->geodatasets) (25.0) Requirement already satisfied: requests>=2.19.0 in /usr/local/lib/python3.12/dist-packages (from pooch->geodatasets) (2.32.4) Requirement already satisfied: charset_normalizer<4,>=2 in /usr/local/lib/python3.12/dist-packages (from requests>=2.19.0->pooch->geodatasets) (3.4.4) Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.12/dist-packages (from requests>=2.19.0->pooch->geodatasets) (3.11) Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.12/dist-packages (from requests>=2.19.0->pooch->geodatasets) (2.5.0) Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.12/dist-packages (from requests>=2.19.0->pooch->geodatasets) (2025.10.5) Downloading geodatasets-2024.8.0-py3-none-any.whl (20 kB) Installing collected packages: geodatasets Successfully installed geodatasets-2024.8.0
In [ ]:
import pandas as pd
import geopandas
import matplotlib.pyplot as plt
from geodatasets import get_path
from osgeo import gdal
gdal.SetConfigOption('SHAPE_RESTORE_SHX', 'YES')
In [ ]:
states = geopandas.read_file('usa-states-census-2014.shp')
fig, ax = plt.subplots(figsize= (14, 8))
states.plot(ax=ax, edgecolor='lightgrey', linewidth=1.5, cmap='BuGn')
plt.show()
In [ ]:
df2= pd.read_csv('chipotle_stores.csv')
df2.head()
Out[ ]:
| state | location | address | latitude | longitude | |
|---|---|---|---|---|---|
| 0 | Alabama | Auburn | 346 W Magnolia Ave Auburn, AL 36832 US | 32.606813 | -85.487328 |
| 1 | Alabama | Birmingham | 300 20th St S Birmingham, AL 35233 US | 33.509721 | -86.802756 |
| 2 | Alabama | Birmingham | 3220 Morrow Rd Birmingham, AL 35235 US | 33.595581 | -86.647437 |
| 3 | Alabama | Birmingham | 4719 Highway 280 Birmingham, AL 35242 US | 33.422582 | -86.698279 |
| 4 | Alabama | Cullman | 1821 Cherokee Ave SW Cullman, AL 35055 US | 34.154134 | -86.841220 |
In [ ]:
len(df2)
Out[ ]:
2629
In [ ]:
gdf = geopandas.GeoDataFrame(df2, geometry=geopandas.points_from_xy(df2.longitude, df2.latitude))
gdf.head()
Out[ ]:
| state | location | address | latitude | longitude | geometry | |
|---|---|---|---|---|---|---|
| 0 | Alabama | Auburn | 346 W Magnolia Ave Auburn, AL 36832 US | 32.606813 | -85.487328 | POINT (-85.48733 32.60681) |
| 1 | Alabama | Birmingham | 300 20th St S Birmingham, AL 35233 US | 33.509721 | -86.802756 | POINT (-86.80276 33.50972) |
| 2 | Alabama | Birmingham | 3220 Morrow Rd Birmingham, AL 35235 US | 33.595581 | -86.647437 | POINT (-86.64744 33.59558) |
| 3 | Alabama | Birmingham | 4719 Highway 280 Birmingham, AL 35242 US | 33.422582 | -86.698279 | POINT (-86.69828 33.42258) |
| 4 | Alabama | Cullman | 1821 Cherokee Ave SW Cullman, AL 35055 US | 34.154134 | -86.841220 | POINT (-86.84122 34.15413) |
In [ ]:
states = geopandas.read_file('usa-states-census-2014.shp')
fig, ax = plt.subplots(figsize= (14, 8))
states.plot(ax=ax, edgecolor='lightgrey', linewidth=1.5, cmap='BuGn')
gdf.plot(ax=ax, marker= ',', markersize=10, color='crimson')
ax.set_facecolor('#a2d2ff')
plt.show()
In [ ]: