-
-
Notifications
You must be signed in to change notification settings - Fork 108
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
IndexError when using geographic data #738
Comments
Yes it would be nice if you could share this NetCDF file (EPSG 2154, thanks for the memory 🇫🇷). |
Thanks for your answer ! |
I am getting the same error. Using an xarray DataArray in CRS 'epsg:3857'. Works fine with rasterize=True and Project=False. Fails with Project=True. |
@hxawax I can get your plot working by declaring explicitly import xarray as xr
import hvplot.xarray
ds = xr.open_dataset('bug.nc')
ds.band_data.hvplot(x='x', y='y', crs=cartopy.crs.epsg(2154)) (I think what happens when you don't declare them explicitly is that hvPlot assumes you want to plot (y, x) since this is the convention for arrays. The axes being now messed up their extents is also messed up which lead to the error message) |
@kearney-sp did you experience exactly the same issue due to not declaring explicitly |
@maximlt I was declaring x and y explicitly when I got the error. I will see if I can create a reproducible example, or at least just paste the code snippet (it's part of a much larger app). Thanks. |
Thanks, that'd be much appreciated @kearney-sp ! |
I sometimes have the same error, below you can find a MRE, and these are the package versions I am using (please let me know if some relevant ones are missing). I believe I only get this error with some CRSs but not with all of them.
import numpy as np
import xarray as xr
import rioxarray as rxr
import cartopy.crs as ccrs
import geoviews as gv
import holoviews as hv
import hvplot.xarray
da = xr.DataArray(np.arange(1_000_000).reshape(1000,1000),
coords=dict(x=np.linspace(577200, 867600, 1000),
y=np.linspace(-1802100, -2036700, 1000))
)
da = da.rio.write_crs(32635)
crs = ccrs.epsg(32635)
da.hvplot(x="x", y="y", crs=crs, rasterize=True) |
@gcaria, I'm in no way an expert in maps, but could the reason you are seeing the Because if I change the import numpy as np
import xarray as xr
import rioxarray as rxr
import cartopy.crs as ccrs
import geoviews as gv
import holoviews as hv
import hvplot.xarray
da = xr.DataArray(np.arange(1_000_000).reshape(1000,1000),
coords=dict(x=np.linspace(166021, 534994, 1000),
y=np.linspace(0.00, 9329005, 1000))
)
crs = ccrs.epsg(32635)
da = da.rio.write_crs(crs)
da.hvplot(x="y", y="x", crs=crs, rasterize=True) (Note there is a weird artifact when you move around, this will be fixed with holoviz/holoviews#5351) @hxawax, this could also be the reason why you see the I think a more descriptive error message is needed when exceeding the bounds and getting an |
Good catch @hoxbro ! There's a very good chance that's what's going on. I agree with you that a better error message would be very helpful. |
This looks like the same error that is showing up in #951 (leading me to believe even more firmly that that issue has to do with bad hvplot misunderstanding the crs of the bounds). |
Having finally circled back to this, I think that in order to raise a more informative error there would need to be a change on the holoviews side. |
Are you sure the change is needed in Holoviews? Because I did some initial work to give a more informative error message in holoviz/geoviews#581 but never finished it. |
Oh sorry I mean "not on hvplot" yeah it's more likely that it would happen on geoviews. |
You are more than welcome to continue the work on the PR or rewrite it if that is easier 😅 |
Hey,
I'm reporting a bug occurring when using hvplot with
geo=True
option orcrs=
optionALL software version info
hvplot version : 0.7.3
xarray version 2022.3.0
geoviews version 1.9.5
Description of expected behavior and the observed behavior
without option the dataset is showing fine
xr.open_dataset('bug.nc').band_data.hvplot(x='x',y='y')
Complete, minimal, self-contained example code that reproduces the issue
If I add the
geo=True
option orcrs=
option or both the following error occurxr.open_dataset('bug.nc').band_data.hvplot(crs=cartopy.crs.epsg(2154))
the same error is happening with
xr.open_dataset('bug.nc').band_data.hvplot(geo=True)
I can give you the bug.nc netcdf file if you wish.
The text was updated successfully, but these errors were encountered: