Skip to main content

Tools for plotting routes, clusters and more from JSON

Project description

nextplot

pypi_versionbuild

Tools for plotting routes and clusters from JSON

Installation

pip install nextplot

Usage

If the installation succeeded, you should be able to invoke the following:

nextplot --help

Furthermore, use the route and cluster commands for the respective plotting type. Find an overview of the arguments for the specific mode by invoking nextplot route --help and nextplot cluster --help.

Above shows some information about how to use the script. Below presents some further information for running the script using route plotting as an example.

There are basically two options of running the script. Either feed the JSON to STDIN of the script like so:

cat examples/data/kyoto-route.json | nextplot route \
  --jpath_route "vehicles[*].route" \
  --jpath_x "position.lon" \
  --jpath_y "position.lat"

Or supply a path to the .json file like so:

nextplot route \
  --input_route examples/data/kyoto-route.json \
  --jpath_route "vehicles[*].route" \
  --jpath_x "position.lon" \
  --jpath_y "position.lat"

Both approaches will create a .png plot image and if possible (valid lon/lat coordinates given) an interactive .html plot file. The filenames will be plot.[png,html] for the first option, based on the input filename for the second option and customized ones if --output_image and/or --output_map are specified.

The input file is expected to have some JSON array of positions which can be addressed using the notation described here: https://goessner.net/articles/JsonPath/. The path to the positions can be modified via the --jpath_route parameter. For example, if your input file stores the locations like shown below, the path "vehicles[*].route" will extract them. As you can see, the path first goes through the vehicles. Next, [*] denotes that a list of vehicles is expected, which in turn results in a list of routes. Finally, .route points to the exact location of the route object per vehicle. The --jpath_x and --jpath_y parameters are used to extract the longitude and latitude values from the stop objects at position.lon and position.lat.

{
    "vehicles": [
        // ...
        {
            "id": "v1",
            "route": [
                {
                    "id": "v1-start",
                    "position": { "lon": 135.73723, "lat": 35.04381 }
                },
                {
                    "id": "Kinkaku-ji",
                    "position": { "lon": 135.728898, "lat": 35.039705 }
                },
                {
                    "id": "Nijō Castle",
                    "position": { "lon": 135.748134, "lat": 35.014239 }
                },
                {
                    "id": "Arashiyama Bamboo Forest",
                    "position": { "lon": 135.672009, "lat": 35.017209 }
                }
            ]
        }
        // ...
    ]
}

Further examples

A more detailed introduction and a plot gallery can be found here.

Preview

Preview route plot (screenshot of .html-file, cartodbdark_matter selected):

sample-popup

Another preview route plot (screenshot of .html-file, cartodbdark_matter selected):

sample-plot-html

Preview cluster plot (screenshot of .html-file, cartodbdark_matter selected):

sample-plot-html

Auto-completion

Auto-completion (using tab) is supported via argcomplete. To enable it, install the package:

pip install argcomplete

Then, add the following line to your ~/.bashrc:

eval "$(register-python-argcomplete nextplot)"

Development setup

Install development dependencies

pip install -r requirements-dev.txt

Tests

Tests are located in tests/ and can be run via python -m pytest. Update test expectations (golden files) by running UPDATE=1 python test_cli.py from the test directory.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nextplot-0.1.3.tar.gz (5.5 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nextplot-0.1.3-py3-none-any.whl (41.7 kB view details)

Uploaded Python 3

File details

Details for the file nextplot-0.1.3.tar.gz.

File metadata

  • Download URL: nextplot-0.1.3.tar.gz
  • Upload date:
  • Size: 5.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for nextplot-0.1.3.tar.gz
Algorithm Hash digest
SHA256 396c2d9fb86c9c7ab0ca525b48e586a807991bdfd39a9ad235e5beafdbe9258c
MD5 59785af68486828cf494c711a0405a75
BLAKE2b-256 63aa8c94fbd115608ce4f7013066d881a72804c7497653c465b58421833d2ad3

See more details on using hashes here.

File details

Details for the file nextplot-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: nextplot-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 41.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for nextplot-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0f9fbc37d0fa4b6c39fa9a105c43ee1fc10d18f4ab9788ba7580414b4722cd60
MD5 af12b785364c1eef720a1d9abf35d6ed
BLAKE2b-256 2a4d1b5bf34d88da458fe927a324d1bc57863c7fb51e251c1052c2b1bdc02df0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page