new_cut_ply = []

# identify which new polygon we want to keep
for poly in new_polygons:
    # check if new poly is inside original otherwise ignore it
    if poly.centroid.within(polygon):
        # center_pt = poly.centroid
        # ax.plot(center_pt.x, center_pt.y, 'o', color='#999999')
        print "creating new split polygon"
        patch3 = PolygonPatch(poly, fc='purple', alpha=0.5, zorder=2)
        ax.add_patch(patch3)
        # add only polygons that overlap original for export
        new_cut_ply.append(poly)
    else:
        # draw centroid of new polygon NOT inside original polygon
        # center_pt = poly.centroid
        # ax.plot(center_pt.x, center_pt.y, 'o', color='#FF1813')
        print "This polygon is outside of the input features"

# write title of second plot
ax.set_title('Line intersects circle')

# define the area that plot will fit into
x_range = set_plot_bounds(polygon, 1.5)['xrange']
y_range = set_plot_bounds(polygon, 1)['yrange']

ax.set_xlim(*x_range)
ax.set_ylim(*y_range)
ax.set_aspect(1)

pyplot.show()
# identify which new polygon we want to keep
for poly in new_polygons:
    # check if new poly is inside original otherwise ignore it
    if poly.centroid.within(polygon):
        # center_pt = poly.centroid
        # ax.plot(center_pt.x, center_pt.y, 'o', color='#999999')
        print "creating new split polygon"
        patch3 = PolygonPatch(poly, fc='purple',
                              alpha=0.5, zorder=2)
        ax.add_patch(patch3)
        # add only polygons that overlap original for export
        new_cut_ply.append(poly)
    else:
        # draw centroid of new polygon NOT inside original polygon
        # center_pt = poly.centroid
        # ax.plot(center_pt.x, center_pt.y, 'o', color='#FF1813')
        print "This polygon is outside of the input features"


# write title of second plot
ax.set_title('Line intersects circle')

# define the area that plot will fit into
x_range = set_plot_bounds(polygon, 1.5)['xrange']
y_range = set_plot_bounds(polygon, 1)['yrange']

ax.set_xlim(*x_range)
ax.set_ylim(*y_range)
ax.set_aspect(1)

pyplot.show()
Example #3
0
#####################################
#      plot with Matplotlib
#  display symmetric difference
# ###################################

# setup matplotlib figure that will display the results
fig = pyplot.figure(1, figsize=SIZE, dpi=90, facecolor="white")

# add a little more space around subplots
fig.subplots_adjust(hspace=.5)

ax = fig.add_subplot(111)

# draw each MultiPolygon green
for poly in result:
    patch3 = PolygonPatch(poly, fc='green', alpha=0.5, zorder=2)
    ax.add_patch(patch3)

ax.set_title('symmetric difference')

# define the area that plot will fit into
x_range = set_plot_bounds(result, 50)['xrange']
y_range = set_plot_bounds(result, 50)['yrange']

ax.set_xlim(*x_range)
ax.set_ylim(*y_range)
ax.set_aspect(1)

pyplot.show()