Plotting Points and Shapes over RadarMapDisplayCartopy Object

237 views
Skip to first unread message

Abby Hutson (Kenyon)

unread,
Jul 9, 2018, 12:21:45 PM7/9/18
to Py-ART Users
Hello All, 

This may sound like a trivial problem, but I am having some issues attempting to plot a circle over a subplot on which I display NEXRAD reflectivities over a cartopy map. Currently, I am creating two subplots, one displaying reflectivity, the other displaying velocity. Below, I set up my PyART display object:

fig = plt.figure(figsize = [20,8])
display = pyart.graph.RadarMapDisplayCartopy(radar)
proj = display.grid_projection

Then I set up my reflectivity subplot on which I plot the location of our mobile radar used in the field (Ka-1) using display.plot_point

# Plot reflectivity on the left
ax1 = fig.add_subplot(1,2,1,projection=proj)
plt.tight_layout()
field='reflectivity'
title = field+' \n'+fancy_date_string+' ('+fancy_date_string_utc+') '
offset = 0.75
ax1.plot(klon1,klat1,color='r',markersize=200,transform=proj)
display.plot_ppi_map(
        field, 0, colorbar_flag=True,
        title=title, ax=ax1,
        vmin=-10, vmax=75,
        min_lon=klon1-offset,max_lon=klon1+offset,
        min_lat=klat1-offset,max_lat=klat1+offset)
#     Mark the location of Ka-1
    display.plot_point(klon1,klat1,marker='+',color='k',
                       label_text='Ka1',label_offset=(0.01,0.02),
                       markersize=8,markeredgewidth=2)

The display.plot_point works great. Next, I would like to plot a circle centered on my Ka-1 point with a radius of 15km (to display the range captured by our mobile radar). I have attempted using many matplotlib/cartopy plotting techniques such as plt.Circle and pyart.graph.common.plt.Circle (always including the transform=proj keyword argument), and while I don't receive an error, I also don't see any circle plotted on the map. 

Does anyone have a successful way to plot a circle (NOT centered on the NEXRAD radar) over the part.graph.RadarMapDisplayCartopy object? I appreciate any help or suggestions! Thank you!

Abby Hutson

Scott Collis

unread,
Jul 10, 2018, 1:15:58 PM7/10/18
to Abby Hutson (Kenyon), Py-ART Users
Hey Abby!
(Come one community! You can answer these too!)

Perhaps you can use an example I put together that had nothing to do with radar data:

The key cell is 183

def circle(geod, lon, lat, radius, n_samples=360):
    """
    Return the coordinates of a geodetic circle of a given
    radius about a lon/lat point.

    Radius is in meters in the geodetic's coordinate system.

    """
    lons, lats, back_azim = geod.fwd(np.repeat(lon, n_samples),
                                     np.repeat(lat, n_samples),
                                     np.linspace(360, 0, n_samples),
                                     np.repeat(radius, n_samples),
                                     radians=False,
                                     )
    return lons, lats

def rring(radius_km):
    geod = Geod(ellps='WGS84')
    n_samples = 80
    geoms = []
    lons, lats = circle(geod, arm_sites['Longitude'][1], arm_sites['Latitude'][1], radius_km * 1e3, n_samples)
    geoms.append(sgeom.Polygon(zip(lons, lats)))

    plt.gca().add_geometries(geoms, ccrs.PlateCarree(), facecolor='none',
                             edgecolor='k', alpha=1, linewidth=2)
In [184]:

Scott Collis


--
You received this message because you are subscribed to the Google Groups "Py-ART Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyart-users...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Abby Hutson (Kenyon)

unread,
Jul 10, 2018, 4:52:43 PM7/10/18
to Py-ART Users
Thank you, Scott!

This worked great. I will probably be digging into it a little more to plot additional shapes/lines over top of the image, so I really appreciate it. I hope SciPy is going well!

Abby Hutson
Reply all
Reply to author
Forward
0 new messages