Print countries in ASCII Art based on Natural Earth shape files.
Project description
db .M"""bgd .g8"""bgd `7MMF'`7MMF' `7MMM. ,MMF' ;MM: ,MI "Y .dP' `M MM MM MMMb dPMM ,V^MM. `MMb. dM' ` MM MM M YM ,M MM ,6"Yb. `7MMpdMAo. ,M `MM `YMMNq. MM MM MM M Mb M' MM 8) MM MM `Wb AbmmmqMA . `MM MM. MM MM M YM.P' MM ,pm9MM MM M8 A' VML Mb dM `Mb. ,' MM MM M `YM' MM 8M MM MM ,AP .AMA. .AMMA.P"Ybmmd" `"bmmmd' .JMML..JMML. .JML. `' .JMML.`Moo9^Yo. MMbmmd' MM .JMML.
Terminal application to print countries to console in ASCII Art
·-----· /...../ ´...../ |....| ,---· |.....--....| ´............· ·.........../ `........./ |.......| |,.......--· · |.........· |..........· ·--· ·-.........| |..-· `--.......· |...| `.......--· ·----· `......-.· United Kingdom ·.....-..· ·-----..........· |................· ·.................---· |...................| /...................,· ·-...................| `-..................· |................,· ,-....,....,------´ /....,´ `--´ ·-----´ ··
You can print any country with asciimap
for which a Geometry exists (currently
177 countries).
Dependencies
For asciimap
to work you need the python bindings for GDAL and GDAL itself
installed. I experienced problems installing the python bindings into a
virtualenv, so I recommend installing the system packages.
Arch
pacman -Sy gdal python-gdal
Debian/Ubuntu
apt-get update
apt-get install gdal-bin libgdal-dev python3-gdal
Installation
PyPi
Installation with pip is straightforward:
sudo pip install asciimap
Git
Installation with git from master branch:
git clone git@github.com:MaelStor/asciimap.git
cd asciimap
git checkout master
In userspace
Install in user space with:
pip install --user .
System
Install system wide with:
sudo pip install .
Usage
usage: asciimap [-h] [--fill FILL] [--empty EMPTY] [--outside OUTSIDE] [--height HEIGHT] [--width WIDTH] [--blur BLUR] [--method {full,f,dynamic,d,height,h,width,w}] [--surface SURFACE] [--negative] [--benchmark] [--stats] country Print countries in ASCII Art positional arguments: country Select country by ISO 3166-1 alpha-2 codes. For a complete list of ISO A2 codes use 'list' as argument optional arguments: -h, --help show this help message and exit --fill FILL, -f FILL Single character marking the edges of the land surface --empty EMPTY, -e EMPTY The character to use for the land surface --outside OUTSIDE, -o OUTSIDE Single character marking the outside surface --height HEIGHT, -i HEIGHT Height of the map as integer --width WIDTH, -w WIDTH Width of the map as integer --blur BLUR, -b BLUR Add blur to radius and inflate the surface by double value --method {full,f,dynamic,d,height,h,width,w}, -m {full,f,dynamic,d,height,h,width,w} Change rendering method --surface SURFACE, -s SURFACE Choose a surface by number or 'all' --negative, -n Print the negative --benchmark, -t Print execution times of methods along with the map. Can be give multiple times to increase verbosity. --stats, -x Print statistics List all countries and ISO 3166-1 alpha-2 codes with 'list'
Examples
$ asciimap it
·-· ·---...· |.......----· ,----............| · ,---...............,-| ·----.................,´ · |.................../ |..................| ·...................| |......,...........| ·-...,´ `-..........· |./ `-........| ·´ `........-· |.........-· |..........| ·...........· `....Italy..· `...........· `-..........· `..........-· `-..........---· `--.........| `-........--· ,· `-.........-· ·-..· `-........--· |....· `....../ `--· |....· `..../ `-· |...| `..| |...| `..· ·..,· |..-· `´ |../ |./ |/ ´| ·-· ,---· ·· |..---....· ·--......| `---..| `-| ·
$ asciimap no
·-----· ·----· ,-· ,---· |,----------· ·-...---.....---/ `-..........,´ `-......,´ ·--· `-...| `· `--· ,--------· ,· ,-...,----..· ·-----.`....| `--· Norway../ `-----· ·-· ·´ ,-/ ,-./ /../ /../ /../ ,-..| /..,-· ,-..| ,-....· ,--.....| ,-........| ·...........· |...........| |...........| ·...........· |......,--´ ·....,´ ·--·
You can print a country with the negative filter:
$ asciimap --surface 1 fr --negative
.........................................··..................................... ....................................... .................................... ....................................... ................................. ...................................... ................................ ...................................... .............................. ................................... . .......................... ....................... ........ ........................ ....................... ... ...................... ........................ ................... ........................ ............. ............... ..... ............ ...........· ............. ...........| ............. ...........| .............. ...........· .............. ............... .............. ................... . ............... .................... ................. ...................... ................... ....................... .................... ........................ France ..................... ......................... ..................... .......................... .................. .......................... ................. .......................... ................. .......................... ................. .......................... ................ .......................... ................. .......................... ................. .......................... ................. .......................... ................. .......................... ................ ......................... .............. ......................... .............. ........................ ............... ........................ .... ................. ......................... ................................. ............................ .................................. ................................ .. .................................. .......................................·----·...................................
or if you want the borders to be shown:
$ asciimap --surface 1 --outside '.' fr
.........................................··..................................... .......................................·- ·.................................... .......................................| --·................................. ......................................´ ·................................ ......................................| -·.............................. ...................................,-- ·.,·.......................... .......................·........,-- ` -·........................ .......................·-·...,-- -·...................... ........................| --- --·................... ........................| -----·............. ...............,--·.....| ·............ ...........·--- ----- |............. ...........| ·............. ...........| |.............. ...........·--- |.............. ...............`--- , ·.............. ...................` |.\´............... ....................`- -·................. ......................` /................... .......................` /.................... ........................` France |..................... .........................` |..................... ..........................| --·.................. ..........................| ·................. ..........................| |................. ..........................| |................. ..........................| ·................ ..........................| |................. ..........................| |................. ..........................| |................. ..........................| |................. ..........................| ·................ .........................´ -·.............. .........................| ·.............. ........................´ ,--- ,´............... ........................· ,--´....`------´................. .........................`-- /................................. ............................`--- ,- |.................................. ................................`´..`-- ·.................................. .......................................·----·...................................
Fillings can be combined. If you want to fill the land surface with .
,
everything outside the land surface with ~
and corners with ^
use:
$ asciimap nz --outside '~' --empty '.' --fill '^'
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~··~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|·~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~·.-·~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`..·~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`.|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~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~~,-.......,´~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~,-........|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~/..........·~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~,-..........|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~´............·~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~|...........|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~·...........,·~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~·----.....,´~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~·---·~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Advanced usage
An example with 'paste' and boasted usage of 'blur':
$ asciimap -b 0 jp -i 30 -w 30 | paste - <(asciimap -b 2.0 jp -i 30 -w 30)
· ·-· |· ´...-· |.-· · |.....---· /....--· /.........| ,-.,...,´ /...........· ´../ `./ ´............| ·-´ · |............| |............· ·-· |..........,´ |.| |........,´ |.| |.......| |.| |.......| ´..· ,--........· ·.· ·-..........| Japan |...Japan...· ·....· ,----...........| ,--....| /................| ´.......| ,-.................| ,-· |.......· /...................· ,--..--..,----´ /.................../ /-.,.| |./ ·.................../ ,-/ | \· ·´ |..............,---´ /.| |· ·............./ ·-..· · |........,--´ || ·......,´ |· |..../ · ·-../ `´
$ asciimap au --blur 0.1 --empty '.' --method full
·· ,-· || ,---...-----· ´..· /..........| |..| ,---· /...........| |...· /.....---............| |....--· /......................--· ´.......| ·· /..........................--· |........· |.`..............................----.........| /..............................................| /................................................-· ,----...................................................--· ,-----...........................................................· ,-..................................................................· ·-.....................................................................-· |........................................................................· ·..........................................................................-· |,..........................................................................· ·| |......................................Australia...........................· |`...........................................................................| ·............................................................................| `............................................................................· |...........................................................................· ·..........................................................................| `...........................,---..........................................| |...................,-----´ `----.....................................· |................,-´ `......,...........................,´ /........,-------´ `...,´ |........................./ ·--....,-´ `-´ /-......................../ `--´ ·· `....................../ `....................| `...................| `--......,.....,---· `----´ `---´ ·· ,-· |---..· ·...,´ ·-·
Sometimes a country has more than one land surface (or more precise: Polygons) defined, what warps or shows just a few pixels for the surface of interest when printing all surfaces together:
$ asciimap --surface all --method full ru --fill "'"
· · · · ,· · ,-..· · · /....| · ´.....| · · |......---· | · | |.........| |· · | ´...........--..-· · · |................| · ·· · |.................--· · · ·\ ·--.· |....................`| · · |...| |.....................| · · ·-.....`......................| · | |............................| |--.............................| |...........................,-..· |.............Russia.......| |/ ´...........................· · |........................,-´ |.......................| · |.......................| | ·-......................· | |......,.............| | · ´....../ |,...........| | |.....| · |........,..· · ·...,.· ·....,...| |.| |.| · `.,| |..| |.| ·.· | · ·.,· |.| | · · ·.| | `| |· | ·.| | · |· · · | · ·· · ·
To overcome the bias you can just render the big land surface for example with:
$ asciimap --surface 1 --method height ru --fill "'"
·-· ,---...--------· ,---------.............,--· ,---......................| ·-----...........................--· ,---· ,· ,--· · |,..................................`.....-----..---· ·--· /..| ´| ,---| |.................................................| |...------· ·-....· |.`.....`...................................................--· ,-------...........---· ,---· `....| ·..............................................................`.......................`.....· ·· ·-------· ,---· \...| |............................................................................................---------· |.-------· |.......---· ·-· ,--· ,-----.....--· |..-· |......................................................................................................--.........| ·....,--....· `| ,--....`..............`..| /..................................................................................................................| |..| `--´ ,· |---.........................| /...................................................................................................................| |...· ·-..`..............................`...................................................................................................................,· |...| ,--......................................................................................................................................................| ·....---..........................................................................................................................................................· |...........................................................................................................................................,...,-...........,----· /..........................................................................Russia.........................................................,-´ |,´ |.......,-´ ·-........................................................................................................................................,´ · ·-.,-----´ |...........................................................................................................................,---------../ ·---´ ·-..........................................................................................................................,´ `´ /./ ·.........................................................................................................................,´ ,-.| |......................................................................................................................./ ·-....-· ·--..........................................,........................................................................,´ |.....,· |.....................................,--´ `......,...............................................................| ·...../ ·-...............................,---´ `----´ |...............................................................· |.../ |.............................| ·..............................................,-----............---· |../ ·--..................,-........| `.....................,......................| `...............· |./ `...............,´ `------.· `----.........,...../ `--...................· |.............| ·´ `---.........,´ · `-....,-´ `---| `-----......,-.,../ ·.............| `......./ `--´ · `----´ · `´ `--..........| |.....| |..,-.....· |......· ·-´ |.../ /........· ´.../ /.........-· |../ ·-........./ · /../ `--.....| |`../ `----.· ·--´ `-\ ·
or
$ asciimap --surface 1 --method width --height 20 ru --fill "'"
·-· ,-------...-· · ,--.............--------· ´.· ·--.........................· ,---------· ·--· ,· |.| |............................`...........-------· ,---· |..--· · ,------..`..| |................................................`....| ·.| ·-.`.............`......................................................· |.---.............................................................,..,....,-´ /...................................Russia.....................,../ `| `--´ ·..........................................................,---´ `´ | ·-.......................................................,´ ,-| |...............,-----.,..............................| ´..· ·-............./ · `..........,...........,--.....· ·./ `-....,-----´ `--...,-.| `---...,../ `.....-· · `..| `-´ `· `-´ `´ `.,..| |.| · |.· ´...· |/ ·--´ ·-· ·
To find the right surface you have to try around a bit. I'm working on a better solution.
Performance
Rendering and printing time depends on the size of the resulting map. Rendering
and printing a country with 40x80 (h x w)
usually takes about 0.1 - 0.3
seconds on a 2-core system. Rendering is implemented to use parallel processes
and reduces computation time on multicore systems. To use the inbuild benchmark
system you need 'yappi' installed. This is not a hard dependency as it is only
used for development. Print 'yappi' results for example with
$ asciimap de --benchmark
Statistics
The configuration and statistics are shown with --stats
(or -x
) along the
resulting map and benchmarking results.
$ asciimap ca -x
·----------------· ,-------...........,-´ ·---.| |.....,---´ `-..--· ,-.....| ·· ·· `´ |`....,--· ·-· ·-----´ ·· ·--· ,· ·--· ·· ·--· · ·-· |---------· ,-----· |.--´ ·..../ |-· · · ,· · ·-· || ·--· ,--· `--´ ·.,--.--.`..· ·-· || ·...`....----· · |.......· /-.· `--...,----..----· ·· ,--------· ,-· ·------....-· ·--/ |.-· |.| `--....-· |.---..........`...---.| |..| || |...-· |..· `....| |.......................-----....-----..--......· `--· · |...---· |................................................· /...| `-· |.............................................,-´ ·· ·----....· |...........................................,´ ·-· ,· `-...-· |..........................................· ·· `-´ · |.....................................Canada · ·---· ·-..,....................................· |....--· `´ `-..................................| |......| ,· `..................................· ·.......· /..· `..................................· |.......`....· `..................................---· |............| |.....................................----· /..............-· · ·.........................................| ´.................-· `.........................................· |...................· \.........................................· |.................,-| · |,........................................`...........,--.,-´ | · |,---------------------------.....................,| · /| · `-----............../ ·-· ·----· `-...........| || · `..........· ·-· · · |....,---´ ·-· |..,´ · ·-´ MapConfig max_height: 40 height: None max_width: 80 width: None fill_char: '*' no_char: '.' outside_char: ' ' blur: 0.0 method: 'dynamic' surface: 'all' is_negative: False PrinterConfig fill_char: '*' no_char: '.' outside_char: ' ' is_negative: False is_unicode: False padding: (1, 0, 1, 0) max_width: 80 max_height: 40 RenderConfig name: 'Canada' geom: > centroid: (-98.14238137209722, 61.46907614534891) lowest_lon: -140.99778 lowest_lat: 41.675105088867326 highest_lon: -52.64809872090421 highest_lat: 83.23324 lat_diff: 41.55813491113267 lon_diff: 88.34968127909579 worker_count: 4 h_res: 1.1043710159886975 w_res: 1.1043710159886975 max_height: 38 max_width: 80
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file asciimap-1.0.0.tar.gz
.
File metadata
- Download URL: asciimap-1.0.0.tar.gz
- Upload date:
- Size: 240.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6977dc8918b66aed4287d58d4f95857b7d3c6ccd9a9d3cabb0647bdf4d9ee1d0 |
|
MD5 | c7aebf9a0c407dbbf06b85f1516a01a3 |
|
BLAKE2b-256 | f49b607cfb395984066bac2b24d79515561a1ee4c8471b54cbd4f264aad0ce23 |
File details
Details for the file asciimap-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: asciimap-1.0.0-py3-none-any.whl
- Upload date:
- Size: 230.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 93c0253f56b68b0c901dde48cd9041049e738c33e6f6e5ca4278b14afdbf0600 |
|
MD5 | 4c8fadc93f499bba09767ba60e91d7b1 |
|
BLAKE2b-256 | 1cb3c8d15d2f6a5a1f6dd04c823a91563cbc316a6c250f5a0053d4e3a495ca7f |