diff --git a/geopandas/geoseries.py b/geopandas/geoseries.py index d1b1b1a..03b4f07 100644 --- a/geopandas/geoseries.py +++ b/geopandas/geoseries.py @@ -135,6 +135,33 @@ class GeoSeries(Series): return Series([s.contains(other) for s in self], index=self.index) + # TODO: refactor to eliminate replications + def difference(self, other): + """ + Return a GeoSeries of differences + Operates on either a GeoSeries or a Shapely geometry + """ + if isinstance(other, GeoSeries): + # TODO: align series + return GeoSeries([s[0].difference(s[1]) for s in zip(self, other)], + index=self.index) + else: + return GeoSeries([s.difference(other) for s in self], + index=self.index) + + def union(self, other): + """ + Return a GeoSeries of differences + Operates on either a GeoSeries or a Shapely geometry + """ + if isinstance(other, GeoSeries): + # TODO: align series + return GeoSeries([s[0].union(s[1]) for s in zip(self, other)], + index=self.index) + else: + return GeoSeries([s.union(other) for s in self], + index=self.index) + def buffer(self, distance, resolution=16): return GeoSeries([geom.buffer(distance, resolution) for geom in self], index=self.index)