In [3]:
%matplotlib inline
import shapefile

In [4]:
import matplotlib.pyplot as plt
import numpy as np

In [5]:
midori_sh = shapefile.Reader("A002005212010XYSJC23114/h22ka23114.shp")
kita_sh = shapefile.Reader("A002005212010XYSWC23103/h22ka23103.shp")

In [6]:
# kita_sh.records

In [7]:
kita_sh_list = kita_sh.shapes()
midori_sh_list = midori_sh.shapes()

In [8]:
for i in kita_sh.records():
#     print i[28].decode("sjis")
    pass
print kita_sh.records()[0]


[22144.11, 735.983, 0, 0, '23', '103', '\x88\xa4\x92m\x8c\xa7', '                      ', '\x96\xbc\x8c\xc3\x89\xae\x8es', '\x96k\x8b\xe6', 8101, '0380', '-', '20', '103038020', '103038020', 'M', '  ', '  ', '   ', 0, '   ', ' ', 0, 0, 50, 10, 10, '\x93\xed\x92\xac\x91\xe5\x8e\x9a\x94@\x88\xd3\x8c\xe4\x89\xd4\x8aX\x93\xb9', 2100, 1, 1, 0, 0, 136.92955, 35.24236, '0380-20', '23103038020', 0, 0, 0, 0, 2101, 2100]

In [9]:
kita_sh.shapeName


Out[9]:
'A002005212010XYSWC23103/h22ka23103'

In [10]:
f = open("test.txt", "w")
for i, j in zip(kita_sh_list, kita_sh.records()):
    aa = np.array(i.points).transpose()
    machiname = j[28].decode("sjis")
    f.write("{}\n".format(machiname.encode("utf-8")))
    plt.plot(aa[0], aa[1], label=machiname)
    plt.axis("equal")
#     plt.legend()
# f = open("test.txt", "w")
# f.write("teset")
f.close()
# for i in midori_sh_list:
#     bb = np.array(i.points).transpose()
#     plt.plot(bb[0], bb[1])
#     plt.axis("equal")



In [11]:
import xml.dom.minidom

In [12]:
dom1 = xml.dom.minidom.parse("PackDLMap/FG-GML-523646-12-20150101/FG-GML-523646-CommBdry-20150101-0001.xml")

In [13]:
test = []
for i in dom1.getElementsByTagName("CommBdry"):
    for j in i.getElementsByTagName("gml:posList"):
        test.append([k.rsplit() for k in j.childNodes[0].data.rsplit("\n")][1:-1])

In [14]:
for tes in test:
    nakami = np.array(tes, dtype=np.float64).transpose()
    plt.plot(nakami[1], nakami[0])
plt.axis("equal")


Out[14]:
(136.74000000000001, 136.88, 35.0, 35.090000000000003)

In [15]:
japan_sh = shapefile.Reader("japan_ver72.shp")

In [20]:
for i in japan_sh.shapes():
    testlist = np.array(i.points).transpose()
    plt.plot(testlist[0], testlist[1], lw=0.1)
plt.axis("equal")
plt.savefig("japan.pdf", dpi=300)



In [16]: