foliumap module¶
Adds custom Map class that extends the folium Map class.
Map
¶
Bases: Map
A custom Map class that extends folium.Map.
Source code in landcalc/foliumap.py
10 11 12 13 14 15 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 56 57 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 120 121 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 |
|
__init__(center=(0, 0), zoom=2, **kwargs)
¶
Initializes the Map object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
center
|
tuple
|
The initial center of the map as (latitude, longitude). Defaults to (0, 0). |
(0, 0)
|
zoom
|
int
|
The initial zoom level of the map. Defaults to 2. |
2
|
**kwargs
|
Additional keyword arguments for the folium.Map class. |
{}
|
Source code in landcalc/foliumap.py
13 14 15 16 17 18 19 20 21 |
|
add_basemap(basemap='OpenStreetMap', **kwargs)
¶
Adds a basemap to the map using a known provider name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
basemap
|
str
|
The name of the basemap to add. |
'OpenStreetMap'
|
**kwargs
|
Additional keyword arguments for the folium.TileLayer. |
{}
|
Source code in landcalc/foliumap.py
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 |
|
add_gdf(gdf, **kwargs)
¶
Adds a GeoDataFrame to the map.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
gdf
|
GeoDataFrame
|
The GeoDataFrame to add. |
required |
**kwargs
|
Additional keyword arguments for the GeoJSON layer. |
{}
|
Source code in landcalc/foliumap.py
69 70 71 72 73 74 75 76 77 78 |
|
add_geojson(data, zoom_to_layer=True, hover_style=None, **kwargs)
¶
Adds a GeoJSON layer to the map.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
str or dict
|
The GeoJSON data. Can be a file path (str) or a dictionary. |
required |
zoom_to_layer
|
bool
|
Whether to zoom to the layer's bounds. Defaults to True. |
True
|
hover_style
|
dict
|
Style to apply when hovering over features. Defaults to {"color": "yellow", "fillOpacity": 0.2}. |
None
|
**kwargs
|
Additional keyword arguments for the folium.GeoJson layer. |
{}
|
Raises:
Type | Description |
---|---|
ValueError
|
If the data type is invalid. |
Source code in landcalc/foliumap.py
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 |
|
add_layer_control()
¶
Adds a layer control widget to the map.
Source code in landcalc/foliumap.py
102 103 104 |
|
add_shp(data, **kwargs)
¶
Adds a shapefile to the map.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
str
|
The file path to the shapefile. |
required |
**kwargs
|
Additional keyword arguments for the GeoJSON layer. |
{}
|
Source code in landcalc/foliumap.py
55 56 57 58 59 60 61 62 63 64 65 66 67 |
|
add_split_map(left='openstreetmap', right='cartodbpositron', **kwargs)
¶
Adds a split map to the map.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
left
|
str
|
The tile layer for the left side of the split map. Defaults to "openstreetmap". |
'openstreetmap'
|
right
|
str
|
The tile layer for the right side of the split map. Defaults to "cartodbpositron". |
'cartodbpositron'
|
Source code in landcalc/foliumap.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
|
add_vector(data, **kwargs)
¶
Adds vector data to the map.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
str, geopandas.GeoDataFrame, or dict
|
The vector data. Can be a file path, GeoDataFrame, or GeoJSON dictionary. |
required |
**kwargs
|
Additional keyword arguments for the GeoJSON layer. |
{}
|
Raises:
Type | Description |
---|---|
ValueError
|
If the data type is invalid. |
Source code in landcalc/foliumap.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
|