{ "info": { "author": "Kevin Wurster", "author_email": "wursterk@gmail.com", "bugtrack_url": null, "classifiers": [], "description": ".. code-block:: console\n\n _ ___ _ _\n ____ _ (_)__ \\ ____ ___________(_|_)\n / __ `/ / /__/ // __ `/ ___/ ___/ / /\n / /_/ / / // __// /_/ (__ ) /__/ / /\n \\__, /_/ //____/\\__,_/____/\\___/_/_/\n /____/___/\n\n\n.. image:: https://travis-ci.org/geowurster/gj2ascii.svg?branch=master\n :target: https://travis-ci.org/geowurster/gj2ascii\n\n\n.. image:: https://coveralls.io/repos/geowurster/gj2ascii/badge.svg?branch=master\n :target: https://coveralls.io/r/geowurster/gj2ascii\n\nRender spatial vector data as ASCII or emoji with Python on the commandline.\n\n.. image:: https://raw.githubusercontent.com/geowurster/gj2ascii/master/images/emoji-land-cover-80w.png\n :target: https://github.com/geowurster/gj2ascii/blob/master/images/emoji-land-cover-80w.png\n :width: 574\n :height: 563\n\n\nWhy?\n====\n\nA `tweet `__ made it seem like an interesting exercise but\nthe ``gj2ascii`` commandline utility has been very useful for previewing multiple files and the API has proven to be\nuseful for debugging complex geoprocessing operations.\n\n\nDefault Behavior\n================\n\nThe overall goal of this utility is to provide easy access to ASCII representations\nof vector geometries and overlapping layers.\n\n1. When rendering a single layer an ASCII character is used.\n2. When rendering multiple layers colors are used with a randomly assigned character underneath and a transparent fill.\n\nThere are only ``7`` colors (black is not used for auto-assignment) so if more than 7 layers\nare given the ``--char`` flag must be used for each of them to manually assign a character,\nemoji, or color.\n\n\nEmoji Example\n=============\n\nThe emoji screenshot was generated by downloading the ``GeoTIFF`` version of the\n`MODIS Landcover dataset `_, resampling to ``25%``\nof its original, size converted to a vector with `gdal_polygonize.py `_,\nand `split `_\ninto one ``ESRI Shapefile`` per class with `QGIS `_, before executing the following\ncommand:\n\n.. code-block:: console\n\n $ gj2ascii \\\n --bbox -130 9 -61.5 77 \\\n --width 80 \\\n 0.geojson -c ' ' \\\n 1.geojson -c :christmas_tree: \\\n 2.geojson -c :evergreen_tree: \\\n 3.geojson -c :maple_leaf: \\\n 4.geojson -c :maple_leaf: \\\n 5.geojson -c :deciduous_tree: \\\n 6.geojson -c :herb: \\\n 7.geojson -c :herb: \\\n 8.geojson -c :herb: \\\n 9.geojson -c :herb: \\\n 10.geojson -c :ear_of_rice: \\\n 11.geojson -c :turtle: \\\n 12.geojson -c :tractor: \\\n 13.geojson -c :house_building: \\\n 14.geojson -c :leaf_fluttering_in_wind: \\\n 15.geojson -c :snowflake: \\\n 16.geojson -c :black_medium_square:\n\nThe same data can be rendered with ASCII characters instead:\n\n.. code-block:: console\n\n $ gj2ascii \\\n --bbox -130 9 -61.5 77 \\\n --width 80 \\\n 0.shp -c ' ' \\\n 1.shp -c \\# \\\n 2.shp -c \\^ \\\n 3.shp -c + \\\n 4.shp -c \\& \\\n 5.shp -c \\$ \\\n 6.shp -c \\% \\\n 7.shp -c \\: \\\n 8.shp -c P \\\n 9.shp -c - \\\n 10.shp -c \\\" \\\n 11.shp -c 0 \\\n 12.shp -c = \\\n 13.shp -c N \\\n 14.shp -c \\@ \\\n 15.shp -c \\* \\\n 16.shp -c O\n\n\n.. image:: https://raw.githubusercontent.com/geowurster/gj2ascii/master/images/ascii-land-cover-80w.png\n :target: https://github.com/geowurster/gj2ascii/tree/master/images/ascii-land-cover-80w.png\n :width: 566\n :height: 553\n\n\nOther Examples\n==============\n\nSee the `examples directory `__ for more information and\nmore complex examples but the following are a good place to get started. Some of the examples include output that\nwould be colored if run on the commandline or in Python but RST cannot render the ANSI codes.\n\nRender two layers, one read from stin and one read directly from a file, across 20 pixels while explicitly specifying\na character and color for each layer and background fill, and zooming in on an area of interest.\n\n.. code-block:: console\n\n $ cat sample-data/polygons.geojson | gj2ascii - \\\n sample-data/lines.geojson \\\n --bbox sample-data/small-aoi-polygon-line.geojson \\\n --width 20 \\\n --char ^=red \\\n --char -=blue \\\n --fill .=green\n . . . . . . - . . . . . . . . . ^ ^ ^ ^\n . . . . . - . . . . . . . . . . . ^ ^ ^\n . . . . - . . . . . . . . . . . . . - -\n . . . . - . . . . . . . . - - - - - . ^\n ^ ^ . - . . . . . . . . . . . . . . . .\n ^ ^ - . . . . . . . . . . . . . . . . .\n ^ - ^ . . . . . . . . . . . . . . . . .\n ^ - . . . . . . . . . . . . . . . . . .\n - ^ . . . . . . - . . . . . ^ . . . . .\n . - . . . . . . - - . . . ^ ^ . . . . .\n . . - . . . . . - . - . ^ ^ ^ . . . . .\n . . . - . . . . - . . - ^ ^ ^ . . . . .\n . . . . - . . - . . ^ ^ - ^ ^ . . . . .\n . . . . . - . - . ^ ^ ^ ^ - ^ . . . . .\n . . . . . . - - ^ ^ ^ ^ ^ ^ - . . . . .\n\n\n\nRender individual features across 10 pixels and display the attributes for two\nfields, ``COUNTYFP`` and ``NAME``.\n\n.. code-block:: console\n\n $ gj2ascii sample-data/WV.geojson \\\n --iterate \\\n --properties COUNTYFP,NAME \\\n --width 10\n\n +----------+---------+\n | COUNTYFP | 001 |\n | NAME | Barbour |\n +----------+---------+\n\n + + +\n + + + + + + + +\n + + + + + + + + +\n + + + + + + + + +\n + + + + + + + + + +\n + + + + + + +\n + + + +\n + + + +\n\n Press enter for the next geometry or ^C/^D or 'q' to quit...\n\nRecreate the first example with the Python API\n----------------------------------------------\n\nThere are two ways to recreate the first example with the Python API. If the user does not care about which characters\nare assigned to which color, use this one:\n\n.. code-block:: python\n\n import fiona as fio\n import gj2ascii\n with fio.open('sample-data/polygons.geojson') as poly, \\\n fio.open('sample-data/lines.geojson') as lines, \\\n fio.open('sample-data/small-aoi-polygon-line.geojson') as bbox:\n layermap = [\n (poly, 'red'),\n (lines, 'blue')\n ]\n print(gj2ascii.style_multiple(layermap, 20, fill='green', bbox=bbox.bounds))\n 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 2 2 2 2\n 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 2 2 2\n 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1\n 0 0 0 0 1 0 0 0 0 0 0 0 0 1 1 1 1 1 0 2\n 2 2 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n 2 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n 2 1 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n 1 2 0 0 0 0 0 0 1 0 0 0 0 0 2 0 0 0 0 0\n 0 1 0 0 0 0 0 0 1 1 0 0 0 2 2 0 0 0 0 0\n 0 0 1 0 0 0 0 0 1 0 1 0 2 2 2 0 0 0 0 0\n 0 0 0 1 0 0 0 0 1 0 0 1 2 2 2 0 0 0 0 0\n 0 0 0 0 1 0 0 1 0 0 2 2 1 2 2 0 0 0 0 0\n 0 0 0 0 0 1 0 1 0 2 2 2 2 1 2 0 0 0 0 0\n 0 0 0 0 0 0 1 1 2 2 2 2 2 2 1 0 0 0 0 0\n\n\nIf the user cares about which character is assigned to which layer, use this one:\n\n.. code-block:: python\n\n import fiona as fio\n import gj2ascii\n\n with fio.open('sample-data/polygons.geojson') as poly, \\\n fio.open('sample-data/lines.geojson') as lines, \\\n fio.open('sample-data/small-aoi-polygon-line.geojson') as bbox:\n\n # Render each layer individually with the same bbox and width\n # The fill will be assigned in the next step but must be a single space here\n rendered_layers = [\n gj2ascii.render(poly, 20, char='^', fill=' ', bbox=bbox.bounds),\n gj2ascii.render(lines, 20, char='-', fill=' ', bbox=bbox.bounds)\n ]\n\n # Overlay the rendered layers into one stack\n stacked = gj2ascii.stack(rendered_layers, fill='.')\n\n # Apply the colors and print\n colormap = {\n '^': 'red',\n '-': 'blue',\n '.': 'green'\n }\n print(gj2ascii.style(stacked, colormap))\n . . . . . . - . . . . . . . . . ^ ^ ^ ^\n . . . . . - . . . . . . . . . . . ^ ^ ^\n . . . . - . . . . . . . . . . . . . - -\n . . . . - . . . . . . . . - - - - - . ^\n ^ ^ . - . . . . . . . . . . . . . . . .\n ^ ^ - . . . . . . . . . . . . . . . . .\n ^ - ^ . . . . . . . . . . . . . . . . .\n ^ - . . . . . . . . . . . . . . . . . .\n - ^ . . . . . . - . . . . . ^ . . . . .\n . - . . . . . . - - . . . ^ ^ . . . . .\n . . - . . . . . - . - . ^ ^ ^ . . . . .\n . . . - . . . . - . . - ^ ^ ^ . . . . .\n . . . . - . . - . . ^ ^ - ^ ^ . . . . .\n . . . . . - . - . ^ ^ ^ ^ - ^ . . . . .\n . . . . . . - - ^ ^ ^ ^ ^ ^ - . . . . .\n\nPaginating through features:\n\n.. code-block:: python\n\n import fiona as fio\n import gj2ascii\n\n with fio.open('sample-data/WV.geojson') as src:\n for feature in gj2ascii.paginate(src, 10, properties=['COUNTYFP', 'NAME']):\n print(feature)\n +----------+---------+\n | COUNTYFP | 001 |\n | NAME | Barbour |\n +----------+---------+\n\n + + +\n + + + + + + + +\n + + + + + + + + +\n + + + + + + + + +\n + + + + + + + + + +\n + + + + + + +\n + + + +\n + + + +\n\n\nInstallation\n============\n\nVia pip:\n\n.. code-block:: console\n\n $ pip install gj2ascii --upgrade\n\nFrom master branch:\n\n.. code-block:: console\n\n $ git clone https://github.com/geowurster/gj2ascii.git\n $ cd gj2ascii\n $ python setup.py install\n\nTo enable emoji:\n\n.. code-block:: console\n\n $ pip install gj2ascii[emoji]\n\n\nDependencies\n------------\n\nThe dependencies are pretty heavy for a utility like this and may require some\nextra work to get everything installed. All dependencies should install on their\nown but there are a few potentially problematic packages. Manually installing\nthe following might help:\n\n* `Rasterio `__\n* `Fiona `__\n* `Shapely `__\n\nSome Linux distributions require an additional step before installing rasterio:\n``apt-get install python-numpy-dev libgdal1h libgdal-dev``.\n\n\nDeveloping\n==========\n\n.. code-block:: console\n\n $ git clone https://github.com/geowurster/gj2ascii.git\n $ cd gj2ascii\n $ virtualenv venv\n $ source venv/bin/activate\n $ pip install -e .[all]\n $ py.test gj2ascii --cov gj2ascii --cov-report term-missing\n\n\nLicense\n=======\n\nSee ``LICENSE.txt``.\n", "description_content_type": null, "docs_url": null, "download_url": null, "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/geowurster/gj2ascii", "keywords": null, "license": "New BSD License", "maintainer": null, "maintainer_email": null, "name": "gj2ascii", "package_url": "https://pypi.org/project/gj2ascii/", "platform": null, "project_url": "https://pypi.org/project/gj2ascii/", "project_urls": { "Homepage": "https://github.com/geowurster/gj2ascii" }, "release_url": "https://pypi.org/project/gj2ascii/0.4.1/", "requires_dist": null, "requires_python": null, "summary": "Render GeoJSON as ASCII on the commandline.", "version": "0.4.1" }, "last_serial": 1575502, "releases": { "0.1": [], "0.1.1": [ { "comment_text": "", "digests": { "md5": "3210852a833ca6dc0061aecc1cc16840", "sha256": "34714e6846fa59c545625561bf2da7fce72ebff56401101dae42f4c18774b9cc" }, "downloads": -1, "filename": "gj2ascii-0.1.1.tar.gz", "has_sig": false, "md5_digest": "3210852a833ca6dc0061aecc1cc16840", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4586, "upload_time": "2015-03-11T00:23:12", "url": "https://files.pythonhosted.org/packages/c0/39/fa6a17138fb482d2db3f5617598cee1752fce6389d8d003c5acfb5e2ef11/gj2ascii-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "33312e00a7fdbcd1a413f75a9294e7bf", "sha256": "f7ac1347ead3e188c56c2d27f0327917b009ff3793e2fe9d45682aecfbb80dc2" }, "downloads": -1, "filename": "gj2ascii-0.1.2.tar.gz", "has_sig": false, "md5_digest": "33312e00a7fdbcd1a413f75a9294e7bf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4778, "upload_time": "2015-03-11T00:24:49", "url": "https://files.pythonhosted.org/packages/7a/f9/40b5fa18689bd9528732e0cd7852331565471548ccf2bd94d3ca41af8e24/gj2ascii-0.1.2.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "8b285753fff5a9b5da27dcecca835b73", "sha256": "843ceda860770d293a8b8ab211a78ac1fe572d640d65c60e8881b775419d7610" }, "downloads": -1, "filename": "gj2ascii-0.2.0.tar.gz", "has_sig": false, "md5_digest": "8b285753fff5a9b5da27dcecca835b73", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5060, "upload_time": "2015-03-11T05:58:59", "url": "https://files.pythonhosted.org/packages/27/9d/f7ea6fbf1428588a78c67676aaaa26ba115a7517bb1f8620b4fd0f6a368a/gj2ascii-0.2.0.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "b5fd7704eb21b2c9daaccc56a0b3f241", "sha256": "5349ad597d3576725d47a8b2b1020a57c7a2c936a2cb1a8a875cd506279304a1" }, "downloads": -1, "filename": "gj2ascii-0.3.0.tar.gz", "has_sig": false, "md5_digest": "b5fd7704eb21b2c9daaccc56a0b3f241", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10201, "upload_time": "2015-03-13T04:44:51", "url": "https://files.pythonhosted.org/packages/4b/cb/d13bac6e88d6f9fd68b97872bae976b578f531fe6d23731da9d746191197/gj2ascii-0.3.0.tar.gz" } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "3f320f0009f41430bca37c7f9eaed077", "sha256": "4b292f6b2692f6cb40305b95ef058f78ee0e6a4e0c84b14449499b31f8f74ced" }, "downloads": -1, "filename": "gj2ascii-0.3.1.tar.gz", "has_sig": false, "md5_digest": "3f320f0009f41430bca37c7f9eaed077", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10361, "upload_time": "2015-03-13T05:05:09", "url": "https://files.pythonhosted.org/packages/a2/2d/207aa7acdb3da1b5d598f14a5bc4be2733fcef2ab41a823791cb2679e92a/gj2ascii-0.3.1.tar.gz" } ], "0.4": [ { "comment_text": "", "digests": { "md5": "4c3e359ae242d9ea93d931d9d631584c", "sha256": "5e541a66620a962beac4119c5c6fdf0d3e8871c54720e9519fe00f3027adf62c" }, "downloads": -1, "filename": "gj2ascii-0.4.tar.gz", "has_sig": false, "md5_digest": "4c3e359ae242d9ea93d931d9d631584c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 25386, "upload_time": "2015-06-02T04:38:33", "url": "https://files.pythonhosted.org/packages/54/da/2bfa2354f4c45355551b8f396d3789937a38421bc21c27d12c23cc74c85a/gj2ascii-0.4.tar.gz" } ], "0.4.1": [ { "comment_text": "", "digests": { "md5": "887274b006171a18da25fba003430983", "sha256": "65c865410aecd6e4698a120b47531171ee4bc89a511c301c770393f4884ffe8e" }, "downloads": -1, "filename": "gj2ascii-0.4.1.tar.gz", "has_sig": false, "md5_digest": "887274b006171a18da25fba003430983", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 25401, "upload_time": "2015-06-02T17:11:05", "url": "https://files.pythonhosted.org/packages/12/bb/7ba7b05bf43b334d5a2b7f84844279f377456512adba7634585f3d97e13e/gj2ascii-0.4.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "887274b006171a18da25fba003430983", "sha256": "65c865410aecd6e4698a120b47531171ee4bc89a511c301c770393f4884ffe8e" }, "downloads": -1, "filename": "gj2ascii-0.4.1.tar.gz", "has_sig": false, "md5_digest": "887274b006171a18da25fba003430983", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 25401, "upload_time": "2015-06-02T17:11:05", "url": "https://files.pythonhosted.org/packages/12/bb/7ba7b05bf43b334d5a2b7f84844279f377456512adba7634585f3d97e13e/gj2ascii-0.4.1.tar.gz" } ] }