Polygons#

import hvplot.pandas  # noqa

Using hvplot with geopandas is as simple as loading a geopandas dataframe and calling hvplot on it with geo=True.

import geodatasets
import geopandas as gpd

chicago = gpd.read_file(geodatasets.get_path("geoda.chicago_commpop"))
chicago.sample(3)
Downloading file 'chicago_commpop.zip' from 'https://geodacenter.github.io/data-and-lab//data/chicago_commpop.zip' to '/home/runner/.cache/geodatasets'.
Extracting 'chicago_commpop/chicago_commpop.geojson' from '/home/runner/.cache/geodatasets/chicago_commpop.zip' to '/home/runner/.cache/geodatasets/chicago_commpop.zip.unzip'
community NID POP2010 POP2000 POPCH POPPERCH popplus popneg geometry
58 NEW CITY 61 44377 51721 -7344 -14.199261 0 1 MULTIPOLYGON (((-87.63546 41.79448, -87.63599 ...
53 ARCHER HEIGHTS 57 13393 12644 749 5.923758 1 0 MULTIPOLYGON (((-87.71437 41.82604, -87.71436 ...
60 GAGE PARK 63 39894 39193 701 1.788585 1 0 MULTIPOLYGON (((-87.67882 41.79387, -87.67882 ...
chicago.hvplot(geo=True)

Control the color of the elements using the c option.

chicago.hvplot.polygons(geo=True, c='POP2010', hover_cols='all')

You can even color by another series, such as population density:

chicago.hvplot.polygons(
    geo=True,
    c=chicago.POP2010/chicago.to_crs('EPSG:32616').area,
    clabel='pop density',
)
This web page was generated from a Jupyter notebook and not all interactivity will work on this website.