Python - 地理資料



許多開源 Python 庫現已建立用於表示地理地圖。它們具備高度可定製性,並提供多種形狀和顏色的地圖,描繪不同區域。Cartopy 就是其中之一。你可以從 Cartopy 下載並在自己本地環境中安裝此軟體包。你可以在其相簿中找到許多示例。

在下例中,我們展示了世界地圖的一部分,顯示了亞洲和澳大利亞的部分地區。你可以調整方法 set_extent 中的引數值,以定位世界地圖的不同區域。

import matplotlib.pyplot as plt
import cartopy.crs as ccrs    

fig = plt.figure(figsize=(15, 10))
ax = fig.add_subplot(1, 1, 1, projection=ccrs.PlateCarree())

    # make the map global rather than have it zoom in to
    # the extents of any plotted data

ax.set_extent((60, 150, 55, -25))

ax.stock_img()
ax.coastlines()

ax.tissot(facecolor='purple', alpha=0.8)

plt.show()

它的輸出如下 -

geographic.png
廣告