MCPcopy
hub / github.com/python-visualization/folium / Choropleth

Class Choropleth

folium/features.py:1411–1717  ·  view source on GitHub ↗

Apply a GeoJSON overlay to the map. Plot a GeoJSON overlay on the base map. There is no requirement to bind data (passing just a GeoJSON plots a single-color overlay), but there is a data binding option to map your columnar data to different feature objects with a color scale.

Source from the content-addressed store, hash-verified

1409
1410
1411class Choropleth(FeatureGroup):
1412 """Apply a GeoJSON overlay to the map.
1413
1414 Plot a GeoJSON overlay on the base map. There is no requirement
1415 to bind data (passing just a GeoJSON plots a single-color overlay),
1416 but there is a data binding option to map your columnar data to
1417 different feature objects with a color scale.
1418
1419 If data is passed as a Pandas DataFrame, the "columns" and "key-on"
1420 keywords must be included, the first to indicate which DataFrame
1421 columns to use, the second to indicate the layer in the GeoJSON
1422 on which to key the data. The 'columns' keyword does not need to be
1423 passed for a Pandas series.
1424
1425 Colors are generated from color brewer (https://colorbrewer2.org/)
1426 sequential palettes. By default, linear binning is used between
1427 the min and the max of the values. Custom binning can be achieved
1428 with the `bins` parameter.
1429
1430 TopoJSONs can be passed as "geo_data", but the "topojson" keyword must
1431 also be passed with the reference to the topojson objects to convert.
1432 See the topojson.feature method in the TopoJSON API reference:
1433 https://github.com/topojson/topojson/wiki/API-Reference
1434
1435
1436 Parameters
1437 ----------
1438 geo_data: string/object
1439 URL, file path, or data (json, dict, geopandas, etc) to your GeoJSON
1440 geometries
1441 data: Pandas DataFrame or Series, default None
1442 Data to bind to the GeoJSON.
1443 columns: tuple with two values, default None
1444 If the data is a Pandas DataFrame, the columns of data to be bound.
1445 Must pass column 1 as the key, and column 2 the values.
1446 key_on: string, default None
1447 Variable in the `geo_data` GeoJSON file to bind the data to. Must
1448 start with 'feature' and be in JavaScript objection notation.
1449 Ex: 'feature.id' or 'feature.properties.statename'.
1450 bins: int or sequence of scalars or str, default 6
1451 If `bins` is an int, it defines the number of equal-width
1452 bins between the min and the max of the values.
1453 If `bins` is a sequence, it directly defines the bin edges.
1454 For more information on this parameter, have a look at
1455 numpy.histogram function.
1456 fill_color: string, optional
1457 Area fill color, defaults to blue. Can pass a hex code, color name,
1458 or if you are binding data, one of the following color brewer palettes:
1459 'BuGn', 'BuPu', 'GnBu', 'OrRd', 'PuBu', 'PuBuGn', 'PuRd', 'RdPu',
1460 'YlGn', 'YlGnBu', 'YlOrBr', and 'YlOrRd'.
1461 nan_fill_color: string, default 'black'
1462 Area fill color for nan or missing values.
1463 Can pass a hex code, color name.
1464 fill_opacity: float, default 0.6
1465 Area fill opacity, range 0-1.
1466 nan_fill_opacity: float, default fill_opacity
1467 Area fill opacity for nan or missing values, range 0-1.
1468 line_color: string, default 'black'

Calls

no outgoing calls