Quadtree of NYC traffic collisions

This example plots traffic collisions in New York City. Overlaying a pointplot on a quadtree like this communicates information on two visual channels, position and texture, simultaneously.



/Users/alekseybilogur/opt/miniconda3/envs/geoplot-dev/lib/python3.8/site-packages/geopandas/geoseries.py:318: UserWarning: GeoSeries.isna() previously returned True for both missing (None) and empty geometries. Now, it only returns True for missing values. Since the calling GeoSeries contains empty geometries, the result has changed compared to previous versions of GeoPandas.
Given a GeoSeries 's', you can use 's.is_empty | s.isna()' to get back the old behaviour.

To further ignore this warning, you can do:
import warnings; warnings.filterwarnings('ignore', 'GeoSeries.isna', UserWarning)
  return self.isna()

import geopandas as gpd
import geoplot as gplt
import geoplot.crs as gcrs
import matplotlib.pyplot as plt

nyc_boroughs = gpd.read_file(gplt.datasets.get_path('nyc_boroughs'))
collisions = gpd.read_file(gplt.datasets.get_path('nyc_collision_factors'))

ax = gplt.quadtree(
    collisions, nmax=1,
    projection=gcrs.AlbersEqualArea(), clip=nyc_boroughs,
    facecolor='lightgray', edgecolor='white', zorder=0
gplt.pointplot(collisions, s=1, ax=ax)

plt.title("New York Ciy Traffic Collisions, 2016")
plt.savefig("nyc-collisions-quadtree.png", bbox_inches='tight', pad_inches=0)

Total running time of the script: ( 0 minutes 23.188 seconds)

Gallery generated by Sphinx-Gallery