holoviz / geoviews

Simple, concise geographical visualization in Python
http://geoviews.org
BSD 3-Clause "New" or "Revised" License
596 stars 77 forks source link

empty plot from single-panel overlaid features #355

Open Timothy-W-Hilton opened 5 years ago

Timothy-W-Hilton commented 5 years ago

Hello,

Many thanks for providing this marvelous tool!

I am trying to plot some data on a map using the QuadMesh element. I am finding that things work as I expect if I create the background of my map by using either a single feature (land, ocean, coastline, etc) or overlaid features as part of a layout with at least two items. If I try to use overlaid features in a single panel, however, I get a blank plot. Minimal example:

# In[1]:
import geoviews as gv
import geoviews.feature as gf
gv.extension('bokeh')

# create a world map using the 50m resolution dataset, and draw it.  So far so good.
# In[2]:
img1 = gf.land.options(scale='50m')
img1

# show the same map zoomed in to the San Francisco, California, USA area.  So far so good.
# In[3]:
img1.opts(xlim=(-122, -123),  ylim=(37, 38))

# show oceans, land masses, and (oceans, coastlines, land masses) overlaid.  So far so good.
# In[4]:
(gf.ocean + gf.land + gf.ocean * gf.land * gf.coastline * gf.borders)

# Now show a single panel with land and oceans overlaid.  This produces a blank plot.
# In[5]:
img2 = gf.land.options(scale='50m') * gf.ocean.options(scale='50m')
img2
poplarShift commented 5 years ago

I think it's there but you may have to zoom out (or plot actual data so the extent can be set automatically).

Timothy-W-Hilton commented 5 years ago

wow, @poplarShift, you're right. I expected it to default to the whole of Earth like it does for the three-panel plot. Also the negative in the coordinate exponents was tiny on my screen and I didn't notice them, so I thought I was looking at latitudes and longitudes up to 10^5, which made no sense. Thanks!

Timothy-W-Hilton commented 5 years ago

actually, explicitly setting the axis limits has no effect for this plot, unlike the first plot that shows a single feature.

img2 = gf.land.options(scale='50m') * gf.ocean.options(scale='50m')
img2.opts(xlim=(-122, -123),  ylim=(37, 38))
poplarShift commented 5 years ago

I think you can keep this issue open, there must be a way to make default behaviour more transparent.

IIRC every once in a while there's an issue/question popping up about setting extents of geoviews elements in various ways, not all of which seem to work seamlessly. Your case looks like https://github.com/pyviz/geoviews/issues/340. Consider opening an issue to collect all those instances.

Timothy-W-Hilton commented 5 years ago

Consider opening an issue to collect all those instances.

Done. See #357