Skip to content

Add several map projection options#898

Merged
fneum merged 2 commits intoPyPSA:masterfrom
koen-vg:custom-projection
Jan 25, 2024
Merged

Add several map projection options#898
fneum merged 2 commits intoPyPSA:masterfrom
koen-vg:custom-projection

Conversation

@koen-vg
Copy link
Copy Markdown
Contributor

@koen-vg koen-vg commented Jan 25, 2024

It's quite petty but being based in the north of Norway I can't really deal with the default EqualEarth projections and its wild distortions. I say give the user some (limited) choice in projection without them having to do surgery on the plot_network.py script. Do feel free to discard (I will just keep it for personal use) if this kind of "feature creep" isn't really desired.

Changes proposed in this Pull Request

Added a config["plotting"]["projection"] option with a few different preset choices. Falls back to the old default of EqualEarth if not specified.

Checklist

  • I tested my contribution locally and it seems to work fine.
  • Code and workflow changes are sufficiently documented.
  • Changed dependencies are added to envs/environment.yaml.
  • Changes in configuration options are added in all of config.default.yaml.
  • Changes in configuration options are also documented in doc/configtables/*.csv.
  • A release note doc/release_notes.rst is added.

@fneum
Copy link
Copy Markdown
Member

fneum commented Jan 25, 2024

I like it!

I was thinking whether one could give even more flexibility to the user rather than just 4 options:

plotting:
  projection:
    name: Orthographic
    # kwargs
    central_longitude: 10.
    central_latitude: 50.
proj_kwargs = snakemake.params.plotting.get("projection", dict(name="EqualEarth"))
proj_func = getattr(ccrs, proj_kwargs.pop("name"))
proj = proj_func(**proj_kwargs)

The config.yaml would default to:

plotting:
  projection:
    name: EqualEarth

This would unlock in principle all cartopy projections.

Then, one could just document a few recommended options that are currently explicit in the code.

@koen-vg
Copy link
Copy Markdown
Contributor Author

koen-vg commented Jan 25, 2024

Sure, sounds good! I just haven't really gotten comfortable with the whole getattr thing yet, so I didn't really consider this :)

For now I've given one reasonable alternative example (commented) in config.default.yaml, along with a link to the complete list of projections. I feel like this should provide a useful starting point for the user, but feel free to move things or let me know if you'd for instance rather document alternatives in configtables/plotting.csv or so instead.

Copy link
Copy Markdown
Member

@fneum fneum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

@fneum fneum merged commit 2db564e into PyPSA:master Jan 25, 2024
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 this pull request may close these issues.

2 participants