首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Cartopy Mercator图

Cartopy Mercator图
EN

Stack Overflow用户
提问于 2022-12-02 13:30:19
回答 1查看 21关注 0票数 0

我想在Mercator投影的地图上创建一个数据散点图。只有当我在Mercator中设置投影时,它才会打印没有值的空映射。但是,如果我选择PlateCarree投影.没有问题.

工作良好:

代码语言:javascript
复制
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

打印空地图:

代码语言:javascript
复制
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

我在其他问题上找不到我的例子

EN

回答 1

Stack Overflow用户

发布于 2022-12-03 10:37:52

在墨卡托投影上绘制的地质数据图的演示。

代码语言:javascript
复制
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())

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74656553

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档