I want to plot the Canadian shapefile with province boundaries highlighted and hollow filling.

I have downloaded the shapefile from here.

This is the script I use to visualize the shapefile:

import shapefile
import matplotlib.pyplot as plt
import matplotlib.patches as patches
from matplotlib.patches import Polygon
from matplotlib.collections import PatchCollection
#   -- input --
sf = shapefile.Reader("myfolder\gpr_000a11a_e.shp")
recs    = sf.records()
shapes  = sf.shapes()
Nshp    = len(shapes)
cns     = []
for nshp in xrange(Nshp):
cns = array(cns)
cm    = get_cmap('Dark2')
cccol = cm(1.*arange(Nshp)/Nshp)
#   -- plot --
fig     = plt.figure()
ax      = fig.add_subplot(111)
for nshp in xrange(Nshp):
    ptchs   = []
    pts     = array(shapes[nshp].points)
    prt     = shapes[nshp].parts
    par     = list(prt) + [pts.shape[0]]
    for pij in xrange(len(prt)):
    ax.add_collection(PatchCollection(ptchs,facecolor=cccol[nshp,:],edgecolor='k', linewidths=.1))

The output is confusing, in that the Northern border is completely wrong and it does not resemble the real one. I think there are unwanted lines that connect points far away from each other. As a result, the islands in Northern Nunavut have been merged in a single polygon. How to obtain a neat border?

enter image description here

1 Answer 1


The polygon is not "wrong", it's just not representing landmass enter image description here

It uses 1 polygon for each province.

You can find polygons representing Canada's borders and land surface on GADM or DIVA-GIS

  • And do you know where I can get a shapefile representing the true landmass?
    – FaCoffee
    Jun 21, 2016 at 10:51
  • 1
    @CF84 I've just edited my answer, take a look at the links. you can always do a search for "Canada District Shapefile" and find plenty of results as well
    – HDunn
    Jun 21, 2016 at 10:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.