pixel-map
Python CLI tool for plotting geo data in the terminal
Documentation · Examples · Basemaps · Renderers
Installation
PyPI:
$ pip install pixel-map
uv:
$ uv pip install pixel-map
Usage
To display your data in the terminal, you can just pass a filename as an argument:
$ pixel-map <file_name>
Tool can also display data for multiple files at once:
$ pixel-map <file_name_1> <file_name_2>
See more examples below ⬇️
CLI Help output (pixel-map -h)
Usage: pixel-map [OPTIONS] {files}...
Plot the geo data into a terminal.
Generates a Matplotlib canvas that is rendered to an image and later transformed into a list of
unicode characters.
╭─ Arguments ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ * files <str> List of files to display. Those could be any that can be opened by GeoPandas. [required] │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Options ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --bbox -b BBOX Clip the map to a given bounding box. Expects 4 floating point numbers separated by commas. │
│ --renderer -r <str> Renderer used for generating terminal output. Possible values: all, ascii, ascii-bw, block, braille, braille-bw, half, │
│ quad, space. │
│ [default: (block)] │
│ --dark --light Uses the predefined dark or light style. Can be overriden with user defined style. [default: dark] │
│ --color -c COLOR Pass color or list of colours per each geo file. │
│ --alpha,--opacity -a FLOAT Pass opacity or list of opacities per each geo file. │
│ --basemap,--tileset -t TILES Set the basemap. Can be a name of a basemaplibre style, or a URL or a path of a MapLibre style JSON. Raster tiles (like │
│ names of xyzservices) need contextily to be installed. Defaults to OpenFreeMap.Dark if --dark or OpenFreeMap.Positron if │
│ --light. │
│ --no-border,--fullscreen -f Removes the border around the map. │
│ --no-background,--no-bg Removes the background of the map and plots only geo data. │
│ --background-color,--bg-color COLOR Set the background color. Can be used together with --no-background. │
│ --width INT Override the current console width. │
│ --height INT Override the current console height. │
│ --dpi INT DPI used to rasterise the matplotlib plot. Setting this to 8 (matching the renderer's subpixel width) skips the PIL resize │
│ for a faster path; higher values improve anti-aliasing quality. │
│ [default: 8] │
│ --example,--example-files Can be used to load one of example files based on name. Possible values: london_buildings, london_park, london_water, │
│ monaco_buildings. │
│ --version -v Show the application's version and exit. │
│ --install-completion Install completion for the current shell. │
│ --show-completion Show completion for the current shell, to copy it or customize the installation. │
│ --help -h Show this message and exit. │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Examples
pixel-map is published with few example files for testing.
Basic usage
$ pixel-map --example london_buildings
Light mode
$ pixel-map --example london_buildings --light
Multiple files with different colors
$ pixel-map --example london_buildings london_water london_park -c C1,C0,C2
Different basemap and changed opacity (alpha)
$ pixel-map --example london_water -c C0 -a 0.6 -t VersaTiles.Satellite
No background and different renderer
You can explore multiple available renderers.
$ pixel-map --example london_buildings --no-bg -r ascii-bw
Dependencies
-
typer[all] (>=0.9.0)(click, colorama, rich, shellingham): Required for CLI -
rich (>=12.0.0): For showing progress and generating terminal output -
geopandas (>=0.8): For reading Geo files and plotting -
pyarrow (>=16.0.0): For geoparquet files support -
matplotlib (>=3.2.0): For generating the plot with styling and cropping -
basemaplibre (>=0.1.1): For adding basemap to the plot (raster tiles needcontextily, which is not installed by default) -
numpy (>=1.26.0): For transforming matplotlib array into an image -
pillow (>=10.1.0): For rasterising ASCII glyph templates and downscaling the canvas
How does it work?
- Files are read by
GeoPandasto GeoSerieses. Matplotlibfigure is created with the size of the terminal (pixel-mapexpects a default monospace font with the ratio of 8 to 16 pixels. Figure canvas takes terminal height and multiplies it by two).- GeoSerieses are plotted to the canvas.
- Plot bounding box is expanded to the canvas ratio (based on terminal size).
- Basemap is drawn with
basemaplibrefrom a MapLibre style, without labels. - Canvas is copied to the image as an
NumPyarray. - Image is downsampled and converted to a grid of Unicode characters with
foreground/background colours using the native dual-colour engine in
pixel_map/terminal_renderers.py(Lab perceptual distance, BLAS-accelerated character selection). Richstring output is generated using the list of unicode characters with background and foreground colors.- Output is printed to the console.
FAQ
-
Why does my terminal render visible characters in the output?
Check if your terminal doesn't have automatic contrast changer for WCAG compatibility.
For example in VS Code there is an option
terminal.integrated.minimumContrastRatiothat is set to4.5by default.Contrast: 4.5 Contrast: 1 -
Why are there black bars on the left/right, top/bottom of the output?
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.
Contributing
If you want to contribute, please fork the repository, use pdm tool to install the project.
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.
Please remember to update CHANGELOG.md with description your changes.
Metadata
Release files for pixel-map 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pixel_map-0.4.0.tar.gz | 379.2 kB | Without provenance | Details for pixel_map-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pixel_map-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for pixel_map-0.4.0-py3-none-any.whl |
Total release size: 754.7 kB
Release files / pixel_map-0.4.0.tar.gz
| Download URL | pixel_map-0.4.0.tar.gz |
|---|---|
| Size | 379.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
11a24e757479731d92f1f0347038d69eafe338bf519bdcb84e8d2367aca9bc4d
|
|
BLAKE2b-256 checksum How to use checksums |
3979d0ac52874ccb0ba88012beee3b11498929deca810efa648de5fd7f3b3112
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
pdm/2.29.7 CPython/3.12.16 Linux/7.0.0-1020-azure
|
Release files / pixel_map-0.4.0-py3-none-any.whl
| Download URL | pixel_map-0.4.0-py3-none-any.whl |
|---|---|
| Size | 375.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
998ffdc32427f3c351d6f5f99143dedb98748f7378e547ffb54b25d2eacdadcf
|
|
BLAKE2b-256 checksum How to use checksums |
5f333cb280aa50662295fc68f1bb8fad20d24ac0fa115e1667865d6e023a1613
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
pdm/2.29.7 CPython/3.12.16 Linux/7.0.0-1020-azure
|
Security for pixel-map 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.