adding basic support for plotting shapelylinestrings in GeoSeries objects

This commit is contained in:
Alexander Crosby committed 2013-07-09 12:37:32 -04:00
1 parent 6380fb5992
commit 3bdc5c7076
1 file changed
+9 -1
+9 -1
View File
@@ -4,7 +4,7 @@ from pandas.core.common import isnull
import matplotlib.pyplot as plt
from matplotlib import cm
from shapely.geometry import shape, Polygon, Point
from shapely.geometry import shape, Polygon, Point, LineString
from shapely.geometry.collection import GeometryCollection
from shapely.geometry.base import BaseGeometry
from shapely.ops import cascaded_union, unary_union
@@ -14,6 +14,7 @@ from descartes.patch import PolygonPatch
EMPTY_COLLECTION = GeometryCollection()
EMPTY_POLYGON = Polygon()
EMPTY_POINT = Point()
EMPTY_LINE = LineString()
def _plot_polygon(ax, poly, facecolor='red', edgecolor='black', alpha=0.5):
@@ -41,6 +42,11 @@ def _plot_point(ex, geom):
"""
pass
def _plot_line(ax, geom, edgecolor="black", alpha=1.0):
""" Plot Shapley LineString geometries
"""
x, y = geom.xy
ax.plot(x, y, color=edgecolor, solid_capstyle='round', zorder=1)
def _gencolor(N, colormap='Set1'):
"""
@@ -449,6 +455,8 @@ class GeoSeries(Series):
_plot_multipolygon(ax, geom, facecolor=color.next())
elif geom.type == 'Point':
_plot_point(ax, geom)
elif geom.type == 'LineString':
_plot_line(ax, geom, edgecolor=color.next())
return ax
if __name__ == '__main__':