How to draw circle in basemap or add artiste

后端 未结 2 924
日久生厌
日久生厌 2021-01-25 18:39

I want to know how can i plot a circle with Basemap using latitude and longitude.

import matplotlib.pyplot as plt
fig,ax = plt.subplots()
ax.axis([0,10,0,10])
c         


        
2条回答
  •  轮回少年
    2021-01-25 19:04

    So I'm not sure the radius that you want your circle in your map, but this code will draw you a circle polygon on top of your map m:

    from mpl_toolkits.basemap import Basemap
    import matplotlib.pyplot as plt
    from matplotlib.patches import Circle
    
    m = Basemap(projection="mill", #miller est une projection connu
        llcrnrlat =0,#lower left corner latitude
        llcrnrlon =0,
        urcrnrlat =10, #upper right lat
        urcrnrlon =10,
        resolution = "l") #c croud par defaut, l low , h high , f full
    

    For the circle here, I just arbitrarily chose a radius of 1/3 the entire length of your y-axis...

    circle = Circle(xy=m(5,5),radius=(m.ymax - m.ymin) / 3, fill=False)
    plt.gca().add_patch(circle)
    
    m.drawcoastlines() #dessiner les lignes
    m.drawcountries()
    m.drawstates()
    plt.show()
    

提交回复
热议问题