Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instantiating from class cartopy.mpl.geoaxes.GeoAxes(*args, **kwargs)[source] #1979

Closed
hklaufus opened this issue Jan 3, 2022 · 2 comments · Fixed by #1980
Closed

Instantiating from class cartopy.mpl.geoaxes.GeoAxes(*args, **kwargs)[source] #1979

hklaufus opened this issue Jan 3, 2022 · 2 comments · Fixed by #1980
Milestone

Comments

@hklaufus
Copy link

hklaufus commented Jan 3, 2022

Description

Using
vAxes = cartopy.mpl.geoaxes.GeoAxes(projection=ccrs.Mercator())

throws KeyError:

File "/usr/lib64/python3.10/site-packages/cartopy/mpl/geoaxes.py", line 410, in __init__
self.projection = kwargs.pop('map_projection')
KeyError: 'map_projection'

Note that the following does work:

vAxes = matplotlib.pyplot.axes(projection=ccrs.Mercator())

Although this throws a warning QSocketNotifier: Can only be used with threads started with QThread - which is a different issue?

Code to reproduce

import cartopy.crs as ccrs
import cartopy.mpl.geoaxes as cga
import cartopy.feature as cfeature

vAxes = cga.GeoAxes(projection=ccrs.Mercator())

Traceback

File "/usr/lib64/python3.10/site-packages/cartopy/mpl/geoaxes.py", line 410, in __init__
self.projection = kwargs.pop('map_projection')
KeyError: 'map_projection'
Full environment definition

Operating system

Fedora 35

Cartopy version

0.20.1

@greglucas
Copy link
Contributor

I have run into the same issue before and I wonder if there is a good reason why there is a "map_projection" keyword here rather than just using "projection" and validating that it is a valid instance of Projection or something similar.

It also lists this as an "optional" keyword, but as this error shows, it isn't so optional ;)

Parameters
----------
map_projection: optional
The target :class:`~cartopy.crs.Projection` of this Axes object.

@hklaufus
Copy link
Author

hklaufus commented Jan 9, 2022

Thanks for your support, @greglucas .

@QuLogic QuLogic added this to the 0.21 milestone Aug 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants