Print countries in ASCII Art based on Natural Earth shape files.
Project description
asciimap
Print countries in ASCII Art based on shape files from Natural Earth project
*-----* $-----$ '-----' * / $ / ' / * * $ $ ' ' * *-----* $ $-----$ ' '-----' | | | | | | | * | $ | ' * / $ / ' / * / $ / ' / | * | $ | ' |-* *--* |-$ $--$ |-' '--' * * * $ $ $ ' ' ' * * $ $ ' ' *--* *--* \ $--$ $--$ \ '--' '--' \ | ** \ \ | $$ \ \ | '' \ \ *\ | \ *-* $\ | \ $-$ '\ | \ '-' *-* * * $-$ $ $ '-' ' ' United Kingdom United Kingdom United Kingdom *--* * * $--$ $ $ '--' ' ' * * \ $ $ \ ' ' \ * ** $ $$ ' '' \ \* \ \$ \ \' * * $ $ ' ' *--/ * $--/ $ '--/ ' *----* | $----$ | '----' | * | $ | ' | *--* /* $--$ /$ '--' /' / ** *--------* / $$ $--------$ / '' '--------' /-----* * /-----$ $ /-----' ' *-* $-$ '-'
You can print any country with asciimap
for which a Geometry exists (currently
177 countries). In general printing is pretty fast though big countries like
Russia, Canada etc. need some extra computation time. To circumvent loading times
store the results in a database or similar. Disk space isn't much for normal
40x80 sized ascii maps.
Dependencies
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] [--height HEIGHT] [--width WIDTH] [--empty EMPTY] [--blur BLUR] [--method {full,f,dynamic,d,height,h,width,w}] country Print countres in ASCII Art positional arguments: country Select country by ISO 3166-1 alpha-2 codes optional arguments: -h, --help show this help message and exit --fill FILL, -f FILL Single character --height HEIGHT, -i HEIGHT Height of the map --width WIDTH, -w WIDTH Width of the map --empty EMPTY, -e EMPTY The character to use for empty space --blur BLUR, -b BLUR Add blur to radius and inflate the map --method {full,f,dynamic,d,height,h,width,w}, -m {full,f,dynamic,d,height,h,width,w} Change rendering method List all countries and ISO 3166-1 alpha-2 codes with 'list'
Examples
$ asciimap --blur 0.1 it
* *---* *-* *--* *---* ** * / * *---* ** * * *----* * * * | | | | * *\ *--* \ \ ** *-* \ ** * ** | \ * * \ * \ \ \ Italy ** \ \ ** *--* ** \ *--* ** *-* \ ** */ \ ** ** * * \ / ** * * ** / *-* * | * \ * ** | | * * | | * \* * *-* * | * | /* * / / / *----------/ /* | | * *\ | *-* | *-* | *-*
$ asciimap --blur 0.1 no
*---------------* *-----------* \ | /------* *\ *---* ** / * \ ** *----* *-* / *-* *------* ** / *--* *-----* ** \ | Norway/ /--\ ** *--* * *--* *---* *--* ** / / / / / ** / / / / / ** /* ** / *-* * ** | * * | * | | | * | ** / * / * *----*
Advanced usage
Some advanced usage with command-line tools. The picture in the title was produced with
$ asciimap gb --height 30 --width 35 | paste - <(asciimap gb --height 30 --width 35 --fill "$") | paste - <(asciimap gb --height 30 --width 35 --fill "'")
another example with 'paste' and 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 which scrambles the surface of interest when printing all surfaces:
$ 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| / | ' | | | | | '\ | \ '--' | \ '----' '-' '' | \ ' '' \ | |-' ' \ | ' \ '---' / \ /' \ ' / '------' '---' '--' / ' '' '' '-' '-' '--' ' ' ' ' ' / \ ' ' '' | / '' '-\ ' '--' ' '-' \ '-'
what cuts off the right half of Russia. To print the whole surface:
$ 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.
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
Hashes for asciimap-0.1.0b0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6ea02982b4f636b7ae9caaec6eb6a0ff2239ef02460dc95c793e332e746dd16 |
|
MD5 | 8b5f0bf86aaf80fd5a1449a7b7121e09 |
|
BLAKE2b-256 | dc3e7c6a0dfc996034bb24370b656416fb4c1fc189cbfbb8a788e05a238808c2 |