Package: wktplot
WKTPlotWrapper around theBokehlibrary for plotting well-known-text strings and shapely geometries!BadgesInstallationpipinstallwktplotDescriptionThewell-known-textstandard is very common for working with and representing geospatial data, however it is painful to visualize them programatically. TheShapelylibrary  extends the functionality of the well-known-text standard with a rich assortment of geometry objects and operations, but it doesn't make it any easier to visualize.WKTPlot is a library that provides an easy-to-use API for visualizing well-known-text strings and shapely objects programatically. This library wraps around theBokehlibrary, which is a powerful plotting library for generating interactive visualizations. Bokeh also provides a rich assortment ofstylizing optionswhich are all usable through WKTPlot'sadd_shapemethod.Supported datatypesWKTPlot supports the majority of well-known-text primitives, including:PointMultiPointLineStringMultiLineStringLinearRingPolygonMultiPolygonGeometryCollectionBasic Usagefromshapely.geometryimportLineStringfromwktplotimportWKTPlot# Create plot objectplot=WKTPlot(title="My first plot!",save_dir="/path/to/directory")# Define shapes either through well-known-text (WKT) string, or shapely objectline_string=LineString([[45,5],[30,-7],[40,10]])polygon="POLYGON ((35 10, 45 45, 15 40, 10 20, 35 10),(20 30, 35 35, 30 20, 20 30))"points="MULTIPOINT (17 11, 13 0, 22 -5, 25 7)"# Add shapes to the plot with style argsplot.add_shape(line_string,line_color="firebrick",line_alpha=0.5,line_width=20)plot.add_shape(polygon,fill_color="#6495ED",fill_alpha=0.5)plot.add_shape(points,fill_color=(50,205,50,0.25),fill_alpha=0.7,size=30)# Save plot to disk [/path/to/directory/my_first_plot.html]plot.save()OpenStreetMapsWKTPlot now supports the ability to integrate with OpenStreetMaps. Shape coordinates will be projected to the Mercator coordinate system, which appear to distort shape proportions compared to standard geometric projection.If your shape data has already been projected, you can disable the Mercator calculation by setting thedisable_mercatorparameter when creating the plot object. SeeAdvanced Usagefor an example.# Import OpenStreetMaps plotting classfromwktplot.plots.osmimportOpenStreetMapsPlot# Create plot object just like standard WKTPlot classplot=OpenStreetMapsPlot("Open Street Map Plot",save_dir="/path/to/directory")shape="POLYGON ((35 10, 45 45, 15 40, 10 20, 35 10), (20 30, 35 35, 30 20, 20 30))"plot.add_shape(shape,fill_alpha=0.5,fill_color="firebrick")plot.save()Advanced UsageExample for plotting from shapefile. Shapefile is of California's county boundaries, download fromhere.importshapefile# pyshp modulefrombokeh.palettesimportMagma6frompathlibimportPathfromrandomimportchoicefromshapely.geometryimportPolygonfromwktplot.plots.osmimportOpenStreetMapsPlotCOUNTIES_PATH=Path("/path/to/CA_Counties_TIGER2016.shp")# Create plot and disable mercator calculation# because data has already been projectedplot=OpenStreetMapsPlot(title="California Counties 2016",height=1000,width=1000,disable_mercator=True,)# Read shapefile data points from filewithshapefile.Reader(COUNTIES_PATH)asshp:forshapeinshp.shapes():plot.add_shape(shape=Polygon(shape.points),fill_color=choice(Magma6),fill_alpha=0.75,)# Save plot to disk [./california_counties_2016.html]plot.save()Which will result in this output:DevelopmentBugs / Feature RequestsPlease open anIssuein Github with any bugs found or feature requests, and follow the prompts so that developers can reproduce or implement the necessary changes.Local developmentDevelopment of this model is centered around the Makefile. All you need to spin up a working environment to build and test this module can be done with the Makefile.Clone the repository onto your machine.gitclonehttps://github.com/FuzzFoundation/WKTPlot.gitCreate the Python virtual environment and install module's development / testing dependencies. This will also install WKTPlot indevelop mode.makedevelopActivate virtual environmentsourcevenv/bin/activateRun linting and unittests.maketestWhen you want to remove the virtual environment and clean up after development.deactivate

makeclean# This will remove all generated files, like .coverage and build/makesparkling# This will remove all generate files and the virtual env.