pytroll / pytroll-examples

Collection of examples for pytroll satellite data processing
GNU General Public License v3.0
76 stars 34 forks source link

Feature requestion: add example of scatter plot to Cartopy Plot.ipynb #34

Open raybellwaves opened 4 years ago

raybellwaves commented 4 years ago

After some time I worked out how to create a scatter plot onto of a satpy/cartopy plot.

I know i'm not the first person who has come across this as it has been brought up before (https://pytroll.slack.com/archives/C06GJFRN0/p1588754633277200).

The cartopy plot notebook https://github.com/pytroll/pytroll-examples/blob/master/satpy/Cartopy%20Plot.ipynb could have an extra cell demonstrating the use of crs and ccrs.PlateCarree()

For example here's a cartopy plot with a scatter plot using the hurricane Florence example:

from satpy import Scene, demo
import matplotlib.pyplot as plt
import cartopy.crs as ccrs

filenames = demo.get_hurricane_florence_abi(num_frames=1)
scn = Scene(reader='abi_l1b', filenames=filenames)
scn.load(['C01'])

new_scn = scn.resample(scn['C01'].attrs['area'])
crs = new_scn['C01'].attrs['area'].to_cartopy_crs()

ax = plt.axes(projection=crs)

ax.coastlines()
ax.gridlines(draw_labels=True)
ax.set_global()

plt.imshow(new_scn['C01'], transform=crs, extent=crs.bounds, origin='upper')

ax.scatter(-65, 27, marker='o', transform=ccrs.PlateCarree(), color='red', s=50)

plt.show()

image