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

Forced interpolation="None" in plot() to avoid NaN artefacts causes large vectorized file size #641

Open
rhugonnet opened this issue Dec 12, 2024 · 2 comments · Fixed by #643
Labels
documentation Improvements or additions to documentation enhancement Feature improvement or request

Comments

@rhugonnet
Copy link
Member

rhugonnet commented Dec 12, 2024

And, as we override the default, it's not parametrizable with the rcParams of matplotlib anymore, the only way is to override everywhere with the interpolation= parameter at every call of plot(), which is unpractical.

To give an idea of the impact: Plotting a 100MB DEM with our forced interpolation="None": no matter the figsize or dpi arguments, the PDF figure file is always around 80MB.

@rhugonnet rhugonnet added documentation Improvements or additions to documentation enhancement Feature improvement or request labels Dec 12, 2024
@rhugonnet
Copy link
Member Author

rhugonnet commented Dec 12, 2024

I remember now that we forced "None" to avoid matplotlib propagating NaNs into big areas... It looks extremely bad on rasters with small NaN gaps distributed everywhere.
We could almost think about running by default our own SciPy interpolation to downsample the raster to a reasonable size for a plot (as an additional argument to plot), then set interpolation="None" via geoutils.config which can be overridden globally?
This way there would be full argument/global control for the user, and still a good default plot() that saves file to a reasonable size.

@rhugonnet rhugonnet changed the title Default interpolation="None" in plot() causes large file size during vectorized saving Forced interpolation="None" in plot() to avoid NaN artefacts causes large vectorized file size Dec 12, 2024
@rhugonnet rhugonnet reopened this Jan 29, 2025
@adehecq
Copy link
Member

adehecq commented Jan 29, 2025

I think before going down the road of downsampling on our side (which might be less transparent/understable for the users), I would first try with different interpolation schemes: https://matplotlib.org/stable/gallery/images_contours_and_fields/interpolation_methods.html
Maybe "nearest" would solve the issue of NaN propagation while reducing image size?
But it's indeed still a problem that the parameter is overwritten for the rest of the script...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement Feature improvement or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants