0
我目前正在嘗試使用heatmap.py生成熱圖覆蓋圖到Google地圖。描述heatmap.py的站點(http://jjguy.com/heatmap/)顯示華盛頓特區上的一張美麗熱圖的圖片以及用於生成它的代碼。運行代碼後,但是,我得到以下KML輸出:使用heatmap.py生成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生成類似於圖片的熱圖。如果沒有,您是否能夠使用其他方法生成類似的熱圖?謝謝。