geovizpy 0.1.3__tar.gz → 0.1.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- geovizpy-0.1.5/PKG-INFO +117 -0
- geovizpy-0.1.5/README.md +95 -0
- geovizpy-0.1.5/geovizpy/__init__.py +7 -0
- geovizpy-0.1.5/geovizpy/controls.py +31 -0
- geovizpy-0.1.5/geovizpy/effects.py +48 -0
- geovizpy-0.1.5/geovizpy/geoviz.py +43 -0
- geovizpy-0.1.5/geovizpy/legends.py +60 -0
- geovizpy-0.1.5/geovizpy/marks.py +184 -0
- geovizpy-0.1.5/geovizpy/plots.py +86 -0
- geovizpy-0.1.5/geovizpy/renderer.py +363 -0
- geovizpy-0.1.5/geovizpy.egg-info/PKG-INFO +117 -0
- geovizpy-0.1.5/geovizpy.egg-info/SOURCES.txt +15 -0
- geovizpy-0.1.5/geovizpy.egg-info/requires.txt +3 -0
- {geovizpy-0.1.3 → geovizpy-0.1.5}/setup.py +8 -3
- geovizpy-0.1.3/PKG-INFO +0 -46
- geovizpy-0.1.3/README.md +0 -27
- geovizpy-0.1.3/geovizpy/__init__.py +0 -253
- geovizpy-0.1.3/geovizpy.egg-info/PKG-INFO +0 -46
- geovizpy-0.1.3/geovizpy.egg-info/SOURCES.txt +0 -7
- {geovizpy-0.1.3 → geovizpy-0.1.5}/geovizpy.egg-info/dependency_links.txt +0 -0
- {geovizpy-0.1.3 → geovizpy-0.1.5}/geovizpy.egg-info/top_level.txt +0 -0
- {geovizpy-0.1.3 → geovizpy-0.1.5}/setup.cfg +0 -0
geovizpy-0.1.5/PKG-INFO
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: geovizpy
|
|
3
|
+
Version: 0.1.5
|
|
4
|
+
Summary: A Python wrapper for the geoviz JavaScript library
|
|
5
|
+
Author: fbxyz
|
|
6
|
+
Project-URL: Source, https://codeberg.org/fbxyz/geovizpy
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3.6
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
Provides-Extra: export
|
|
13
|
+
Requires-Dist: playwright; extra == "export"
|
|
14
|
+
Dynamic: author
|
|
15
|
+
Dynamic: classifier
|
|
16
|
+
Dynamic: description
|
|
17
|
+
Dynamic: description-content-type
|
|
18
|
+
Dynamic: project-url
|
|
19
|
+
Dynamic: provides-extra
|
|
20
|
+
Dynamic: requires-python
|
|
21
|
+
Dynamic: summary
|
|
22
|
+
|
|
23
|
+
# geovizpy
|
|
24
|
+
|
|
25
|
+
**geovizpy** is a Python wrapper for the `geoviz` JavaScript library, designed to bring the power of D3.js-based thematic mapping to Python. It allows you to create high-quality, interactive maps directly from Python scripts or Jupyter notebooks.
|
|
26
|
+
|
|
27
|
+
This library is a wrapper around the excellent `geoviz` library. For detailed information on the underlying mapping logic, please refer to the [original geoviz documentation](https://github.com/neocarto/geoviz).
|
|
28
|
+
|
|
29
|
+
## Features
|
|
30
|
+
|
|
31
|
+
- **Simple, chainable API**: Build complex maps by chaining intuitive methods.
|
|
32
|
+
- **Variety of Map Types**: Create choropleth, proportional symbol, typology, and other thematic maps.
|
|
33
|
+
- **Interactive Controls**: Add hover-to-expand controls for toggling layer visibility and exporting the map as SVG or PNG.
|
|
34
|
+
- **Customizable**: Extensive options to customize colors, legends, strokes, and more.
|
|
35
|
+
- **Standalone HTML**: Renders self-contained HTML files with no server required.
|
|
36
|
+
- **Image Export**: Save maps directly to PNG or SVG from Python (requires optional dependencies).
|
|
37
|
+
|
|
38
|
+
## Installation
|
|
39
|
+
|
|
40
|
+
### Standard Installation
|
|
41
|
+
|
|
42
|
+
You can install the core library using pip:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pip install geovizpy
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Or install directly from the source repository:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
pip install git+https://codeberg.org/fbxyz/geovizpy.git
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### For Image Export
|
|
55
|
+
|
|
56
|
+
To save maps as PNG or SVG files directly from Python, you need to install the optional `export` dependencies, which include `playwright`.
|
|
57
|
+
|
|
58
|
+
1. **Install the extra dependencies:**
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
pip install "geovizpy[export]"
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
2. **Install Playwright's browser binaries:**
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
playwright install
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
On Linux, you may also need to install host dependencies:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
sudo playwright install-deps
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Quick Start
|
|
77
|
+
|
|
78
|
+
Here is a simple example of how to create a choropleth map:
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
from geovizpy import Geoviz
|
|
82
|
+
import json
|
|
83
|
+
|
|
84
|
+
# Load your GeoJSON data
|
|
85
|
+
# (Assuming 'world.json' is in a 'data' subdirectory)
|
|
86
|
+
with open("data/world.json") as f:
|
|
87
|
+
world_data = json.load(f)
|
|
88
|
+
|
|
89
|
+
# Initialize the map
|
|
90
|
+
viz = Geoviz(projection="EqualEarth", width=800)
|
|
91
|
+
|
|
92
|
+
# Add layers
|
|
93
|
+
viz.outline()
|
|
94
|
+
viz.graticule()
|
|
95
|
+
|
|
96
|
+
# Add a choropleth layer
|
|
97
|
+
viz.choro(
|
|
98
|
+
data=world_data,
|
|
99
|
+
var="gdppc",
|
|
100
|
+
colors="Blues",
|
|
101
|
+
legend=True,
|
|
102
|
+
leg_title="GDP per Capita"
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
# Add interactive controls
|
|
106
|
+
viz.add_layer_control(layers=["choropleth_gdp"])
|
|
107
|
+
viz.add_export_control()
|
|
108
|
+
|
|
109
|
+
# Save the map
|
|
110
|
+
viz.save("my_map.html") # Renders an interactive HTML file
|
|
111
|
+
# viz.save("my_map.png") # Renders a static PNG image (requires export dependencies)
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Documentation
|
|
115
|
+
|
|
116
|
+
For more detailed information on all available methods and parameters, please see the [full documentation](https://your-username.github.io/geovizpy/).
|
|
117
|
+
|
geovizpy-0.1.5/README.md
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# geovizpy
|
|
2
|
+
|
|
3
|
+
**geovizpy** is a Python wrapper for the `geoviz` JavaScript library, designed to bring the power of D3.js-based thematic mapping to Python. It allows you to create high-quality, interactive maps directly from Python scripts or Jupyter notebooks.
|
|
4
|
+
|
|
5
|
+
This library is a wrapper around the excellent `geoviz` library. For detailed information on the underlying mapping logic, please refer to the [original geoviz documentation](https://github.com/neocarto/geoviz).
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **Simple, chainable API**: Build complex maps by chaining intuitive methods.
|
|
10
|
+
- **Variety of Map Types**: Create choropleth, proportional symbol, typology, and other thematic maps.
|
|
11
|
+
- **Interactive Controls**: Add hover-to-expand controls for toggling layer visibility and exporting the map as SVG or PNG.
|
|
12
|
+
- **Customizable**: Extensive options to customize colors, legends, strokes, and more.
|
|
13
|
+
- **Standalone HTML**: Renders self-contained HTML files with no server required.
|
|
14
|
+
- **Image Export**: Save maps directly to PNG or SVG from Python (requires optional dependencies).
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
### Standard Installation
|
|
19
|
+
|
|
20
|
+
You can install the core library using pip:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pip install geovizpy
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Or install directly from the source repository:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pip install git+https://codeberg.org/fbxyz/geovizpy.git
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### For Image Export
|
|
33
|
+
|
|
34
|
+
To save maps as PNG or SVG files directly from Python, you need to install the optional `export` dependencies, which include `playwright`.
|
|
35
|
+
|
|
36
|
+
1. **Install the extra dependencies:**
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pip install "geovizpy[export]"
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
2. **Install Playwright's browser binaries:**
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
playwright install
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
On Linux, you may also need to install host dependencies:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
sudo playwright install-deps
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Quick Start
|
|
55
|
+
|
|
56
|
+
Here is a simple example of how to create a choropleth map:
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
from geovizpy import Geoviz
|
|
60
|
+
import json
|
|
61
|
+
|
|
62
|
+
# Load your GeoJSON data
|
|
63
|
+
# (Assuming 'world.json' is in a 'data' subdirectory)
|
|
64
|
+
with open("data/world.json") as f:
|
|
65
|
+
world_data = json.load(f)
|
|
66
|
+
|
|
67
|
+
# Initialize the map
|
|
68
|
+
viz = Geoviz(projection="EqualEarth", width=800)
|
|
69
|
+
|
|
70
|
+
# Add layers
|
|
71
|
+
viz.outline()
|
|
72
|
+
viz.graticule()
|
|
73
|
+
|
|
74
|
+
# Add a choropleth layer
|
|
75
|
+
viz.choro(
|
|
76
|
+
data=world_data,
|
|
77
|
+
var="gdppc",
|
|
78
|
+
colors="Blues",
|
|
79
|
+
legend=True,
|
|
80
|
+
leg_title="GDP per Capita"
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
# Add interactive controls
|
|
84
|
+
viz.add_layer_control(layers=["choropleth_gdp"])
|
|
85
|
+
viz.add_export_control()
|
|
86
|
+
|
|
87
|
+
# Save the map
|
|
88
|
+
viz.save("my_map.html") # Renders an interactive HTML file
|
|
89
|
+
# viz.save("my_map.png") # Renders a static PNG image (requires export dependencies)
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Documentation
|
|
93
|
+
|
|
94
|
+
For more detailed information on all available methods and parameters, please see the [full documentation](https://your-username.github.io/geovizpy/).
|
|
95
|
+
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"""Module for interactive map controls."""
|
|
2
|
+
|
|
3
|
+
class ControlsMixin:
|
|
4
|
+
"""Mixin class for interactive map controls."""
|
|
5
|
+
|
|
6
|
+
def add_layer_control(self, layers=None, pos=None, x=10, y=10, title="Layers"):
|
|
7
|
+
"""
|
|
8
|
+
Add a collapsible layer control widget (expands on hover).
|
|
9
|
+
|
|
10
|
+
Args:
|
|
11
|
+
layers (list): List of layer IDs to control. If None, finds all layers with IDs.
|
|
12
|
+
pos (string): Predefined position ("top-right", "top-left", etc.). Overrides x, y.
|
|
13
|
+
x (int): X position of the control.
|
|
14
|
+
y (int): Y position of the control.
|
|
15
|
+
title (string): Title of the control panel.
|
|
16
|
+
"""
|
|
17
|
+
self.layer_control_config = {"layers": layers, "pos": pos, "x": x, "y": y, "title": title}
|
|
18
|
+
return self
|
|
19
|
+
|
|
20
|
+
def add_export_control(self, pos=None, x=10, y=50, title="Export"):
|
|
21
|
+
"""
|
|
22
|
+
Add a download button to export the map as SVG or PNG (expands on hover).
|
|
23
|
+
|
|
24
|
+
Args:
|
|
25
|
+
pos (string): Predefined position ("top-right", "top-left", etc.). Overrides x, y.
|
|
26
|
+
x (int): X position of the control.
|
|
27
|
+
y (int): Y position of the control.
|
|
28
|
+
title (string): Title of the button.
|
|
29
|
+
"""
|
|
30
|
+
self.export_control_config = {"pos": pos, "x": x, "y": y, "title": title}
|
|
31
|
+
return self
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"""Module for visual effects."""
|
|
2
|
+
|
|
3
|
+
class EffectsMixin:
|
|
4
|
+
"""Mixin class for visual effects."""
|
|
5
|
+
|
|
6
|
+
def effect_blur(self, **kwargs):
|
|
7
|
+
"""
|
|
8
|
+
Apply a blur effect.
|
|
9
|
+
|
|
10
|
+
Args:
|
|
11
|
+
id (string): ID of the effect.
|
|
12
|
+
stdDeviation (number): Standard deviation of the blur.
|
|
13
|
+
"""
|
|
14
|
+
return self._add_command("effect.blur", kwargs)
|
|
15
|
+
|
|
16
|
+
def effect_shadow(self, **kwargs):
|
|
17
|
+
"""
|
|
18
|
+
Apply a shadow effect.
|
|
19
|
+
|
|
20
|
+
Args:
|
|
21
|
+
id (string): ID of the effect.
|
|
22
|
+
dx (number): X offset.
|
|
23
|
+
dy (number): Y offset.
|
|
24
|
+
stdDeviation (number): Blur amount.
|
|
25
|
+
opacity (number): Opacity of the shadow.
|
|
26
|
+
color (string): Color of the shadow.
|
|
27
|
+
"""
|
|
28
|
+
return self._add_command("effect.shadow", kwargs)
|
|
29
|
+
|
|
30
|
+
def effect_radialGradient(self, **kwargs):
|
|
31
|
+
"""
|
|
32
|
+
Apply a radial gradient effect.
|
|
33
|
+
|
|
34
|
+
Args:
|
|
35
|
+
id (string): ID of the effect.
|
|
36
|
+
stops (list): List of stops (e.g., [{"offset": "0%", "color": "white"}, ...]).
|
|
37
|
+
"""
|
|
38
|
+
return self._add_command("effect.radialGradient", kwargs)
|
|
39
|
+
|
|
40
|
+
def effect_clipPath(self, **kwargs):
|
|
41
|
+
"""
|
|
42
|
+
Apply a clip path effect.
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
id (string): ID of the effect.
|
|
46
|
+
datum (object): GeoJSON to use as clip path.
|
|
47
|
+
"""
|
|
48
|
+
return self._add_command("effect.clipPath", kwargs)
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"""Main Geoviz class that assembles all modules."""
|
|
2
|
+
|
|
3
|
+
from .marks import MarksMixin
|
|
4
|
+
from .plots import PlotsMixin
|
|
5
|
+
from .legends import LegendsMixin
|
|
6
|
+
from .effects import EffectsMixin
|
|
7
|
+
from .controls import ControlsMixin
|
|
8
|
+
from .renderer import RendererMixin
|
|
9
|
+
|
|
10
|
+
class Geoviz(
|
|
11
|
+
MarksMixin,
|
|
12
|
+
PlotsMixin,
|
|
13
|
+
LegendsMixin,
|
|
14
|
+
EffectsMixin,
|
|
15
|
+
ControlsMixin,
|
|
16
|
+
RendererMixin
|
|
17
|
+
):
|
|
18
|
+
"""
|
|
19
|
+
A Python wrapper for the geoviz JavaScript library.
|
|
20
|
+
Allows creating maps by chaining commands and rendering them to an HTML file.
|
|
21
|
+
"""
|
|
22
|
+
def __init__(self, **kwargs):
|
|
23
|
+
"""
|
|
24
|
+
Initialize the Geoviz object.
|
|
25
|
+
|
|
26
|
+
Args:
|
|
27
|
+
width (int): Width of the SVG.
|
|
28
|
+
height (int): Height of the SVG.
|
|
29
|
+
margin (list): Margins [top, right, bottom, left].
|
|
30
|
+
domain (object): GeoJSON to define the domain.
|
|
31
|
+
projection (string): Projection name (e.g., "mercator", "EqualEarth").
|
|
32
|
+
zoomable (bool): If True, the map is zoomable.
|
|
33
|
+
background (string): Background color.
|
|
34
|
+
"""
|
|
35
|
+
self.commands = []
|
|
36
|
+
self.commands.append({"name": "create", "args": kwargs})
|
|
37
|
+
self.layer_control_config = None
|
|
38
|
+
self.export_control_config = None
|
|
39
|
+
|
|
40
|
+
def _add_command(self, name, args):
|
|
41
|
+
"""Add a command to the list of commands to be executed."""
|
|
42
|
+
self.commands.append({"name": name, "args": args})
|
|
43
|
+
return self
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"""Module for map legends."""
|
|
2
|
+
|
|
3
|
+
class LegendsMixin:
|
|
4
|
+
"""Mixin class for map legends."""
|
|
5
|
+
|
|
6
|
+
def legend_circles_nested(self, **kwargs):
|
|
7
|
+
"""Draw a nested circles legend."""
|
|
8
|
+
return self._add_command("legend.circles_nested", kwargs)
|
|
9
|
+
|
|
10
|
+
def legend_circles(self, **kwargs):
|
|
11
|
+
"""Draw a circles legend."""
|
|
12
|
+
return self._add_command("legend.circles", kwargs)
|
|
13
|
+
|
|
14
|
+
def legend_squares(self, **kwargs):
|
|
15
|
+
"""Draw a squares legend."""
|
|
16
|
+
return self._add_command("legend.squares", kwargs)
|
|
17
|
+
|
|
18
|
+
def legend_squares_nested(self, **kwargs):
|
|
19
|
+
"""Draw a nested squares legend."""
|
|
20
|
+
return self._add_command("legend.squares_nested", kwargs)
|
|
21
|
+
|
|
22
|
+
def legend_circles_half(self, **kwargs):
|
|
23
|
+
"""Draw a half-circles legend."""
|
|
24
|
+
return self._add_command("legend.circles_half", kwargs)
|
|
25
|
+
|
|
26
|
+
def legend_spikes(self, **kwargs):
|
|
27
|
+
"""Draw a spikes legend."""
|
|
28
|
+
return self._add_command("legend.spikes", kwargs)
|
|
29
|
+
|
|
30
|
+
def legend_mushrooms(self, **kwargs):
|
|
31
|
+
"""Draw a mushrooms legend."""
|
|
32
|
+
return self._add_command("legend.mushrooms", kwargs)
|
|
33
|
+
|
|
34
|
+
def legend_choro_vertical(self, **kwargs):
|
|
35
|
+
"""Draw a vertical choropleth legend."""
|
|
36
|
+
return self._add_command("legend.choro_vertical", kwargs)
|
|
37
|
+
|
|
38
|
+
def legend_choro_horizontal(self, **kwargs):
|
|
39
|
+
"""Draw a horizontal choropleth legend."""
|
|
40
|
+
return self._add_command("legend.choro_horizontal", kwargs)
|
|
41
|
+
|
|
42
|
+
def legend_typo_vertical(self, **kwargs):
|
|
43
|
+
"""Draw a vertical typology legend."""
|
|
44
|
+
return self._add_command("legend.typo_vertical", kwargs)
|
|
45
|
+
|
|
46
|
+
def legend_typo_horizontal(self, **kwargs):
|
|
47
|
+
"""Draw a horizontal typology legend."""
|
|
48
|
+
return self._add_command("legend.typo_horizontal", kwargs)
|
|
49
|
+
|
|
50
|
+
def legend_symbol_vertical(self, **kwargs):
|
|
51
|
+
"""Draw a vertical symbol legend."""
|
|
52
|
+
return self._add_command("legend.symbol_vertical", kwargs)
|
|
53
|
+
|
|
54
|
+
def legend_symbol_horizontal(self, **kwargs):
|
|
55
|
+
"""Draw a horizontal symbol legend."""
|
|
56
|
+
return self._add_command("legend.symbol_horizontal", kwargs)
|
|
57
|
+
|
|
58
|
+
def legend_box(self, **kwargs):
|
|
59
|
+
"""Draw a box legend."""
|
|
60
|
+
return self._add_command("legend.box", kwargs)
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
"""Module containing low-level drawing marks."""
|
|
2
|
+
|
|
3
|
+
class MarksMixin:
|
|
4
|
+
"""Mixin class for drawing marks on the map."""
|
|
5
|
+
|
|
6
|
+
def outline(self, **kwargs):
|
|
7
|
+
"""
|
|
8
|
+
Add an outline to the map (graticule sphere).
|
|
9
|
+
|
|
10
|
+
Args:
|
|
11
|
+
fill (string): Fill color.
|
|
12
|
+
stroke (string): Stroke color.
|
|
13
|
+
strokeWidth (number): Stroke width.
|
|
14
|
+
"""
|
|
15
|
+
return self._add_command("outline", kwargs)
|
|
16
|
+
|
|
17
|
+
def graticule(self, **kwargs):
|
|
18
|
+
"""
|
|
19
|
+
Add a graticule to the map.
|
|
20
|
+
|
|
21
|
+
Args:
|
|
22
|
+
stroke (string): Stroke color.
|
|
23
|
+
strokeWidth (number): Stroke width.
|
|
24
|
+
step (list): Step [x, y] in degrees.
|
|
25
|
+
"""
|
|
26
|
+
return self._add_command("graticule", kwargs)
|
|
27
|
+
|
|
28
|
+
def path(self, **kwargs):
|
|
29
|
+
"""
|
|
30
|
+
Draw a path (geometry) on the map.
|
|
31
|
+
|
|
32
|
+
Args:
|
|
33
|
+
datum (object): GeoJSON Feature or FeatureCollection.
|
|
34
|
+
fill (string): Fill color.
|
|
35
|
+
stroke (string): Stroke color.
|
|
36
|
+
strokeWidth (number): Stroke width.
|
|
37
|
+
"""
|
|
38
|
+
return self._add_command("path", kwargs)
|
|
39
|
+
|
|
40
|
+
def header(self, **kwargs):
|
|
41
|
+
"""
|
|
42
|
+
Add a header (title) to the map.
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
text (string): Title text.
|
|
46
|
+
fontSize (number): Font size.
|
|
47
|
+
fontFamily (string): Font family.
|
|
48
|
+
fill (string): Text color.
|
|
49
|
+
anchor (string): Text anchor ("start", "middle", "end").
|
|
50
|
+
"""
|
|
51
|
+
return self._add_command("header", kwargs)
|
|
52
|
+
|
|
53
|
+
def footer(self, **kwargs):
|
|
54
|
+
"""
|
|
55
|
+
Add a footer (source, author) to the map.
|
|
56
|
+
|
|
57
|
+
Args:
|
|
58
|
+
text (string): Footer text.
|
|
59
|
+
fontSize (number): Font size.
|
|
60
|
+
fill (string): Text color.
|
|
61
|
+
anchor (string): Text anchor.
|
|
62
|
+
"""
|
|
63
|
+
return self._add_command("footer", kwargs)
|
|
64
|
+
|
|
65
|
+
def circle(self, **kwargs):
|
|
66
|
+
"""
|
|
67
|
+
Draw circles on the map (low-level mark).
|
|
68
|
+
For proportional circles with legend, use prop().
|
|
69
|
+
|
|
70
|
+
Args:
|
|
71
|
+
data (object): GeoJSON FeatureCollection.
|
|
72
|
+
r (string|number): Radius value or property name.
|
|
73
|
+
fill (string): Fill color.
|
|
74
|
+
stroke (string): Stroke color.
|
|
75
|
+
tip (string|bool): Tooltip content.
|
|
76
|
+
"""
|
|
77
|
+
return self._add_command("circle", kwargs)
|
|
78
|
+
|
|
79
|
+
def square(self, **kwargs):
|
|
80
|
+
"""
|
|
81
|
+
Draw squares on the map (low-level mark).
|
|
82
|
+
For proportional squares with legend, use prop(symbol="square").
|
|
83
|
+
|
|
84
|
+
Args:
|
|
85
|
+
data (object): GeoJSON FeatureCollection.
|
|
86
|
+
side (string|number): Side length or property name.
|
|
87
|
+
fill (string): Fill color.
|
|
88
|
+
"""
|
|
89
|
+
return self._add_command("square", kwargs)
|
|
90
|
+
|
|
91
|
+
def spike(self, **kwargs):
|
|
92
|
+
"""
|
|
93
|
+
Draw spikes on the map (low-level mark).
|
|
94
|
+
|
|
95
|
+
Args:
|
|
96
|
+
data (object): GeoJSON FeatureCollection.
|
|
97
|
+
height (string|number): Height value or property name.
|
|
98
|
+
width (number): Width of the spike.
|
|
99
|
+
fill (string): Fill color.
|
|
100
|
+
"""
|
|
101
|
+
return self._add_command("spike", kwargs)
|
|
102
|
+
|
|
103
|
+
def text(self, **kwargs):
|
|
104
|
+
"""
|
|
105
|
+
Add text labels to the map.
|
|
106
|
+
|
|
107
|
+
Args:
|
|
108
|
+
data (object): GeoJSON FeatureCollection.
|
|
109
|
+
text (string): Property name for the text.
|
|
110
|
+
fontSize (number): Font size.
|
|
111
|
+
fill (string): Text color.
|
|
112
|
+
"""
|
|
113
|
+
return self._add_command("text", kwargs)
|
|
114
|
+
|
|
115
|
+
def tile(self, **kwargs):
|
|
116
|
+
"""
|
|
117
|
+
Add a tile layer (basemap).
|
|
118
|
+
|
|
119
|
+
Args:
|
|
120
|
+
url (string): URL template or keyword (e.g., "worldStreet", "openstreetmap").
|
|
121
|
+
opacity (number): Opacity (0 to 1).
|
|
122
|
+
"""
|
|
123
|
+
return self._add_command("tile", kwargs)
|
|
124
|
+
|
|
125
|
+
def scalebar(self, **kwargs):
|
|
126
|
+
"""
|
|
127
|
+
Add a scale bar.
|
|
128
|
+
|
|
129
|
+
Args:
|
|
130
|
+
x (number): X position.
|
|
131
|
+
y (number): Y position.
|
|
132
|
+
units (string): "km" or "mi".
|
|
133
|
+
"""
|
|
134
|
+
return self._add_command("scalebar", kwargs)
|
|
135
|
+
|
|
136
|
+
def north(self, **kwargs):
|
|
137
|
+
"""
|
|
138
|
+
Add a north arrow.
|
|
139
|
+
|
|
140
|
+
Args:
|
|
141
|
+
x (number): X position.
|
|
142
|
+
y (number): Y position.
|
|
143
|
+
width (number): Width of the arrow.
|
|
144
|
+
"""
|
|
145
|
+
return self._add_command("north", kwargs)
|
|
146
|
+
|
|
147
|
+
def plot(self, **kwargs):
|
|
148
|
+
"""
|
|
149
|
+
Generic plot function.
|
|
150
|
+
|
|
151
|
+
Args:
|
|
152
|
+
type (string): Type of plot ("choro", "prop", "typo", etc.).
|
|
153
|
+
data (object): GeoJSON data.
|
|
154
|
+
var (string): Variable to map.
|
|
155
|
+
"""
|
|
156
|
+
return self._add_command("plot", kwargs)
|
|
157
|
+
|
|
158
|
+
def tissot(self, **kwargs):
|
|
159
|
+
"""Draw Tissot's indicatrix to visualize distortion."""
|
|
160
|
+
return self._add_command("tissot", kwargs)
|
|
161
|
+
|
|
162
|
+
def rhumbs(self, **kwargs):
|
|
163
|
+
"""Draw rhumb lines."""
|
|
164
|
+
return self._add_command("rhumbs", kwargs)
|
|
165
|
+
|
|
166
|
+
def earth(self, **kwargs):
|
|
167
|
+
"""Draw the earth (background)."""
|
|
168
|
+
return self._add_command("earth", kwargs)
|
|
169
|
+
|
|
170
|
+
def empty(self, **kwargs):
|
|
171
|
+
"""Create an empty layer."""
|
|
172
|
+
return self._add_command("empty", kwargs)
|
|
173
|
+
|
|
174
|
+
def halfcircle(self, **kwargs):
|
|
175
|
+
"""Draw half-circles."""
|
|
176
|
+
return self._add_command("halfcircle", kwargs)
|
|
177
|
+
|
|
178
|
+
def symbol(self, **kwargs):
|
|
179
|
+
"""Draw symbols."""
|
|
180
|
+
return self._add_command("symbol", kwargs)
|
|
181
|
+
|
|
182
|
+
def grid(self, **kwargs):
|
|
183
|
+
"""Draw a grid."""
|
|
184
|
+
return self._add_command("grid", kwargs)
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"""Module for thematic map plots."""
|
|
2
|
+
|
|
3
|
+
class PlotsMixin:
|
|
4
|
+
"""Mixin class for thematic map plots."""
|
|
5
|
+
|
|
6
|
+
def choro(self, **kwargs):
|
|
7
|
+
"""
|
|
8
|
+
Draw a choropleth map.
|
|
9
|
+
|
|
10
|
+
Args:
|
|
11
|
+
data (object): GeoJSON FeatureCollection.
|
|
12
|
+
var (string): Variable name containing numeric values.
|
|
13
|
+
method (string): Classification method ('quantile', 'jenks', 'equal', etc.).
|
|
14
|
+
nb (int): Number of classes.
|
|
15
|
+
colors (string|list): Color palette name or list of colors.
|
|
16
|
+
legend (bool): Whether to show the legend (default: True).
|
|
17
|
+
leg_pos (list): Legend position [x, y].
|
|
18
|
+
leg_title (string): Legend title.
|
|
19
|
+
"""
|
|
20
|
+
return self._add_command("plot", {"type": "choro", **kwargs})
|
|
21
|
+
|
|
22
|
+
def typo(self, **kwargs):
|
|
23
|
+
"""
|
|
24
|
+
Draw a typology map (categorical data).
|
|
25
|
+
|
|
26
|
+
Args:
|
|
27
|
+
data (object): GeoJSON FeatureCollection.
|
|
28
|
+
var (string): Variable name containing categories.
|
|
29
|
+
colors (string|list): Color palette or list.
|
|
30
|
+
legend (bool): Show legend.
|
|
31
|
+
"""
|
|
32
|
+
return self._add_command("plot", {"type": "typo", **kwargs})
|
|
33
|
+
|
|
34
|
+
def prop(self, **kwargs):
|
|
35
|
+
"""
|
|
36
|
+
Draw a proportional symbol map.
|
|
37
|
+
|
|
38
|
+
Args:
|
|
39
|
+
data (object): GeoJSON FeatureCollection.
|
|
40
|
+
var (string): Variable name containing numeric values.
|
|
41
|
+
symbol (string): Symbol type ("circle", "square", "spike").
|
|
42
|
+
k (number): Size of the largest symbol.
|
|
43
|
+
fill (string): Fill color.
|
|
44
|
+
legend (bool): Show legend.
|
|
45
|
+
leg_type (string): Legend style ("nested", "separate").
|
|
46
|
+
"""
|
|
47
|
+
return self._add_command("plot", {"type": "prop", **kwargs})
|
|
48
|
+
|
|
49
|
+
def propchoro(self, **kwargs):
|
|
50
|
+
"""
|
|
51
|
+
Draw proportional symbols colored by a choropleth variable.
|
|
52
|
+
|
|
53
|
+
Args:
|
|
54
|
+
data (object): GeoJSON FeatureCollection.
|
|
55
|
+
var (string): Variable for symbol size.
|
|
56
|
+
var2 (string): Variable for color.
|
|
57
|
+
method (string): Classification method for color.
|
|
58
|
+
colors (string|list): Color palette.
|
|
59
|
+
"""
|
|
60
|
+
return self._add_command("plot", {"type": "propchoro", **kwargs})
|
|
61
|
+
|
|
62
|
+
def proptypo(self, **kwargs):
|
|
63
|
+
"""
|
|
64
|
+
Draw proportional symbols colored by categories.
|
|
65
|
+
|
|
66
|
+
Args:
|
|
67
|
+
data (object): GeoJSON FeatureCollection.
|
|
68
|
+
var (string): Variable for symbol size.
|
|
69
|
+
var2 (string): Variable for category color.
|
|
70
|
+
"""
|
|
71
|
+
return self._add_command("plot", {"type": "proptypo", **kwargs})
|
|
72
|
+
|
|
73
|
+
def picto(self, **kwargs):
|
|
74
|
+
"""Draw a pictogram map."""
|
|
75
|
+
return self._add_command("plot", {"type": "picto", **kwargs})
|
|
76
|
+
|
|
77
|
+
def bertin(self, **kwargs):
|
|
78
|
+
"""
|
|
79
|
+
Draw a Bertin map (dots).
|
|
80
|
+
|
|
81
|
+
Args:
|
|
82
|
+
data (object): GeoJSON FeatureCollection.
|
|
83
|
+
var (string): Variable name.
|
|
84
|
+
n (int): Number of dots per unit.
|
|
85
|
+
"""
|
|
86
|
+
return self._add_command("plot", {"type": "bertin", **kwargs})
|