pixel-map 0.1.2__tar.gz → 0.2.2__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.
- pixel_map-0.2.2/PKG-INFO +235 -0
- pixel_map-0.2.2/README.md +201 -0
- {pixel_map-0.1.2 → pixel_map-0.2.2}/pixel_map/__init__.py +1 -1
- pixel_map-0.2.2/pixel_map/__main__.py +329 -0
- {pixel_map-0.1.2 → pixel_map-0.2.2}/pixel_map/plotter.py +134 -72
- {pixel_map-0.1.2 → pixel_map-0.2.2}/pyproject.toml +22 -2
- {pixel_map-0.1.2 → pixel_map-0.2.2}/tests/test_bbox.py +2 -2
- pixel_map-0.2.2/tests/test_cli.py +119 -0
- pixel_map-0.1.2/PKG-INFO +0 -19
- pixel_map-0.1.2/README.md +0 -1
- pixel_map-0.1.2/pixel_map/__main__.py +0 -170
- {pixel_map-0.1.2 → pixel_map-0.2.2}/LICENSE +0 -0
- {pixel_map-0.1.2 → pixel_map-0.2.2}/pixel_map/example_files/london_buildings.parquet +0 -0
- {pixel_map-0.1.2 → pixel_map-0.2.2}/pixel_map/example_files/london_park.parquet +0 -0
- {pixel_map-0.1.2 → pixel_map-0.2.2}/pixel_map/example_files/london_water.parquet +0 -0
- {pixel_map-0.1.2 → pixel_map-0.2.2}/pixel_map/example_files/monaco_buildings.parquet +0 -0
- {pixel_map-0.1.2 → pixel_map-0.2.2}/pixel_map/renderers.py +0 -0
- {pixel_map-0.1.2 → pixel_map-0.2.2}/tests/__init__.py +0 -0
pixel_map-0.2.2/PKG-INFO
ADDED
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: pixel-map
|
|
3
|
+
Version: 0.2.2
|
|
4
|
+
Summary: A Python CLI tool for plotting geo files in the terminal
|
|
5
|
+
Author-Email: Kamil Raczycki <kraczycki@kraina.ai>
|
|
6
|
+
License: MIT
|
|
7
|
+
Classifier: Development Status :: 3 - Alpha
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Topic :: Scientific/Engineering :: GIS
|
|
10
|
+
Classifier: Intended Audience :: Science/Research
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Operating System :: Unix
|
|
18
|
+
Classifier: Operating System :: MacOS
|
|
19
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
20
|
+
Project-URL: Homepage, https://github.com/RaczeQ/pixel-map
|
|
21
|
+
Project-URL: Repository, https://github.com/RaczeQ/pixel-map
|
|
22
|
+
Project-URL: Changelog, https://github.com/RaczeQ/pixel-map/blob/main/CHANGELOG.md
|
|
23
|
+
Requires-Python: >=3.9
|
|
24
|
+
Requires-Dist: rich>=12.0.0
|
|
25
|
+
Requires-Dist: typer[all]>=0.9.0
|
|
26
|
+
Requires-Dist: img2unicode[n2]>=0.1a11; sys_platform != "win32" and sys_platform != "darwin"
|
|
27
|
+
Requires-Dist: img2unicode>=0.1a11; sys_platform == "win32" or sys_platform == "darwin"
|
|
28
|
+
Requires-Dist: geopandas>=0.6
|
|
29
|
+
Requires-Dist: numpy>=1.26.0
|
|
30
|
+
Requires-Dist: contextily>=1
|
|
31
|
+
Requires-Dist: matplotlib>=3.2.0
|
|
32
|
+
Requires-Dist: pyarrow>=16.0.0
|
|
33
|
+
Description-Content-Type: text/markdown
|
|
34
|
+
|
|
35
|
+
# pixel-map
|
|
36
|
+
|
|
37
|
+
Python CLI tool for plotting geo data in the terminal
|
|
38
|
+
|
|
39
|
+
<p align="center">
|
|
40
|
+
<img src="https://raw.githubusercontent.com/RaczeQ/pixel-map/main/images/pixel-map-monaco.jpg"><br/>
|
|
41
|
+
</p>
|
|
42
|
+
|
|
43
|
+
<p align="center">
|
|
44
|
+
<img alt="GitHub" src="https://img.shields.io/github/license/raczeq/pixel-map?logo=mit&logoColor=%23fff">
|
|
45
|
+
<img src="https://img.shields.io/github/checks-status/raczeq/pixel-map/main?logo=GitHubActions&logoColor=%23fff" alt="Checks">
|
|
46
|
+
<a href="https://github.com/raczeq/pixel-map/actions/workflows/ci-prod.yml" target="_blank">
|
|
47
|
+
<img alt="GitHub Workflow Status - PROD" src="https://img.shields.io/github/actions/workflow/status/raczeq/pixel-map/ci-prod.yml?label=build-prod&logo=GitHubActions&logoColor=%23fff">
|
|
48
|
+
</a>
|
|
49
|
+
<a href="https://results.pre-commit.ci/latest/github/raczeq/pixel-map/main" target="_blank">
|
|
50
|
+
<img src="https://results.pre-commit.ci/badge/github/raczeq/pixel-map/main.svg" alt="pre-commit.ci status">
|
|
51
|
+
</a>
|
|
52
|
+
<a href="https://www.codefactor.io/repository/github/raczeq/pixel-map"><img alt="CodeFactor Grade" src="https://img.shields.io/codefactor/grade/github/raczeq/pixel-map?logo=codefactor&logoColor=%23fff"></a>
|
|
53
|
+
<a href="https://app.codecov.io/gh/raczeq/pixel-map/tree/main"><img alt="Codecov" src="https://img.shields.io/codecov/c/github/raczeq/pixel-map?logo=codecov&token=PRS4E02ZX0&logoColor=%23fff"></a>
|
|
54
|
+
<a href="https://pypi.org/project/pixel-map" target="_blank">
|
|
55
|
+
<img src="https://img.shields.io/pypi/v/pixel-map?color=%2334D058&label=pypi%20package&logo=pypi&logoColor=%23fff" alt="Package version">
|
|
56
|
+
</a>
|
|
57
|
+
<a href="https://pypi.org/project/pixel-map" target="_blank">
|
|
58
|
+
<img src="https://img.shields.io/pypi/pyversions/pixel-map.svg?color=%2334D058&logo=python&logoColor=%23fff" alt="Supported Python versions">
|
|
59
|
+
</a>
|
|
60
|
+
<a href="https://pypi.org/project/pixel-map" target="_blank">
|
|
61
|
+
<img alt="PyPI - Downloads" src="https://img.shields.io/pypi/dm/pixel-map">
|
|
62
|
+
</a>
|
|
63
|
+
</p>
|
|
64
|
+
|
|
65
|
+
## Installation
|
|
66
|
+
|
|
67
|
+
PyPI:
|
|
68
|
+
|
|
69
|
+
```sh
|
|
70
|
+
$ pip install img2unicode
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
uv:
|
|
74
|
+
|
|
75
|
+
```sh
|
|
76
|
+
$ uv pip install img2unicode
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Usage
|
|
80
|
+
|
|
81
|
+
To display your data in the terminal, you can just pass a filename as an argument:
|
|
82
|
+
```sh
|
|
83
|
+
$ pixel-map <file_name>
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Tool can also display data for multiple files at once:
|
|
87
|
+
```sh
|
|
88
|
+
$ pixel-map <file_name_1> <file_name_2>
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
See more examples below ⬇️
|
|
92
|
+
|
|
93
|
+
<details>
|
|
94
|
+
<summary>CLI Help output (<code>pixel-map -h</code>)</summary>
|
|
95
|
+
|
|
96
|
+
```console
|
|
97
|
+
Usage: pixel-map [OPTIONS] FILES...
|
|
98
|
+
|
|
99
|
+
Plot the geo data into a terminal.
|
|
100
|
+
Generates a Matplotlib canvas that is rendered to an image and later transformed into a list of
|
|
101
|
+
unicode characters.
|
|
102
|
+
|
|
103
|
+
╭─ Arguments ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
|
|
104
|
+
│ * files FILES... List of files to display. Those could be any that can be opened by GeoPandas. [required] │
|
|
105
|
+
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
|
|
106
|
+
╭─ Options ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
|
|
107
|
+
│ --bbox -b BBOX Clip the map to a given bounding box. Expects 4 floating point numbers separated by commas. │
|
|
108
|
+
│ --renderer -r TEXT Renderer used for generating terminal output. Possible values: all, ascii, ascii-bw, block, braille, braille-bw, half, quad, │
|
|
109
|
+
│ space. │
|
|
110
|
+
│ [default: (block)] │
|
|
111
|
+
│ --dark --light Uses the predefined dark or light style. Can be overriden with user defined style. [default: dark] │
|
|
112
|
+
│ --color -c COLOR Pass color or list of colours per each geo file. │
|
|
113
|
+
│ --alpha,--opacity -a FLOAT Pass opacity or list of opacities per each geo file. │
|
|
114
|
+
│ --basemap,--tileset -t TILES Set the basemap provider. Can be any value parsed by xyzservices library. Defaults to CartoDB.DarkMatterNoLabels if --dark │
|
|
115
|
+
│ or CartoDB.PositronNoLabels if --light. │
|
|
116
|
+
│ --no-border,--fullscreen -f Removes the border around the map. │
|
|
117
|
+
│ --no-background,--no-bg Removes the background of the map and plots only geo data. │
|
|
118
|
+
│ --background-color,--bg-color COLOR Set the background color. Can be used together with --no-background. │
|
|
119
|
+
│ --width INT Override the current console width. │
|
|
120
|
+
│ --height INT Override the current console height. │
|
|
121
|
+
│ --dpi INT DPI used to get better quality matplotlib plot before rendering to terminal. [default: 10] │
|
|
122
|
+
│ --example,--example-files Can be used to load one of example files based on name. Possible values: london_buildings, london_park, london_water, │
|
|
123
|
+
│ monaco_buildings. │
|
|
124
|
+
│ --version -v Show the application's version and exit. │
|
|
125
|
+
│ --install-completion Install completion for the current shell. │
|
|
126
|
+
│ --show-completion Show completion for the current shell, to copy it or customize the installation. │
|
|
127
|
+
│ --help -h Show this message and exit. │
|
|
128
|
+
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
|
|
129
|
+
```
|
|
130
|
+
</details>
|
|
131
|
+
|
|
132
|
+
## Examples
|
|
133
|
+
|
|
134
|
+
`pixel-map` is published with few example files for testing.
|
|
135
|
+
|
|
136
|
+
#### Basic usage
|
|
137
|
+
|
|
138
|
+
```sh
|
|
139
|
+
$ pixel-map --example london_buildings
|
|
140
|
+
```
|
|
141
|
+
<p align="center">
|
|
142
|
+
<img src="https://raw.githubusercontent.com/RaczeQ/pixel-map/main/images/london_dark.jpg"><br/>
|
|
143
|
+
</p>
|
|
144
|
+
|
|
145
|
+
#### Light mode
|
|
146
|
+
|
|
147
|
+
```sh
|
|
148
|
+
$ pixel-map --example london_buildings --light
|
|
149
|
+
```
|
|
150
|
+
<p align="center">
|
|
151
|
+
<img src="https://raw.githubusercontent.com/RaczeQ/pixel-map/main/images/london_light.jpg"><br/>
|
|
152
|
+
</p>
|
|
153
|
+
|
|
154
|
+
#### Multiple files with different colors
|
|
155
|
+
|
|
156
|
+
```sh
|
|
157
|
+
$ pixel-map --example london_buildings london_water london_park -c C1,C0,C2
|
|
158
|
+
```
|
|
159
|
+
<p align="center">
|
|
160
|
+
<img src="https://raw.githubusercontent.com/RaczeQ/pixel-map/main/images/london_multiple.jpg"><br/>
|
|
161
|
+
</p>
|
|
162
|
+
|
|
163
|
+
#### Different basemap and changed opacity (alpha)
|
|
164
|
+
|
|
165
|
+
```sh
|
|
166
|
+
$ pixel-map --example london_water -c C0 -a 0.6 -t Esri.WorldImagery
|
|
167
|
+
```
|
|
168
|
+
<p align="center">
|
|
169
|
+
<img src="https://raw.githubusercontent.com/RaczeQ/pixel-map/main/images/london_satellite.jpg"><br/>
|
|
170
|
+
</p>
|
|
171
|
+
|
|
172
|
+
#### No background and different renderer
|
|
173
|
+
|
|
174
|
+
You can explore multiple available renderers. Full list available in the `pixel-map` CLI help.
|
|
175
|
+
|
|
176
|
+
```sh
|
|
177
|
+
$ pixel-map --example london_buildings --no-bg -r ascii-bw
|
|
178
|
+
```
|
|
179
|
+
<p align="center">
|
|
180
|
+
<img src="https://raw.githubusercontent.com/RaczeQ/pixel-map/main/images/london_ascii.jpg"><br/>
|
|
181
|
+
</p>
|
|
182
|
+
|
|
183
|
+
## Dependencies
|
|
184
|
+
|
|
185
|
+
- `typer[all] (>=0.9.0)` (click, colorama, rich, shellingham): Required for CLI
|
|
186
|
+
|
|
187
|
+
- `rich (>=12.0.0)`: For showing progress and generating terminal output
|
|
188
|
+
|
|
189
|
+
- `geopandas (>=0.6)`: For reading Geo files and plotting
|
|
190
|
+
|
|
191
|
+
- `pyarrow (>=16.0.0)`: For geoparquet files support
|
|
192
|
+
|
|
193
|
+
- `matplotlib (>=3.2.0)`: For generating the plot with styling and cropping
|
|
194
|
+
|
|
195
|
+
- `contextily (>=1)`: For adding basemap to the plot
|
|
196
|
+
|
|
197
|
+
- `numpy (>=1.26.0)`: For transforming matplotlib array into an image
|
|
198
|
+
|
|
199
|
+
- `img2unicode[n2] (>=0.1a11)`: For transforming generated plot image into a list of unicode characters for the terminal
|
|
200
|
+
|
|
201
|
+
## How does it work?
|
|
202
|
+
|
|
203
|
+
1. Files are read by `GeoPandas` to GeoSerieses.
|
|
204
|
+
2. `Matplotlib` figure is created with the size of the terminal (`pixel-map` expects a default monospace font with the ratio of 8 to 16 pixels. Figure canvas takes terminal height and multiplies it by two).
|
|
205
|
+
3. GeoSerieses are plotted to the canvas.
|
|
206
|
+
4. Plot bounding box is expanded to the canvas ratio (based on terminal size).
|
|
207
|
+
5. Basemap is loaded with `contextily`.
|
|
208
|
+
6. Canvas is copied to the image as an `NumPy` array.
|
|
209
|
+
7. `img2unicode` is used to render image using unicode characters with color.
|
|
210
|
+
8. `Rich` string output is generated using the list of unicode characters with background and foreground colors.
|
|
211
|
+
9. Output is printed to the console.
|
|
212
|
+
|
|
213
|
+
## FAQ
|
|
214
|
+
|
|
215
|
+
- **Why does my terminal render visible characters in the output?**
|
|
216
|
+
|
|
217
|
+
Check if your terminal doesn't have automatic contrast changer for WCAG compatibility.
|
|
218
|
+
|
|
219
|
+
For example in VS Code there is an option `terminal.integrated.minimumContrastRatio` that is set to `4.5` by default.
|
|
220
|
+
|
|
221
|
+
| Contrast: 4.5 | Contrast: 1 |
|
|
222
|
+
| --- | --- |
|
|
223
|
+
|  |  |
|
|
224
|
+
|
|
225
|
+
- **Why are there black bars on the left/right, top/bottom of the output?**
|
|
226
|
+
|
|
227
|
+
This can happen when output is bigger than Earth bounding box and basemap doesn't cover that far, but image is stretched to the full terminal size.
|
|
228
|
+
|
|
229
|
+
## Contributing
|
|
230
|
+
|
|
231
|
+
If you want to contribute, please fork the repository, use `pdm` tool to install the project.
|
|
232
|
+
|
|
233
|
+
To run the tests you can use command `tox -e python3.12` (or other python version, `-e` is for the environment) or with simple `pytest tests`.
|
|
234
|
+
|
|
235
|
+
Please remember to update `CHANGELOG.md` with description your changes.
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
# pixel-map
|
|
2
|
+
|
|
3
|
+
Python CLI tool for plotting geo data in the terminal
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<img src="https://raw.githubusercontent.com/RaczeQ/pixel-map/main/images/pixel-map-monaco.jpg"><br/>
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<img alt="GitHub" src="https://img.shields.io/github/license/raczeq/pixel-map?logo=mit&logoColor=%23fff">
|
|
11
|
+
<img src="https://img.shields.io/github/checks-status/raczeq/pixel-map/main?logo=GitHubActions&logoColor=%23fff" alt="Checks">
|
|
12
|
+
<a href="https://github.com/raczeq/pixel-map/actions/workflows/ci-prod.yml" target="_blank">
|
|
13
|
+
<img alt="GitHub Workflow Status - PROD" src="https://img.shields.io/github/actions/workflow/status/raczeq/pixel-map/ci-prod.yml?label=build-prod&logo=GitHubActions&logoColor=%23fff">
|
|
14
|
+
</a>
|
|
15
|
+
<a href="https://results.pre-commit.ci/latest/github/raczeq/pixel-map/main" target="_blank">
|
|
16
|
+
<img src="https://results.pre-commit.ci/badge/github/raczeq/pixel-map/main.svg" alt="pre-commit.ci status">
|
|
17
|
+
</a>
|
|
18
|
+
<a href="https://www.codefactor.io/repository/github/raczeq/pixel-map"><img alt="CodeFactor Grade" src="https://img.shields.io/codefactor/grade/github/raczeq/pixel-map?logo=codefactor&logoColor=%23fff"></a>
|
|
19
|
+
<a href="https://app.codecov.io/gh/raczeq/pixel-map/tree/main"><img alt="Codecov" src="https://img.shields.io/codecov/c/github/raczeq/pixel-map?logo=codecov&token=PRS4E02ZX0&logoColor=%23fff"></a>
|
|
20
|
+
<a href="https://pypi.org/project/pixel-map" target="_blank">
|
|
21
|
+
<img src="https://img.shields.io/pypi/v/pixel-map?color=%2334D058&label=pypi%20package&logo=pypi&logoColor=%23fff" alt="Package version">
|
|
22
|
+
</a>
|
|
23
|
+
<a href="https://pypi.org/project/pixel-map" target="_blank">
|
|
24
|
+
<img src="https://img.shields.io/pypi/pyversions/pixel-map.svg?color=%2334D058&logo=python&logoColor=%23fff" alt="Supported Python versions">
|
|
25
|
+
</a>
|
|
26
|
+
<a href="https://pypi.org/project/pixel-map" target="_blank">
|
|
27
|
+
<img alt="PyPI - Downloads" src="https://img.shields.io/pypi/dm/pixel-map">
|
|
28
|
+
</a>
|
|
29
|
+
</p>
|
|
30
|
+
|
|
31
|
+
## Installation
|
|
32
|
+
|
|
33
|
+
PyPI:
|
|
34
|
+
|
|
35
|
+
```sh
|
|
36
|
+
$ pip install img2unicode
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
uv:
|
|
40
|
+
|
|
41
|
+
```sh
|
|
42
|
+
$ uv pip install img2unicode
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Usage
|
|
46
|
+
|
|
47
|
+
To display your data in the terminal, you can just pass a filename as an argument:
|
|
48
|
+
```sh
|
|
49
|
+
$ pixel-map <file_name>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Tool can also display data for multiple files at once:
|
|
53
|
+
```sh
|
|
54
|
+
$ pixel-map <file_name_1> <file_name_2>
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
See more examples below ⬇️
|
|
58
|
+
|
|
59
|
+
<details>
|
|
60
|
+
<summary>CLI Help output (<code>pixel-map -h</code>)</summary>
|
|
61
|
+
|
|
62
|
+
```console
|
|
63
|
+
Usage: pixel-map [OPTIONS] FILES...
|
|
64
|
+
|
|
65
|
+
Plot the geo data into a terminal.
|
|
66
|
+
Generates a Matplotlib canvas that is rendered to an image and later transformed into a list of
|
|
67
|
+
unicode characters.
|
|
68
|
+
|
|
69
|
+
╭─ Arguments ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
|
|
70
|
+
│ * files FILES... List of files to display. Those could be any that can be opened by GeoPandas. [required] │
|
|
71
|
+
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
|
|
72
|
+
╭─ Options ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
|
|
73
|
+
│ --bbox -b BBOX Clip the map to a given bounding box. Expects 4 floating point numbers separated by commas. │
|
|
74
|
+
│ --renderer -r TEXT Renderer used for generating terminal output. Possible values: all, ascii, ascii-bw, block, braille, braille-bw, half, quad, │
|
|
75
|
+
│ space. │
|
|
76
|
+
│ [default: (block)] │
|
|
77
|
+
│ --dark --light Uses the predefined dark or light style. Can be overriden with user defined style. [default: dark] │
|
|
78
|
+
│ --color -c COLOR Pass color or list of colours per each geo file. │
|
|
79
|
+
│ --alpha,--opacity -a FLOAT Pass opacity or list of opacities per each geo file. │
|
|
80
|
+
│ --basemap,--tileset -t TILES Set the basemap provider. Can be any value parsed by xyzservices library. Defaults to CartoDB.DarkMatterNoLabels if --dark │
|
|
81
|
+
│ or CartoDB.PositronNoLabels if --light. │
|
|
82
|
+
│ --no-border,--fullscreen -f Removes the border around the map. │
|
|
83
|
+
│ --no-background,--no-bg Removes the background of the map and plots only geo data. │
|
|
84
|
+
│ --background-color,--bg-color COLOR Set the background color. Can be used together with --no-background. │
|
|
85
|
+
│ --width INT Override the current console width. │
|
|
86
|
+
│ --height INT Override the current console height. │
|
|
87
|
+
│ --dpi INT DPI used to get better quality matplotlib plot before rendering to terminal. [default: 10] │
|
|
88
|
+
│ --example,--example-files Can be used to load one of example files based on name. Possible values: london_buildings, london_park, london_water, │
|
|
89
|
+
│ monaco_buildings. │
|
|
90
|
+
│ --version -v Show the application's version and exit. │
|
|
91
|
+
│ --install-completion Install completion for the current shell. │
|
|
92
|
+
│ --show-completion Show completion for the current shell, to copy it or customize the installation. │
|
|
93
|
+
│ --help -h Show this message and exit. │
|
|
94
|
+
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
|
|
95
|
+
```
|
|
96
|
+
</details>
|
|
97
|
+
|
|
98
|
+
## Examples
|
|
99
|
+
|
|
100
|
+
`pixel-map` is published with few example files for testing.
|
|
101
|
+
|
|
102
|
+
#### Basic usage
|
|
103
|
+
|
|
104
|
+
```sh
|
|
105
|
+
$ pixel-map --example london_buildings
|
|
106
|
+
```
|
|
107
|
+
<p align="center">
|
|
108
|
+
<img src="https://raw.githubusercontent.com/RaczeQ/pixel-map/main/images/london_dark.jpg"><br/>
|
|
109
|
+
</p>
|
|
110
|
+
|
|
111
|
+
#### Light mode
|
|
112
|
+
|
|
113
|
+
```sh
|
|
114
|
+
$ pixel-map --example london_buildings --light
|
|
115
|
+
```
|
|
116
|
+
<p align="center">
|
|
117
|
+
<img src="https://raw.githubusercontent.com/RaczeQ/pixel-map/main/images/london_light.jpg"><br/>
|
|
118
|
+
</p>
|
|
119
|
+
|
|
120
|
+
#### Multiple files with different colors
|
|
121
|
+
|
|
122
|
+
```sh
|
|
123
|
+
$ pixel-map --example london_buildings london_water london_park -c C1,C0,C2
|
|
124
|
+
```
|
|
125
|
+
<p align="center">
|
|
126
|
+
<img src="https://raw.githubusercontent.com/RaczeQ/pixel-map/main/images/london_multiple.jpg"><br/>
|
|
127
|
+
</p>
|
|
128
|
+
|
|
129
|
+
#### Different basemap and changed opacity (alpha)
|
|
130
|
+
|
|
131
|
+
```sh
|
|
132
|
+
$ pixel-map --example london_water -c C0 -a 0.6 -t Esri.WorldImagery
|
|
133
|
+
```
|
|
134
|
+
<p align="center">
|
|
135
|
+
<img src="https://raw.githubusercontent.com/RaczeQ/pixel-map/main/images/london_satellite.jpg"><br/>
|
|
136
|
+
</p>
|
|
137
|
+
|
|
138
|
+
#### No background and different renderer
|
|
139
|
+
|
|
140
|
+
You can explore multiple available renderers. Full list available in the `pixel-map` CLI help.
|
|
141
|
+
|
|
142
|
+
```sh
|
|
143
|
+
$ pixel-map --example london_buildings --no-bg -r ascii-bw
|
|
144
|
+
```
|
|
145
|
+
<p align="center">
|
|
146
|
+
<img src="https://raw.githubusercontent.com/RaczeQ/pixel-map/main/images/london_ascii.jpg"><br/>
|
|
147
|
+
</p>
|
|
148
|
+
|
|
149
|
+
## Dependencies
|
|
150
|
+
|
|
151
|
+
- `typer[all] (>=0.9.0)` (click, colorama, rich, shellingham): Required for CLI
|
|
152
|
+
|
|
153
|
+
- `rich (>=12.0.0)`: For showing progress and generating terminal output
|
|
154
|
+
|
|
155
|
+
- `geopandas (>=0.6)`: For reading Geo files and plotting
|
|
156
|
+
|
|
157
|
+
- `pyarrow (>=16.0.0)`: For geoparquet files support
|
|
158
|
+
|
|
159
|
+
- `matplotlib (>=3.2.0)`: For generating the plot with styling and cropping
|
|
160
|
+
|
|
161
|
+
- `contextily (>=1)`: For adding basemap to the plot
|
|
162
|
+
|
|
163
|
+
- `numpy (>=1.26.0)`: For transforming matplotlib array into an image
|
|
164
|
+
|
|
165
|
+
- `img2unicode[n2] (>=0.1a11)`: For transforming generated plot image into a list of unicode characters for the terminal
|
|
166
|
+
|
|
167
|
+
## How does it work?
|
|
168
|
+
|
|
169
|
+
1. Files are read by `GeoPandas` to GeoSerieses.
|
|
170
|
+
2. `Matplotlib` figure is created with the size of the terminal (`pixel-map` expects a default monospace font with the ratio of 8 to 16 pixels. Figure canvas takes terminal height and multiplies it by two).
|
|
171
|
+
3. GeoSerieses are plotted to the canvas.
|
|
172
|
+
4. Plot bounding box is expanded to the canvas ratio (based on terminal size).
|
|
173
|
+
5. Basemap is loaded with `contextily`.
|
|
174
|
+
6. Canvas is copied to the image as an `NumPy` array.
|
|
175
|
+
7. `img2unicode` is used to render image using unicode characters with color.
|
|
176
|
+
8. `Rich` string output is generated using the list of unicode characters with background and foreground colors.
|
|
177
|
+
9. Output is printed to the console.
|
|
178
|
+
|
|
179
|
+
## FAQ
|
|
180
|
+
|
|
181
|
+
- **Why does my terminal render visible characters in the output?**
|
|
182
|
+
|
|
183
|
+
Check if your terminal doesn't have automatic contrast changer for WCAG compatibility.
|
|
184
|
+
|
|
185
|
+
For example in VS Code there is an option `terminal.integrated.minimumContrastRatio` that is set to `4.5` by default.
|
|
186
|
+
|
|
187
|
+
| Contrast: 4.5 | Contrast: 1 |
|
|
188
|
+
| --- | --- |
|
|
189
|
+
|  |  |
|
|
190
|
+
|
|
191
|
+
- **Why are there black bars on the left/right, top/bottom of the output?**
|
|
192
|
+
|
|
193
|
+
This can happen when output is bigger than Earth bounding box and basemap doesn't cover that far, but image is stretched to the full terminal size.
|
|
194
|
+
|
|
195
|
+
## Contributing
|
|
196
|
+
|
|
197
|
+
If you want to contribute, please fork the repository, use `pdm` tool to install the project.
|
|
198
|
+
|
|
199
|
+
To run the tests you can use command `tox -e python3.12` (or other python version, `-e` is for the environment) or with simple `pytest tests`.
|
|
200
|
+
|
|
201
|
+
Please remember to update `CHANGELOG.md` with description your changes.
|