MESQUAL Folium Area Visualization System¶
viz_areas
¶
ResolvedAreaFeature
dataclass
¶
Bases: ResolvedFeature
Resolved visual properties for area/polygon map elements.
Container for all computed styling properties of polygon visualizations, including fill colors, border styles, and interactive behaviors. Used by AreaGenerator to create folium GeoJson polygons.
Source code in submodules/mesqual/mesqual/visualizations/folium_viz_system/viz_areas.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | |
AreaFeatureResolver
¶
Bases: FeatureResolver[ResolvedAreaFeature]
Resolves visual properties for polygon/area map elements.
Specialized feature resolver for area visualizations that handles polygon geometries, fill colors, border styling, and opacity settings. Commonly used for visualizing bidding zones, geographic regions, or any spatial areas with associated data values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fill_color
|
PropertyMapper | str
|
Area fill color (static value or PropertyMapper) |
'#D2D2D2'
|
border_color
|
PropertyMapper | str
|
Border/stroke color (static value or PropertyMapper) |
'white'
|
border_width
|
PropertyMapper | float
|
Border width in pixels (static value or PropertyMapper) |
2.0
|
fill_opacity
|
PropertyMapper | float
|
Fill transparency 0-1 (static value or PropertyMapper) |
0.8
|
highlight_border_width
|
PropertyMapper | float
|
Border width on hover (defaults to border_width) |
None
|
highlight_fill_opacity
|
PropertyMapper | float
|
Fill opacity on hover (defaults to 1.0) |
1.0
|
tooltip
|
PropertyMapper | str | bool
|
Tooltip content (True for auto-generated, False for none) |
True
|
popup
|
PropertyMapper | Popup | bool
|
Popup content (True/False/PropertyMapper) |
False
|
geometry
|
PropertyMapper | Polygon
|
Polygon geometry (defaults to 'geometry' attribute) |
None
|
**property_mappers
|
PropertyMapper | Any
|
Additional custom property mappings |
{}
|
Examples:
Basic area visualization:
>>> resolver = AreaFeatureResolver(
... fill_color='#FF0000',
... border_color='white',
... fill_opacity=0.8
... )
Data-driven coloring:
>>> color_scale = SegmentedContinuousColorscale(...)
>>> resolver = AreaFeatureResolver(
... fill_color=PropertyMapper.from_kpi_value(color_scale),
... fill_opacity=PropertyMapper.from_item_attr('confidence', lambda c: 0.3 + 0.6 * c)
... )
Source code in submodules/mesqual/mesqual/visualizations/folium_viz_system/viz_areas.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | |
AreaGenerator
¶
Bases: FoliumObjectGenerator[AreaFeatureResolver]
Generates folium GeoJson polygon objects for area visualizations.
Creates interactive map polygons from data items with computed styling properties. Handles polygon and multipolygon geometries, applies styling, and adds tooltips/popups for user interaction.
Commonly used for visualizing:
- Bidding zones colored by electricity prices
- Geographic regions sized by population or economic data
- Network areas colored by KPI values
- Administrative boundaries with associated statistics
Examples:
Basic usage pattern:
>>> color_scale = SegmentedContinuousColorscale(...)
>>> generator = AreaGenerator(
... AreaFeatureResolver(
... fill_color=PropertyMapper.from_kpi_value(color_scale),
... tooltip=True
... )
... )
>>> fg = folium.FeatureGroup('Bidding Zones')
>>> generator.generate_objects_for_kpi_collection(price_kpis, fg)
>>> fg.add_to(map)
Combined with other generators:
>>> # Areas for zones, lines for interconnectors
>>> area_gen = AreaGenerator(...)
>>> line_gen = LineGenerator(...)
>>>
>>> area_gen.generate_objects_for_model_df(zones_df, feature_group)
>>> line_gen.generate_objects_for_model_df(borders_df, feature_group)
Source code in submodules/mesqual/mesqual/visualizations/folium_viz_system/viz_areas.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | |
generate
¶
generate(data_item: VisualizableDataItem, feature_group: FeatureGroup) -> None
Generate and add a folium GeoJson polygon to the feature group.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data_item
|
VisualizableDataItem
|
Data item containing polygon geometry and associated data |
required |
feature_group
|
FeatureGroup
|
Folium feature group to add the polygon to |
required |
Source code in submodules/mesqual/mesqual/visualizations/folium_viz_system/viz_areas.py
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | |