Python wrapper for visualiation of shapely geometries.
Project description
WKTPlot
Plot well-known-text strings and shapely geometries with Bokeh!
Badges
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:
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
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
wktplot-1.0.1.tar.gz
(8.2 kB
view details)
Built Distribution
File details
Details for the file wktplot-1.0.1.tar.gz
.
File metadata
- Download URL: wktplot-1.0.1.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 37550535cd32ab6ad0f11769ec73c0231fd1828dd7d2fed689ed335b23984c53 |
|
MD5 | 737809776653d6b5c4cc6082b981a492 |
|
BLAKE2b-256 | db0bee0a4efb367d8f6a71c438e10afd4a112e4d30b88bec33095ac192cb493a |
File details
Details for the file wktplot-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: wktplot-1.0.1-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1cef6638e169bb989c24bc69473a9ee80b864d68a8341129557af30c57175cf0 |
|
MD5 | 087e53c8c43fc202c534641267d825cc |
|
BLAKE2b-256 | 3b3631d95f3e5a66c510db34d03b5e73612e73901468be391df14e73846e8063 |