descartes

Use geometric objects as matplotlib paths and patches
Download

descartes Ranking & Summary

Advertisement

  • Rating:
  • License:
  • BSD License
  • Price:
  • FREE
  • Publisher Name:
  • Sean Gillies
  • Publisher web site:
  • http://plone.org/products/pleiadesgeocoder

descartes Tags


descartes Description

Use geometric objects as matplotlib paths and patches descartes is a Python module that allows you to use Shapely or GeoJSON-like geometric objects as matplotlib paths and patches.Example:from matplotlib import pyplotfrom shapely.geometry import LineStringfrom descartes.patch import PolygonPatchline = LineString()fig = pyplot.figure(1, figsize=(7.5, 3), dpi=180)# 1ax = fig.add_subplot(121)dilated = line.buffer(0.5)patch1 = PolygonPatch(dilated, facecolor='#99ccff', edgecolor='#6699cc')ax.add_patch(patch1)x, y = line.xyax.plot(x, y, color='#999999')ax.set_xlim(-1, 4)ax.set_ylim(-1, 3)#2ax = fig.add_subplot(122)patch2a = PolygonPatch(dilated, facecolor='#cccccc', edgecolor='#999999')ax.add_patch(patch2a)eroded = dilated.buffer(-0.3)# GeoJSON-like data works as wellpolygon = eroded.__geo_interface__# >>> geo# 'Polygon'# >>> geo# ((0.50502525316941682, 0.78786796564403572), (0.5247963548222736, 0.8096820147509064))patch2b = PolygonPatch(polygon, facecolor='#99ccff', edgecolor='#6699cc')ax.add_patch(patch2b)ax.set_xlim(-1, 4)ax.set_ylim(-1, 3)fig.subplots_adjust(0.0, 0.0, 1.0, 1.0, 0.1)fig.savefig('buffering.png')See also: examples/patches.py. Requirements: · Python · Matplotlib · NumPy · Shapely


descartes Related Software