简体   繁体   中英

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

I am new to Geopandas. How can I draw a circle over a map? I would like to define LAT/LON and radius and then draw it on the 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?

Fortunately, the projection "EPSG:3395" is a conformal projection. To draw (projections of) circles on a conformal projection use .tissot() method available with cartopy's geoaxes . 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)

天梭

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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