Skip to main content

Python wrapper for visualiation of shapely geometries.

Project description

WKTPlot

Plot well-known-text strings and shapely geometries with Bokeh!

Badges

CircleCI Codacy Badge Codacy Badge

Installation

pip install wktplot

Usage

from wktplot.wkt_plot import WKTPlot

shape = "POLYGON((-124.4009 41.9983,-123.6237 42.0024, ...))"
plot = WKTPlot(title="California", save_dir="/path/to/directory")
plot.add_shape(shape, color="green", line_width=3)
plot.save()

WKTPlot supports majority of shapely objects including:

  • Point
  • MultiPoint
  • LineString
  • MultiLineString
  • LinearRing
  • Polygon
  • MultiPolygon
  • GeometryCollection

Example for plotting from shapefile. Shapefile is of California's county boundaries from here.

from random import randrange
from shapely.geometry import Polygon
from wktplot.wkt_plot import WKTPlot

import shapefile  # pyshp module

def get_rand_color():
    return f"#{randrange(0, 0xffffff):0>6x}"

plot = WKTPlot(title="California Counties", save_dir"~/scratch")
with shapefile.Reader("~/scratch/ca_counties/CA_Counties/CA_Counties_TIGER2016.shp") as shp:
    for shape in shp.shapes():
        p = Polygon(shape.points)
        plot.add_shape(p, fill_color=get_rand_color())
plot.save()

Which will result in this output: CaliforniaCounties

Additional Info

WKTPlot supports Bokeh's stylization parameters for customizing the look of added elemented. See this guide for more info: https://docs.bokeh.org/en/latest/docs/user_guide/styling.html

Future Plans

  • Add native support for visualizing GeoDataframes and shapefiles.
  • Make web view more interactive.

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

wktplot-1.0.0.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

wktplot-1.0.0-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file wktplot-1.0.0.tar.gz.

File metadata

  • Download URL: wktplot-1.0.0.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for wktplot-1.0.0.tar.gz
Algorithm Hash digest
SHA256 a57956331914a668b9ebd0a3b36c7bb6d1975d0bd5e3ca7dae347e95e9e3deb5
MD5 89bfb32809aa475e5a0b9c19bdcef8fe
BLAKE2b-256 2221ad2017cde07055eccc10ee2d992d44ef5833f724bc3456a3dac678abe9a8

See more details on using hashes here.

File details

Details for the file wktplot-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: wktplot-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for wktplot-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e053c9c742cbe8dc5ef424d634f769bf99a4352a498e239b48ef3f384f48dcae
MD5 479e680dee50732022ccba664514a30d
BLAKE2b-256 853bf1940ada321ca35c901faf55849bbc3f3f8ecdef482a7cf609c8b00090ca

See more details on using hashes here.

Supported by

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