簡體   English   中英

Cartopy 墨卡托 plot

[英]Cartopy Mercator plot

我想在墨卡托投影中的 map 上創建數據散點 plot。 如果我在 Mercator 中設置投影,它只會打印沒有值的空 map。 但是,如果我選擇 PlateCarree 投影就沒有問題....

工作正常:

ax1=plt.axes(projection=ccrs.PlateCarree())
ax1.add_feature(cf.BORDERS)
ax1.add_feature(cf.COASTLINE)
ax1.add_feature(cf.BORDERS)
ax1.add_feature(cf.STATES)
ax1.set_extent([-5, 10, 41, 52], crs=ccrs.PlateCarree())
ax1.set_title('xxx', fontsize=18);
ax1.grid(b=True, alpha=0.5)
obs200.plot(x="longitude", y="latitude", kind="scatter", c="mm", ax=ax1, cmap = "jet",
       figsize=(18,20), title="xxx") # latitude: Breitengrad, longitude: Längengrad

打印空 map:

ax1=plt.axes(projection=ccrs.Mercator())
ax1.add_feature(cf.BORDERS)
ax1.add_feature(cf.COASTLINE)
ax1.add_feature(cf.BORDERS)
ax1.add_feature(cf.STATES)
ax1.set_extent([-5, 10, 41, 52], crs=ccrs.Mercator())
ax1.set_title('xxx', fontsize=18);
ax1.grid(b=True, alpha=0.5)
obs200.plot(x="longitude", y="latitude", kind="scatter", c="mm", ax=ax1, cmap = "jet",
       figsize=(18,20), title="xxx") # latitude: Breitengrad, longitude: Längengrad

我在其他問題中找不到我的例子

在墨卡托投影上繪制的地理數據框的演示。

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

# These are Geodataframes with world/city data
# Their CRS is ccrs.PlateCarree()
world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
city_pnts = gpd.read_file(gpd.datasets.get_path("naturalearth_cities"))

# Geometries in the 2 Geodataframes have CRS transformed
#  to Mercator projection here
mercator = ccrs.Mercator()
wld2 = world.to_crs(mercator.proj4_init)
cty2 = city_pnts.to_crs(mercator.proj4_init)

# Plot them with matplotlib
#  with projection = ccrs.Mercator()
fig, ax2 = plt.subplots(figsize=[8,6], subplot_kw=dict(projection=mercator))
ax2.add_geometries(wld2['geometry'], crs=mercator, facecolor='sandybrown', edgecolor='black')

# Use ax2 to plot other data
cty2.plot(ax=ax2, zorder=20)

# This sets extent of the plot
ax2.set_extent([-15, 25, 30, 60], crs=ccrs.PlateCarree())

輸出圖

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM