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

Inconsistent projection behavior between Matplotlib & Bokeh Backends #1410

Open
1 task done
philipc2 opened this issue Sep 10, 2024 · 6 comments
Open
1 task done

Inconsistent projection behavior between Matplotlib & Bokeh Backends #1410

philipc2 opened this issue Sep 10, 2024 · 6 comments

Comments

@philipc2
Copy link

philipc2 commented Sep 10, 2024

ALL software version info

(this library, plus any other relevant software, e.g. bokeh, python, notebook, OS, browser, etc)

Software Version Info
abseil-cpp                20211102.0           h6b3803e_1    conda-forge
antimeridian              0.3.8              pyhd8ed1ab_0    conda-forge
anyio                     4.2.0           py311hca03da5_0  
appnope                   0.1.2           py311hca03da5_1001  
argon2-cffi               21.3.0             pyhd3eb1b0_0  
argon2-cffi-bindings      21.2.0          py311h80987f9_0  
arrow-cpp                 14.0.2               hc7aafb3_1  
asttokens                 2.0.5              pyhd3eb1b0_0  
async-lru                 2.0.4           py311hca03da5_0  
attrs                     23.1.0          py311hca03da5_0  
aws-c-auth                0.6.19               h80987f9_0  
aws-c-cal                 0.5.20               h80987f9_0  
aws-c-common              0.8.5                h80987f9_0  
aws-c-compression         0.2.16               h80987f9_0  
aws-c-event-stream        0.2.15               h313beb8_0  
aws-c-http                0.6.25               h80987f9_0  
aws-c-io                  0.13.10              h80987f9_0  
aws-c-mqtt                0.7.13               h80987f9_0  
aws-c-s3                  0.1.51               h80987f9_0  
aws-c-sdkutils            0.1.6                h80987f9_0  
aws-checksums             0.1.13               h80987f9_0  
aws-crt-cpp               0.18.16              h313beb8_0  
aws-sdk-cpp               1.10.55              h313beb8_0  
babel                     2.11.0          py311hca03da5_0  
beautifulsoup4            4.12.3          py311hca03da5_0  
blas                      2.123                  openblas    conda-forge
blas-devel                3.9.0           23_osxarm64_openblas    conda-forge
bleach                    6.1.0              pyhd8ed1ab_0    conda-forge
bokeh                     3.4.2              pyhd8ed1ab_0    conda-forge
boost-cpp                 1.78.0               hb428463_0    conda-forge
bottleneck                1.3.7           py311hb9f6ed7_0  
brotli                    1.0.9                h80987f9_8  
brotli-bin                1.0.9                h80987f9_8  
brotli-python             1.0.9           py311h313beb8_8  
bzip2                     1.0.8                h80987f9_6  
c-ares                    1.33.0               h99b78c6_0    conda-forge
ca-certificates           2024.7.2             hca03da5_0  
cartopy                   0.22.0          py311h7aedaa7_0  
certifi                   2024.7.4        py311hca03da5_0  
cffi                      1.16.0          py311h80987f9_1  
cfgv                      3.4.0                    pypi_0    pypi
cftime                    1.6.2           py311ha0d4635_0  
charset-normalizer        3.3.2              pyhd8ed1ab_0    conda-forge
click                     8.1.7           unix_pyh707e725_0    conda-forge
cloudpickle               3.0.0              pyhd8ed1ab_0    conda-forge
colorama                  0.4.6              pyhd8ed1ab_0    conda-forge
colorcet                  3.1.0              pyhd8ed1ab_0    conda-forge
comm                      0.2.1           py311hca03da5_0  
contourpy                 1.2.0           py311h48ca7d4_0  
cycler                    0.12.1             pyhd8ed1ab_0    conda-forge
cytoolz                   0.12.2          py311h80987f9_0  
dask                      2024.8.1           pyhd8ed1ab_0    conda-forge
dask-core                 2024.8.1           pyhd8ed1ab_0    conda-forge
dask-expr                 1.1.11             pyhd8ed1ab_0    conda-forge
datashader                0.16.3             pyhd8ed1ab_0    conda-forge
debugpy                   1.6.7           py311h313beb8_0  
decorator                 5.1.1              pyhd3eb1b0_0  
defusedxml                0.7.1              pyhd3eb1b0_0  
distlib                   0.3.8                    pypi_0    pypi
distributed               2024.8.1           pyhd8ed1ab_0    conda-forge
executing                 0.8.3              pyhd3eb1b0_0  
filelock                  3.15.4                   pypi_0    pypi
fonttools                 4.25.0             pyhd3eb1b0_0  
freetype                  2.10.4               h17b34a0_1    conda-forge
fsspec                    2024.6.1           pyhff2d567_0    conda-forge
geopandas-base            1.0.1              pyha770c72_0    conda-forge
geos                      3.9.1                h9f76cd9_2    conda-forge
geoviews                  1.12.0             pyhd8ed1ab_0    conda-forge
geoviews-core             1.12.0             pyha770c72_0    conda-forge
gflags                    2.2.2             hc88da5d_1004    conda-forge
glog                      0.5.0                h5c6a83d_0    conda-forge
grpc-cpp                  1.48.2               hc60591f_1  
hdf4                      4.2.13               h5e329fb_3  
hdf5                      1.12.1               h05c076b_3  
holoviews                 1.19.1             pyhd8ed1ab_0    conda-forge
hvplot                    0.10.0                   pypi_0    pypi
icu                       70.1                 h6b3803e_0    conda-forge
identify                  2.6.0                    pypi_0    pypi
idna                      3.7                pyhd8ed1ab_0    conda-forge
importlib-metadata        8.4.0              pyha770c72_0    conda-forge
importlib_metadata        8.4.0                hd8ed1ab_0    conda-forge
ipykernel                 6.28.0          py311hca03da5_0  
ipython                   8.25.0          py311hca03da5_0  
jedi                      0.19.1          py311hca03da5_0  
jinja2                    3.1.4              pyhd8ed1ab_0    conda-forge
joblib                    1.4.2              pyhd8ed1ab_0    conda-forge
jpeg                      9e                   h1a8c8d9_3    conda-forge
json5                     0.9.6              pyhd3eb1b0_0  
jsonschema                4.19.2          py311hca03da5_0  
jsonschema-specifications 2023.7.1        py311hca03da5_0  
jupyter-lsp               2.2.0           py311hca03da5_0  
jupyter_client            8.6.0           py311hca03da5_0  
jupyter_core      

Description of expected behavior and the observed behavior

I am working with data that is projected to InterruptedGoodeHomolosine projection. Using matplotlib and bokeh prouce different results. The Matplotlib one below is what I expected, with anything outside of the bounds of the projecting being clipped out. However, the bokeh one produces different results. I'm not sure if this is intended or not.

Complete, minimal, self-contained example code that reproduces the issue

import hvplot.pandas
import holoviews as hv
import cartopy.crs as ccrs

# link below is a CSV of the projecte data 
# https://drive.google.com/file/d/1xA7RbJKBV2geXe1zvwd8mRTn3f4j9i4p/view?usp=sharing
gdf = ...

# mpl
hv.extension('bokeh')
gdf.hvplot(c='bottomDepth', crs=ccrs.InterruptedGoodeHomolosine(), geo=True, projection=ccrs.InterruptedGoodeHomolosine(), rasterize=True, width=500, height=250)

# bokeh
hv.extension('matplotlib')
gdf.hvplot(c='bottomDepth', crs=ccrs.InterruptedGoodeHomolosine(), geo=True, projection=ccrs.InterruptedGoodeHomolosine(), rasterize=True, width=500, height=250)

Stack traceback and/or browser JavaScript console output

N/A

Screenshots or screencasts of the bug in action

Matplotlib

image

Bokeh

image
  • I may be interested in making a pull request to address this
@ahuang11
Copy link
Collaborator

ahuang11 commented Sep 10, 2024

Thanks for reporting. Can you share as shapefile?

import holoviews as hv
import cartopy.crs as ccrs
import xarray as xr
import hvplot


gdf = gpd.read_file("projected-data.csv")
gdf.set_geometry("geometry")

Reading CSVs with geopandas doesn't seem to work very well

Also, can you check whether removing geo=True/rasterize=True fixes it?

If so, it's a datashader issue; if not it's a geoviews issue.

@philipc2
Copy link
Author

Thanks for reporting. Can you share as shapefile?

import holoviews as hv
import cartopy.crs as ccrs
import xarray as xr
import hvplot


gdf = gpd.read_file("projected-data.csv")
gdf.set_geometry("geometry")

Reading CSVs with geopandas doesn't seem to work very well

Also, can you check whether removing geo=True/rasterize=True fixes it?

If so, it's a datashader issue; if not it's a geoviews issue.

Here's the shapefile: https://drive.google.com/file/d/1A4pecNOk0l6T40SXMi3d7Ht3ZwOQTxHQ/view?usp=sharing

@philipc2
Copy link
Author

Setting rasterize=False look correct, so it does look like a Datashader issue.

image

@ahuang11
Copy link
Collaborator

Thanks for confirming. Can you try reproducing it in geoviews without hvplot?

from holoviews.operation.datashader import rasterize

polygons = gv.Polygons(gdf)

rasterize(polygons) + polygons

@philipc2
Copy link
Author

from holoviews.operation.datashader import rasterize

polygons = gv.Polygons(gdf)

rasterize(polygons) + polygons

I posted an issue on GeoViews regarding something that may be related to this issue

holoviz/geoviews#743

The common denominator is that it only occurs with the Bokeh backend.

@ahuang11
Copy link
Collaborator

Depending on how deep you want to debug this, you can set up breakpoints and see what the call stack is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants