本文整理匯總了Python中descartes.PolygonPatch方法的典型用法代碼示例。如果您正苦於以下問題:Python descartes.PolygonPatch方法的具體用法?Python descartes.PolygonPatch怎麽用?Python descartes.PolygonPatch使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類descartes
的用法示例。
在下文中一共展示了descartes.PolygonPatch方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: plot_filled_polygons
# 需要導入模塊: import descartes [as 別名]
# 或者: from descartes import PolygonPatch [as 別名]
def plot_filled_polygons(self,polygons, facecolour='green', edgecolour='black', linewidth=1, alpha=0.5):
"""
This function plots a series of shapely polygons but fills them in
Args:
ax_list: list of axes
polygons: list of shapely polygons
Author: FJC
"""
from shapely.geometry import Polygon
from descartes import PolygonPatch
from matplotlib.collections import PatchCollection
print('Plotting the polygons...')
#patches = []
for key, poly in polygons.items():
this_patch = PolygonPatch(poly, fc=facecolour, ec=edgecolour, alpha=alpha)
self.ax_list[0].add_patch(this_patch)
示例2: PlotPolygons
# 需要導入模塊: import descartes [as 別名]
# 或者: from descartes import PolygonPatch [as 別名]
def PlotPolygons(Polygons, Map=None, Ax=None, OutlineColour='k', FillColour='w', ColourMap="None", alpha=0.5):
"""
Function to plot polygons from a shapely Polygon Dictionary
Modified from PlottingRaster.py code by FJC
Outline colour can be name, tuple or range of value to shade
MDH
"""
#create a figure if one doesnt already exist?
if Ax == None:
print("PlotPolygons: Warning, no axes provided, creating new figure and axes")
Fig = plt.figure()
Ax = plt.gca()
plt.axis('equal')
plt.xlabel('Longitude ($^o$)')
plt.ylabel('Latitude ($^o$)')
# convert to map coordinates
if Map != None:
Polygons = ConvertPolygonsLatLong2MapCoords(Polygons, Map)
# loop through shapes in polygons and plot patches
for Key, Poly in Polygons.iteritems():
if Poly.geom_type == 'Polygon':
Patch = PolygonPatch(Poly,fc=FillColour,ec=OutlineColour,alpha=alpha)
Ax.add_patch(Patch)
elif Poly.geom_type == 'MultiPolygon':
for singlepoly in Poly:
Patch = PolygonPatch(singlepoly,fc=FillColour,ec=OutlineColour,alpha=alpha)
Ax.add_patch(Patch)
if Ax == None:
Ax.autoscale_view()
示例3: plot_polygon
# 需要導入模塊: import descartes [as 別名]
# 或者: from descartes import PolygonPatch [as 別名]
def plot_polygon(ax,polygon):
# fig = plt.figure(figsize=(10,10))
# ax = fig.add_subplot(111)
# margin = .3
# x_min, y_min, x_max, y_max = polygon.bounds
# ax.set_xlim([x_min-margin, x_max+margin])
# ax.set_ylim([y_min-margin, y_max+margin])
patch = PolygonPatch(polygon, fc='#999999',
ec='#000000', fill=True,
zorder=-1)
ax.add_patch(patch)
return
示例4: plot_polygon
# 需要導入模塊: import descartes [as 別名]
# 或者: from descartes import PolygonPatch [as 別名]
def plot_polygon(polygon):
fig = pl.figure(figsize=(10, 10))
ax = fig.add_subplot(111)
margin = .3
print(polygon)
x_min, y_min, x_max, y_max = polygon.bounds
ax.set_xlim([x_min - margin, x_max + margin])
ax.set_ylim([y_min - margin, y_max + margin])
patch = PolygonPatch(polygon, fc='#999999',
ec='#000000', fill=True,
zorder=-1)
ax.add_patch(patch)
return fig