lonboard
lonboard copied to clipboard
Integrate `mapclassify`
From the geopandas.plot docstring
Name of a choropleth classification scheme (requires mapclassify). A mapclassify.MapClassifier object will be used under the hood. Supported are all schemes provided by mapclassify (e.g. ‘BoxPlot’, ‘EqualInterval’, ‘FisherJenks’, ‘FisherJenksSampled’, ‘HeadTailBreaks’, ‘JenksCaspall’, ‘JenksCaspallForced’, ‘JenksCaspallSampled’, ‘MaxP’, ‘MaximumBreaks’, ‘NaturalBreaks’, ‘Quantiles’, ‘Percentiles’, ‘StdMean’, ‘UserDefined’). Arguments can be passed in classification_kwds.
The following worked for me:
import numpy
from lonboard import Map, SolidPolygonLayer
from mapclassify import JenksCaspall
layer = SolidPolygonLayer.from_geopandas(zones_interpolated, opacity=0.2)
jc = JenksCaspall(
zones_interpolated["ProductionAttractionSum Density"].fillna(0),
k=20
)
colors = []
for color in jc.yb:
colors.append(Viridis_20.colors[color])
layer.get_fill_color = numpy.uint8(colors)
Map(layers=[layer])
Thanks! By the way, I'm not sure where Viridis_20 comes from, but doing an array lookup would be much faster than a loop. You should probably be able to do something like
Viridis_20.colors[jc.yb]