简体   繁体   English

如何在 Geopandas/Matplotlib 中使用 LAT LON 和半径 plot 一个圆?

[英]How to plot a some circle with LAT LON and Radius in Geopandas/Matplotlib?

I am new to Geopandas.我是 Geopandas 的新手。 How can I draw a circle over a map?如何在 map 上画一个圆圈? I would like to define LAT/LON and radius and then draw it on the map.我想定义 LAT/LON 和半径,然后在 map 上绘制它。

This is what I want:这就是我要的:

在此处输入图像描述

Here is the code:这是代码:

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()

How do I plot the circles based on Lat/Long and Radius?我如何 plot 基于纬度/经度和半径的圆圈?

Fortunately, the projection "EPSG:3395" is a conformal projection.幸运的是,投影“EPSG:3395”是保角投影。 To draw (projections of) circles on a conformal projection use .tissot() method available with cartopy's geoaxes .要在等角投影上绘制(投影)圆,请使用 cartopy 的geoaxes可用的.tissot()方法。 Here is a partial code that demonstrates the important steps:这是演示重要步骤的部分代码:

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)

天梭

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM