Skip to content

Instantly share code, notes, and snippets.

@alexrutherford
Created October 28, 2015 17:09
Show Gist options
  • Select an option

  • Save alexrutherford/072ea05d98843789ccda to your computer and use it in GitHub Desktop.

Select an option

Save alexrutherford/072ea05d98843789ccda to your computer and use it in GitHub Desktop.
import shapefile
sf = shapefile.Reader("data/test.shp")
fig=plt.figure()
ax=fig.add_subplot(111)
for nshp in xrange(len(shapes)):
ptchs = []
pts = np.array(shapes[nshp].points)
prt = shapes[nshp].parts
par = list(prt) + [pts.shape[0]]
for pij in xrange(len(prt)):
ptchs.append(Polygon(pts[par[pij]:par[pij+1]]))
plt.plot(pts[par[pij:0],par[pij+1:1]])
ax.add_collection(PatchCollection(ptchs,edgecolor='white', linewidths=0.5))
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment