パイクラおじさんの日記

MinecraftでPythonを勉強するおじさんの日記です。

土地利用細分メッシュ

国土数値情報ダウンロードサービス

続いて、土地利用細分メッシュもマップとして表示してみた。

f:id:pycra:20171008122739p:plain

細分とはいえ、100mメッシュなのでこれも厳しい。

# coding: utf-8

import xml.etree.ElementTree as ET
import numpy as np
import matplotlib.pyplot as plot
import sys


JPGIS_FILE = "JPGIS/5340/L03-b-14_5340-jgd_GML/L03-b-14_5340.xml"

tree = ET.parse(JPGIS_FILE)
root = tree.getroot()

for e in root.getiterator():
    print(e.tag)

tl = root.find('./{http://nlftp.mlit.go.jp/ksj/schemas/ksj-app}LanduseSubdivisionMesh/{http://nlftp.mlit.go.jp/ksj/schemas/ksj-app}coverage/{http://www.opengis.net/gml/3.2}rangeSet/{http://www.opengis.net/gml/3.2}DataBlock/{http://www.opengis.net/gml/3.2}tupleList')
if tl is None:
    raise Exception("{http://www.opengis.net/gml/3.2}tupleList is not found")

lines = tl.text.split("\n")
print("lines=", len(lines))
array = np.empty((800,800), dtype=int)
i = 0
for l in lines:
    print("i=",i)
    d = l.split(" ")
    d.pop(0)
    d = np.array(d, dtype=int)
    print("len(d)=",len(d))
    if len(d) == 800:
        print(d)
        print(len(array[i]))
        array[i] = d
        i += 1

plot.imshow(array, interpolation='nearest')
plot.colorbar()
plot.show()