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

Overlays should respect the first x/y dimensions or raise an error #1413

Open
ahuang11 opened this issue Sep 12, 2024 · 0 comments
Open

Overlays should respect the first x/y dimensions or raise an error #1413

ahuang11 opened this issue Sep 12, 2024 · 0 comments
Labels

Comments

@ahuang11
Copy link
Collaborator

ahuang11 commented Sep 12, 2024

Not sure if this is a hvplot issue or holoviews issue, and the example could probably be simplified by transposing a simple xy df

If I don't specify x, y kwargs manually, I get:

image

If I specify x,y kwargs, I get:
image

import numpy as np
import pandas as pd
import xarray as xr

import datashader as ds

from datashader.transfer_functions import shade
from datashader.transfer_functions import stack
from datashader.transfer_functions import dynspread
from datashader.transfer_functions import set_background
from datashader.colors import Elevation

import xrspatial
from xrspatial import viewshed

OBSERVER_X = -12.5
OBSERVER_Y = 10

canvas = ds.Canvas(plot_width=W, plot_height=H, x_range=(-20, 20), y_range=(-20, 20))

normal_df = pd.DataFrame(
    {"x": np.random.normal(0.5, 1, 10000000), "y": np.random.normal(0.5, 1, 10000000)}
)
normal_agg = canvas.points(normal_df, "x", "y")
normal_agg.values = normal_agg.values.astype("float64")
normal_shaded = shade(normal_agg)

observer_df = pd.DataFrame({"x": [OBSERVER_X], "y": [OBSERVER_Y]})
observer_agg = canvas.points(observer_df, "x", "y")
observer_shaded = dynspread(shade(observer_agg, cmap=["orange"]), threshold=1, max_px=4)

normal_illuminated = hillshade(normal_agg)
normal_illuminated_shaded = shade(
    normal_illuminated, cmap=["black", "white"], alpha=128, how="linear"
)

stack(normal_illuminated_shaded, observer_shaded)

# Will take some time to run...
view = viewshed(normal_agg, x=OBSERVER_X, y=OBSERVER_Y)

view_shaded = shade(view, cmap=["white", "red"], alpha=128, how="linear")

normal_illuminated.hvplot("x", "y") * view.hvplot(
    "x", "y", cmap=["yellow", "black"], alpha=0.5
) * observer_df.hvplot.points("x", "y", color="red")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant