pixel-map¶
Python CLI tool for plotting geo data in the terminal
![]()
Documentation · Examples · Basemaps · Renderers
Installation¶
PyPI:
uv:
Usage¶
To display your data in the terminal, you can just pass a filename as an argument:
Tool can also display data for multiple files at once:
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¶
![]()
Light mode¶
![]()
Multiple files with different colors¶
![]()
Different basemap and changed opacity (alpha)¶
![]()
No background and different renderer¶
You can explore multiple available renderers.
![]()
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.minimumContrastRatio that is set to 4.5 by 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.