holoviz / geoviews

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

Geometry path issues in geostationary projection with geometry.geoms #724

Open TheoMathurin opened 2 months ago

TheoMathurin commented 2 months ago

geoviews 1.12.0 holoviews 1.18.3 bokeh 3.4.1 cartopy 0.23.0 geos 3.12.1 shapely 2.0.4

With coastline.geoms objects in geostationary projection, paths display weird segments extending apparently infinitely towards the top-left corner.

Not sure this is due to geoviews per se though. I've tried various environments including with older versions of all these libraries and they now all seem to exhibit this behaviour while it used to be fine. I've made sure to delete local natural earth geometries cached by cartopy to fetch the latest (could it come from there?)

Note that it does not happen with a bare gv.feature.coastline, but only with its .geoms (which I use with resample_geometry).

import panel as pn
import geoviews as gv
import cartopy.crs as ccrs

gv.extension('bokeh')

plots = [gv.feature.coastline.geoms(res).options(projection=ccrs.Geostationary()) for res in ['110m', '50m', '10m']]

pn.Row(*plots)

Capture d’écran du 2024-04-18 10-08-41

No error is thrown in python or javascript.

ahuang11 commented 2 months ago

Potential workaround:

import panel as pn
import geoviews as gv
import cartopy.crs as ccrs

gv.extension("bokeh")

plots = [
    gv.Points((0, 0), crs=ccrs.Geostationary()).opts(projection=ccrs.Geostationary())
    * gv.project(gv.feature.coastline().geoms(res), projection=ccrs.Geostationary())
    for res in ["110m", "50m", "10m"]
]

pn.Row(*plots)
image
TheoMathurin commented 2 months ago

Many thanks @ahuang11 for the idea.

In my admittedly complex use case wrapping geoms into gv.project somehow results in the geometry not showing. Can't really pinpoint a cause right now though.