我想在Mercator投影的地图上创建一个数据散点图。只有当我在Mercator中设置投影时,它才会打印没有值的空映射。但是,如果我选择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打印空地图:
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我在其他问题上找不到我的例子
发布于 2022-12-03 10:37:52
在墨卡托投影上绘制的地质数据图的演示。
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())

https://stackoverflow.com/questions/74656553
复制相似问题