【问题标题】:How to plot a some circle with LAT LON and Radius in Geopandas/Matplotlib?如何在 Geopandas/Matplotlib 中用 LAT LON 和 Radius 绘制一个圆?
【发布时间】:2021-05-26 15:38:10
【问题描述】:

我是 Geopandas 的新手。如何在地图上画一个圆圈?我想定义 LAT/LON 和半径,然后在地图上绘制。

这就是我想要的:

代码如下:

import matplotlib.pyplot as plt
import geopandas
plt.rcParams["font.family"] = "Times New Roman"

states = geopandas.read_file('data/usa-states-census-2014.shp')
type(states)
states.crs

states = states.to_crs("EPSG:3395")

states.boundary.plot(figsize=(18, 12), color="Black")
plt.show()

如何根据纬度/经度和半径绘制圆?

【问题讨论】:

  • 你试过我的代码了吗?还有什么问题吗?
  • 我认为您提供的代码可以工作,但在尝试安装 cartopy 时出现错误:错误:无法为使用 PEP 517 且无法直接安装的 cartopy 构建轮子

标签: python matplotlib geopandas


【解决方案1】:

幸运的是,投影“EPSG:3395”是保形投影。要在等角投影上绘制(投影)圆,请使用 cartopy 的geoaxes 提供的.tissot() 方法。以下是演示重要步骤的部分代码:

ax2 = plt.subplot(111, projection=ccrs.epsg(3395))  #"EPSG:3395"

# usa_main is a geoDataFrame with crs="EPSG:3395"
usa_main.plot(column="sclass", legend=False, 
              cmap=matplotlib.cm.Reds, 
              ec=edgecolor, lw=0.4,
              alpha=0.5,
              ax=ax2)

# plot circle at 2 locations with different radii
ax2.tissot(rad_km=300, lons=[-95.4,], lats=[29.7,], n_samples=36, zorder=10)
ax2.tissot(rad_km=500, lons=[-81.3,], lats=[28.5,], n_samples=36, zorder=10)

ax2.gridlines(crs=ccrs.PlateCarree(), draw_labels=True)

【讨论】:

    猜你喜欢
    • 2013-11-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-27
    • 2017-01-06
    • 2012-01-08
    相关资源
    最近更新 更多