ResidentMario / geoplot

High-level geospatial data visualization library for Python.
https://residentmario.github.io/geoplot/index.html
MIT License
1.15k stars 95 forks source link

projection=gcrs.OSGB() sometimes creates a blank plot #248

Open data-wombat opened 3 years ago

data-wombat commented 3 years ago

Apologies if this turns out to be a cartopy issue (I'm not deeply familiar with cartopy), but after digging around, I can't find anyone else running into it.

I'm hitting two odd edge cases where setting projection=gcrs.OSGB() creates a blank plot, but AlbersEqualArea() plots fine.

  1. A GeoDataFrame read from the following (Great Britain and Northern Ireland borders), dropping Northern Ireland with .dropna([11]) plots when extent is set but not when it's omitted. AlbersEqualArea() plots fine without extent.
gplt.polyplot(
    uk_borders_partial,
    zorder=1,
    projection=gcrs.OSGB(approx=False),
    extent=uk_borders_partial.total_bounds,
    edgecolor='gray',
    figsize=(12,12)
    )
  1. Setting the previous to ax= and tacking on the following KDEPlot creates a blank plot if clip=uk_borders_partial (Northern Ireland is dropped). Using the full GeoDataFrame or any subset of the full GeoDataFrame that does not drop Northern Ireland, e.g. uk_borders_full[5:12], plots exactly as expected. The code, with Ireland dropped, also plots as expected with AlbersEqualArea(). Just not with OSGB().
gplt.kdeplot(
    lichen_2011_11,
    clip=uk_borders_partial,
    projection=gcrs.OSGB(approx=False),
    cmap='Reds',
    shade=True,
    ax=ax,
    extent=uk_borders_partial.total_bounds,
    )

Would the latter be an issue with how clip gets passed to seaborn kdeplot?

Thank you for your help, and for this beautiful library.

ResidentMario commented 3 years ago

That is some really weird behavior! gcrs.OSGB() is a thin wrapper around the cartopy OSGB projection, so I'd implicate cartopy in these problem. Thanks for bringing a repro, I'll try to fiddle with it something. Sadly I'm not a cartopy expert, and the lifetime of the geoplot library has been filled with occasional and inexplicable quirks like this one, so I don't know how helpful I can be.