I have polygons with lat/long values associated with identifiers in a GeoDataFrame
as shown below. Consider an example with two identifiers A
and B
, polygon A
has three points and B
has four points, their lat/long values are as shown below. Corresponding to each point (lat/long), I also have an associated numeric value as shown in the last column.
id geometry values
A POLYGON((lat_A_1 long_A_1, lat_A_2 long_A_2, lat_A_3 long_A_3)) 10,12,13
B POLYGON((lat_B_1 long_B_1, lat_B_2 long_B_2, lat_B_3 long_B_3, lat_B_4 long_B_4)) 4,8,16,20
I iterate over the GeoDataFrame and plot these polygons on the map using this code
geo_j = folium.GeoJson(data=geo_j,
style_function={
'fillColor': 'blue'
})
Is there a way that I can fill the polygon with a custom colormap based on the column values
in the GeoDataFrame, such as red for 0-5, blue for 6-10 and green for 11-20. How can this be done?
Best Answer
this is the solution that I came up with: