from geopandas import GeoSeries
from shapely.geometry import Polygon, Point, LineString
pylab.rcParams['savefig.dpi'] = 100
poly1 = Polygon([(0, 0), (1, 0), (1, 1)])
poly2 = Polygon([(2, 0), (3, 0), (3, 1), (2, 1)])
circle = Point([(1.5, 0.5)]).buffer(0.5)
g = GeoSeries([poly1, circle, poly2])
print g
0 POLYGON ((0.0000000000000000 0.000000000000000... 1 POLYGON ((2.0000000000000000 0.500000000000000... 2 POLYGON ((2.0000000000000000 0.000000000000000... dtype: object
g.plot()
<matplotlib.axes.AxesSubplot at 0x105a5b950>
Now we create a new series that has
big_circle = Point([1.5, 1.0]).buffer(0.9)
g.plot()
GeoSeries([big_circle]).plot()
<matplotlib.axes.AxesSubplot at 0x10bf238d0>
g.difference(big_circle)
0 POLYGON ((1.0000000000000000 0.251669431327654... 1 POLYGON ((1.8929164090542658 0.191447836648926... 2 POLYGON ((2.3999999999999999 1.000000000000000... dtype: object
g.difference(big_circle).plot()
<matplotlib.axes.AxesSubplot at 0x10bcf8690>
pts = GeoSeries([Point([0,0]), LineString([[1.5, 1], [1.5, 1.5]]), Point([3,0])])
c = pts.buffer(0.5)
g.plot()
c.plot()
<matplotlib.axes.AxesSubplot at 0x10bcf4250>
g.union(c).plot()
<matplotlib.axes.AxesSubplot at 0x10bcf1fd0>
g.intersection(c).plot()
<matplotlib.axes.AxesSubplot at 0x10bcf1390>