mirror of
https://github.com/wassname/geopandas.git
synced 2026-10-03 12:31:14 +08:00
Implement union and difference methods.
This commit is contained in:
1 parent
8445f85ca1
commit
be4a1efa4e
1 file changed
+27
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user