From 3bdc5c70760db2c8f3ab9a799a38f7d7bbae4134 Mon Sep 17 00:00:00 2001 From: Alexander Crosby Date: Tue, 9 Jul 2013 12:37:32 -0400 Subject: [PATCH] adding basic support for plotting shapelylinestrings in GeoSeries objects --- geopandas/geoseries.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/geopandas/geoseries.py b/geopandas/geoseries.py index 4d7207b..3e0f5ed 100644 --- a/geopandas/geoseries.py +++ b/geopandas/geoseries.py @@ -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__':