geopandas / contextily

Context geo-tiles in Python
https://contextily.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
493 stars 81 forks source link

Force basemap to be greyscale #201

Open matthew-law opened 1 year ago

matthew-law commented 1 year ago

It would be useful to be able to turn any basemap greyscale. I've tried passing cmap = 'gray' to cx.add_basemap (which I think calls plt.imshow), but haven't been able to get anything working.

Example of the kind of case in which a greyscale option for the basemap would be handy in the interest of reducing visual clutter / foregrounding the overlying data without losing too much of the information provided by the basemap:

image
darribas commented 1 year ago

This is a good idea! I guess now you should be able to get there by manipulating the output ax object but that's suboptimal. Maybe one general way of allowing this is to let the user pass keywords for imshow in a imshow_kwds dict?

We can flesh out ideas here and, if you have bandwidth, I'd very much welcome PRs :-)

martinfleis commented 1 year ago

Two notes on this.

  1. It is often suboptimal and we should prefer using real B&W tiles than forcing grayscale on otherwise coloured image.
  2. We may not be allowed to do it for some tiles. I'd assume that their T&C will prohibit tampering with the image itself.
martinfleis commented 1 year ago

If someone wanted to do that anyway, here's a nice documentation https://scikit-image.org/docs/dev/auto_examples/color_exposure/plot_rgb_to_gray.html (but ensure that we reimplement it on top of our numpy array and do not depend on scikit-image).