Example in 7.6 is only correct for Plate Carree
chrrrisw opened this issue · comments
Hi,
nice work, however I believe that the KDE example in 7.6 is not quite correct, with the errors apparent if you choose any other projection than Plate Carree (x=longitude, y=latitude).
Specifically the first call to scatter:
ax.scatter(x, y, color='r', s=.5, alpha=.25)
should be something like:
ax.scatter(x, y, color='r', s=.5, alpha=.25, transform=ccrs.Geodetic())
as your source data is in lon/lat.
If you were to replace the whole cell with:
mcrs = ccrs.Mercator()
ax = plt.axes(projection=mcrs)
ax.stock_img()
ax.scatter(x, y, color='r', s=.5, alpha=.25, transform=ccrs.Geodetic())
then the data does not display correctly without the transform
argument.
In the cell with:
geo = ccrs.Geodetic()
h = geo.transform_points(crs, x, y)[:, :2].T
you are actually transforming the data from Plate Carree to Geodetic, not the other way around. This, again, is only working because x=lon, y=lat.
Hope this make sense,
Regards,
Chris.