Projections not working??

409 views
Skip to first unread message

Nick Dunstone

unread,
Jul 18, 2014, 6:10:03 AM7/18/14
to scitoo...@googlegroups.com
Hi,

I'm trying to make my first ever IRIS polar projection plot, but I can't seem to get it to work. I then found this example for projections

---------
import
iris import iris.plot as iplt import cartopy.crs as ccrs import matplotlib.pyplot as plt fname = iris.sample_data_path('air_temp.pp') air_temp = iris.load_cube(fname) ax = plt.axes(projection=ccrs.Robinson(central_longitude=180)) iplt.contourf(air_temp) ax.coastlines() plt.show()
-----
and I get an error:
RuntimeError: Unidentified problem with geometry, linestring being re-added



I've then tried to modify this to polar projection, which is what I really want:
-----
import iris import iris.plot as iplt import cartopy.crs as ccrs import matplotlib.pyplot as plt fname = iris.sample_data_path('air_temp.pp') air_temp = iris.load_cube(fname) ax = plt.axes(projection=ccrs.NorthPolarStereo(central_longitude=0.0))
iplt.contourf(air_temp) ax.coastlines() plt.show()
-----

and then I don't get an error, but all I get is a completely blank image window - no map!

Clearly I'm doing something stupid - any hints?

Thanks,
Nick

(from: http://stackoverflow.com/questions/13766275/can-you-change-iris-cube-projections-in-cartopy)

Andrew Dawson

unread,
Jul 18, 2014, 9:47:51 AM7/18/14
to scitoo...@googlegroups.com
You are stumbling into a know bug with the polar stereographic projection I think. All you need to do is set the extent of the plot. The plot is actually being drawn but so small you can't see it, which is obviously no good!

To set a global extent just add:

ax.set_global()

It is more likely you'll want to use a custom latitudinal extent, in which case you can do something like this:

# Northern Hemisphere from 23 degrees north:
ax
.set_extent([-180, 180, 23, 90], crs=ccrs.PlateCarree())

Hope that helps.

Nick Dunstone

unread,
Jul 21, 2014, 8:57:51 AM7/21/14
to scitoo...@googlegroups.com
That's great, many thanks Andrew!

Daniel Watkins

unread,
Apr 19, 2017, 2:56:37 PM4/19/17
to Iris

Hi Andrew,

Could you explain why ax.set_extent needs crs=ccrs.PlateCarree() instead of crs=ccrs.NorthPolarStereo() for a plot that uses the north polar stereographic projection?

Andrew Dawson

unread,
Apr 19, 2017, 2:58:43 PM4/19/17
to Iris
You use the crs that you want to specify the extents in, so in this case I wanted geographic coordinates (lat/lon) which corresponds to PlateCarree(). If I used crs=NorthPolarStereo() I'd need to provide the extents in the native coordinates of this projection.

Daniel Watkins

unread,
Apr 19, 2017, 3:19:53 PM4/19/17
to Iris
Oh okay, that makes sense. Thanks!
Reply all
Reply to author
Forward
0 new messages