Skip to content

Add option in raster plot to crop around centroids #1047

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

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

ValentinGebhart
Copy link
Collaborator

@ValentinGebhart ValentinGebhart commented Apr 15, 2025

Changes proposed in this PR:

  • Add an optional parameter to geo_im_from_array such that the user can input a (relative) distance above which plot locations that are further away than this distance from any centroids are masked (ie, no values plotted). This option is then available in all function that call geo_im_from_array, i.e., _event_plot, hazard.plot_intensity, hazard.plot_fraction, plot_from_gdf, hazard.plot_rp_intensity, impact.plot_rp_imp
  • removed bug about the NaN legend in geo_im_from_array

PR Author Checklist

PR Reviewer Checklist

@ValentinGebhart
Copy link
Collaborator Author

Example 1: plot_intensity with floods in France

from climada.util.api_client import Client
client = Client()
properties = {"country_iso3alpha": "FRA", "climate_scenario": "historical"}
hazard = client.get_hazard(hazard_type="river_flood", properties=properties)

Results:

hazard.plot_intensity(event=0)

original_fra

hazard.plot_intensity(event=0, mask_rel_distance=0.01)

crop_01fra

hazard.plot_intensity(event=0, mask_rel_distance=0.001)

crop_001fra

Example 2: some return period maps with few centroids

plot_from_gdf(ex_impact_with_zeros, colorbar_name=label, title_subplots=col_label)

orignial_imp

plot_from_gdf(ex_impact_with_zeros, colorbar_name=label, title_subplots=col_label, mask_rel_distance=0.1)

crop_01_imp

plot_from_gdf(ex_impact_with_zeros, colorbar_name=label, title_subplots=col_label, mask_rel_distance=0.01)

crop_001_imp

@ValentinGebhart
Copy link
Collaborator Author

Default is now not to mask anything, so plots will look as before if user does not specify differently. Up for discussion :) @chahank @spjuhel

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.

1 participant