import shapefile
sf = shapefile.Reader('GMJ/data/org/all_japan_d_a.shp','r', encoding='shift-jis')
shapes = sf.shapes()
records = sf.records()
west, east, south, north = 140, 141, 42, 43
idc_region = [i for i, s in enumerate(shapes)
if west < s.bbox[2] and s.bbox[0] < east and
south < s.bbox[3] and s.bbox[1] < north]
shapes_region = [shapes[idx] for idx in idc_region]
records_region = [records[idx] for idx in idc_region]
m = Basemap(llcrnrlon=west, llcrnrlat=south,
urcrnrlon=east, urcrnrlat=north, resolution='i')
m.drawcoastlines(linewidth=0.4)
for s, r in zip(shapes_region, records_region):
lons, lats = [], []
parts = list(s.parts)
for p0, p1 in zip(parts, parts[1:]+[len(s.points)]):
lons += [np.nan] + [p[0] for p in s.points[p0:p1]]
lats += [np.nan] + [p[1] for p in s.points[p0:p1]]
plt.fill(lons, lats, color='hotpink', alpha=0.3)
plt.plot(lons, lats, linewidth=0.5, color='gray')
plt.show()