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

Add option for not including country borders on maps #53

Open
nhsavage opened this issue Jan 29, 2024 · 5 comments
Open

Add option for not including country borders on maps #53

nhsavage opened this issue Jan 29, 2024 · 5 comments

Comments

@nhsavage
Copy link

nhsavage commented Jan 29, 2024

Many countries don't agree on international boundaries, and so often maps produced by RCOFs don't have any boundaries on at all. This is an important feature but at the moment, skill maps etc all use the standard Cartopy BORDERS feature. This plots the de facto boundaries as defined in Natural Earth: https://www.naturalearthdata.com/about/disputed-boundaries-policy/

To improve this, we would need to include a logical flag for "plot_borders" and pass it to all plotting routines and then instead of for example:

ax[i][j].add_feature(cartopy.feature.BORDERS)

have:

if plot_borders:
   ax[i][j].add_feature(cartopy.feature.BORDERS)

Even better would be to optionally allow the use of a specific country point of view (see natural earth boundaries above) but this would need even more development.

@nhsavage nhsavage changed the title Add option for not including country borders to maps Add option for not including country borders on maps Jan 29, 2024
@nhsavage
Copy link
Author

nhsavage commented Feb 1, 2024

a first version of this has been created at https://github.com/nhsavage/pycpt/tree/i53_country_borders

I have tested it with the seasonal notebook and all code works and if plotting functions are run with plot_borders=False no borders are shown. I need to do more testing but before I proceed further I'd welcome comments on whether this is considered a good way forward here

@aaron-kaplan
Copy link
Contributor

Your changes look reasonable.

We've also had requests for using custom borders instead of the NaturalEarth ones, so the ideal would probably be to have a configuration option that defaults to cartopy.feature.BORDERS but can be overridden with either a different value for custom borders, or None for no borders. But if you don't feel like taking it all the way, a pull request that just adds this boolean option would be welcome.

@nhsavage
Copy link
Author

nhsavage commented Feb 7, 2024

I don't have time at the moment to add all the code for custom shapefiles, and being able to turn off borders is fairly pressing for us, so I will

I can give the idea of multiple options (custom shapefile, country pov) more thought later. Ideally, users would just set this option in one place and it would be picked up by all the plotting routines, but I can't see a clean way to do that at the moment

@aaron-kaplan
Copy link
Contributor

How about this: instead of a boolean argument plot_borders, could you call it borders, and have the default value be cartopy.feature.BORDERS? Then you can set it to None if you want to turn borders off, and in the future we can add the ability to use different features without changing the API.

@nhsavage
Copy link
Author

nhsavage commented Feb 7, 2024

that seems like a simple solution - I will try and implement that. That also makes it easy to use the country pov by using e.g. cartopy.feature.NaturalEarthFeature('cultural', 'admin_0_countries_egy', '10m') for Egypt (random example) although at the moment, that has a small bug in cartopy which makes it fail on first but not following runs SciTools/cartopy#2319

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

No branches or pull requests

2 participants