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 '/Users/runner/Library/Caches/geodatasets'.
Extracting 'chicago_commpop/chicago_commpop.geojson' from '/Users/runner/Library/Caches/geodatasets/chicago_commpop.zip' to '/Users/runner/Library/Caches/geodatasets/chicago_commpop.zip.unzip'
community NID POP2010 POP2000 POPCH POPPERCH popplus popneg geometry
51 HEGEWISCH 55 9426 9781 -355 -3.629486 0 1 MULTIPOLYGON (((-87.52462 41.6918, -87.52465 4...
24 WEST TOWN 24 81432 87435 -6003 -6.865672 0 1 MULTIPOLYGON (((-87.65686 41.91078, -87.65685 ...
27 EAST GARFIELD PARK 27 20567 20881 -314 -1.503759 0 1 MULTIPOLYGON (((-87.69157 41.8882, -87.68968 4...
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.