Created
May 11, 2022 10:39
-
-
Save avriiil/fa1c31b7e331f068351556f1680abcc2 to your computer and use it in GitHub Desktop.
Create Interactive Maps with GeoPandas
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import geopandas as gpd | |
from geopandas import points_from_xy | |
from shapely.geometry import Point | |
# read in raw taxi data | |
df = pd.read_csv( | |
"s3://nyc-tlc/trip data/yellow_tripdata_2012-01.csv", | |
nrows=100_000, | |
) | |
# turn into geopandas dataframe | |
taxi_gdf = gpd.GeoDataFrame( | |
df, | |
crs="EPSG:4326", | |
geometry=points_from_xy(df["pickup_longitude"], df["pickup_latitude"]), | |
) | |
# interactively explore geodataframe (in Jupyter Notebook or equivalent) | |
taxi_gdf.explore( | |
tiles="CartoDB positron", # use "CartoDB positron" tiles | |
cmap="Set1", # use "Set1" matplotlib colormap | |
style_kwds=dict(color="black"), # use black outline | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment