現在、heatmap.py を使用して Google マップにヒートマップ オーバーレイを生成しようとしています。heatmap.py を説明しているサイト (http://jjguy.com/heatmap/) には、ワシントン DC の美しいヒートマップの写真と、それを生成するために使用されたコードが示されています。ただし、コードを実行すると、次の KML 出力が得られます。
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Folder>
<GroundOverlay>
<Icon>
<href>classic.png</href>
</Icon>
<LatLonBox>
<north>38.9096822126249293</north>
<south>38.8880342183292171</south>
<east>-77.0127326291108432</east>
<west>-77.0498038539626435</west>
<rotation>0</rotation>
</LatLonBox>
</GroundOverlay>
</Folder>
</kml>
これはただの長方形の箱です。さらに、ソースコードを調べたところ、次のことがわかりました。
KML = """<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Folder>
<GroundOverlay>
<Icon>
<href>%s</href>
</Icon>
<LatLonBox>
<north>%2.16f</north>
<south>%2.16f</south>
<east>%2.16f</east>
<west>%2.16f</west>
<rotation>0</rotation>
<GroundOverlay>
<Icon>
<href>%s</href>
</Icon>
<LatLonBox>
<north>%2.16f</north>
<south>%2.16f</south>
<east>%2.16f</east>
<west>%2.16f</west>
<rotation>0</rotation>
</LatLonBox>
</GroundOverlay>
</Folder>
</kml>"""
def saveKML(self, kmlFile):
"""
Saves a KML template to use with google earth. Assumes x/y coordinates
are lat/long, and creates an overlay to display the heatmap within Google
Earth.
kmlFile -> output filename for the KML.
"""
tilePath = os.path.basename(self.imageFile)
north = self.maxXY[1]
south = self.minXY[1]
east = self.maxXY[0]
west = self.minXY[0]
bytes = KML % (tilePath, north, south, east, west)
file(kmlFile, "w").write(bytes)
出力が示唆することを正確に行うようです。heatmap.pyを使用して、写真に似たヒートマップを生成できた人はいますか? そうでない場合、別の方法を使用して同様のヒートマップを生成できましたか? ありがとう。