日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > python >内容正文

python

Python数据可视化:Cartopy 地理空间数据可视化

發(fā)布時(shí)間:2024/1/8 python 47 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Python数据可视化:Cartopy 地理空间数据可视化 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

前言

Cartopy 是為了向 Python 添加地圖制圖功能而開發(fā)的擴(kuò)展庫。該項(xiàng)目致力于以 matplotlib 包為基礎(chǔ),用簡(jiǎn)單直觀的方式操作各類地理要素的成圖。Cartopy 官網(wǎng)的畫廊頁面已經(jīng)提供了很多繪圖的例子,它們和官方文檔一起,是學(xué)習(xí)該工具的主要材料。

繪制 IGS 站點(diǎn)分布圖

本圖使用的 IGS 核心站與 MGEX 項(xiàng)目站點(diǎn),及其坐標(biāo)均來自 IGS 網(wǎng)站。我已經(jīng)將其整理成為 igs-core 和 mgex 兩個(gè) CSV 文件,你可以直接下載。

?

IGS 核心站與 MGEX 站點(diǎn)分布圖

import numpy as np import matplotlib.pyplot as plt import cartopy.crs as ccrs import cartopy.feature as cfeature# Load the coordinate of IGS Core & MGEX sites, The CSV files are # exported from: http://www.igs.org/network igs_core = np.recfromcsv('igs-core.csv', names=True, encoding='utf-8') mgex = np.recfromcsv('mgex.csv', names=True, encoding='utf-8')fig = plt.figure(figsize=[9, 6]) # Set projection ax = plt.axes(projection=ccrs.Robinson()) # Add ocean and land ax.add_feature(cfeature.LAND) ax.add_feature(cfeature.OCEAN) # Add MGEX & IGS core sites ax.plot(mgex['longitude'], mgex['latitude'], 'o', color='tomato',label='MGEX', transform=ccrs.Geodetic()) ax.plot(igs_core['longitude'], igs_core['latitude'], '*', color='darkmagenta',label='IGS Core', transform=ccrs.Geodetic()) # Plot gridlines ax.gridlines(linestyle='--') # Set figure extent ax.set_global() # Set legend location plt.legend(loc='lower right') # Show figure plt.show()

PS:如有需要Python學(xué)習(xí)資料的小伙伴可以加下方的群去找免費(fèi)管理員領(lǐng)取

?

可以免費(fèi)領(lǐng)取源碼、項(xiàng)目實(shí)戰(zhàn)視頻、PDF文件

?

繪制 GNSS 控制網(wǎng)

這里使用的 IGS 站點(diǎn)坐標(biāo)數(shù)據(jù)同樣來自 IGS 網(wǎng)站。我已將其整理成一個(gè) CSV 格式的文件:euro-igs,你可以直接下載使用。這里使用 matplotlib.tri 中的 Triangulation 來根據(jù)輸入的點(diǎn)位坐標(biāo)來創(chuàng)建 Delaunay 三角網(wǎng),然后使用 plt.triplot() 方法繪制。

?

GNSS 控制網(wǎng)

import numpy as np import matplotlib.pyplot as plt import matplotlib.tri as tri import cartopy.crs as ccrs import cartopy.feature as cfeature# Load coordinate of the IGS sites in Europe, this CSV file is # exported from: http://www.igs.org/network igs_sites = np.recfromcsv('euro-igs.csv', names=True, encoding='utf-8') # Generate Delaunay triangles triangles = tri.Triangulation(igs_sites['longitude'], igs_sites['latitude'])fig = plt.figure(figsize=[6, 8]) # Set projection ax = plt.axes(projection=ccrs.LambertConformal(central_latitude=90,central_longitude=10)) # Add ocean, land, rivers and lakes ax.add_feature(cfeature.OCEAN.with_scale('50m')) ax.add_feature(cfeature.LAND.with_scale('50m')) ax.add_feature(cfeature.RIVERS.with_scale('50m')) ax.add_feature(cfeature.LAKES.with_scale('50m')) # Plot triangles plt.triplot(triangles, transform=ccrs.Geodetic(), marker='o', linestyle='-') # Plot gridlines ax.gridlines(linestyle='--') # Set figure extent ax.set_extent([-10, 30, 30, 73]) # Show figure plt.show()

繪制板塊分布圖

板塊構(gòu)造理論將地球的巖石圈分為十?dāng)?shù)個(gè)大小不等的板塊。本圖使用的 Nuvel 板塊邊界數(shù)據(jù)來自 EarthByte 網(wǎng)站,我已經(jīng)將其整理為一個(gè)壓縮文件,你可以直接下載使用。

?

Nuvel 板塊分布圖

import numpy as np import matplotlib.pyplot as plt import cartopy.crs as ccrs# The plate boundary files files = ['African.txt', 'Antarctic.txt', 'Arabian.txt', 'Australian.txt','Caribbean.txt', 'Cocos.txt', 'Eurasian.txt', 'Indian.txt', 'Juan.txt','Nazca.txt', 'North_Am.txt', 'Pacific.txt', 'Philippine.txt','Scotia.txt', 'South_Am.txt'] # Read boundaries into numpy borders = [] for f in files:border = np.genfromtxt(f, names=['lon', 'lat'], dtype=float, comments=':')borders.append(border) # Plate names plates = ['African', 'Antarctic', 'Arabian', 'Australian', 'Caribbean', 'Cocos','Eurasian', 'Indian', 'Juan', 'Nazca', ' North\nAmerican', 'Pacific','Philippine', 'Scotia', ' South\nAmerican'] # Central point for every plate, just for text positioning central = [(17, -5), (90, -80), (40, 21), (120, -28), (270, 12), (260, 6),(60, 50), (70, 13), (230, 45), (260, -21), (250, 36), (190, 0),(123, 17), (304, -59), (315, -27)]# Start plot fig = plt.figure(figsize=(12, 7)) ax = plt.axes(projection=ccrs.Mollweide(central_longitude=120)) # Plot a image as background ax.stock_img() # Plot boundaries for plate, center, border in zip(plates, central, borders):ax.plot(border['lon'], border['lat'], color='coral',transform=ccrs.Geodetic())ax.text(center[0], center[1], plate, transform=ccrs.Geodetic())plt.show()

本文的文字及圖片來源于網(wǎng)絡(luò),僅供學(xué)習(xí)、交流使用,不具有任何商業(yè)用途,版權(quán)歸原作者所有,如有問題請(qǐng)及時(shí)聯(lián)系我們以作處理。

以下文章來源于EasyShu?,作者姜英明

總結(jié)

以上是生活随笔為你收集整理的Python数据可视化:Cartopy 地理空间数据可视化的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。