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

Setting extent of map to CONUS #499

Open
lluddenusgs opened this issue Jul 1, 2024 · 1 comment
Open

Setting extent of map to CONUS #499

lluddenusgs opened this issue Jul 1, 2024 · 1 comment
Labels
model_eval_viz_app Tag for efforts towards building a model viz app

Comments

@lluddenusgs
Copy link
Contributor

reference this is completing functionality initially proposed in work done on #476

@lluddenusgs lluddenusgs added the model_eval_viz_app Tag for efforts towards building a model viz app label Jul 1, 2024
@alaws-USGS alaws-USGS changed the title Set initial extent of map to CONUS Setting extent of map to CONUS Jul 5, 2024
@alaws-USGS
Copy link
Contributor

Adding thoughts and pseudo code for accomplishing this.

We want to think of the map extent as its own object. So, our initial extent is going to be the continental US (CONUS). This can be derived using:

conus_bbox = states.geometry.total_bounds

But if we want this to update based on interactions made with the widgets?

Currently, if a state(s) is/are selected with state_selector, it updates both the display_states and display_points functions (in that order), which brings the extent of the map to the selected state(s) and clips the points returned by display_points to the same extents.

The streamgage_input is what is throwing a wrench into this as it filters what is returned by display_points but does nothing to filtering in display_states. It seems like a refactor is in order to accomplish this.

  1. Rename display_map to display_basemap
def display_basemap(map: str) -> gv.WMTS:
    '''
    Display a basemap, based on the string input to select a base input to overlay beneath the state boundaries polygons object. 

    Parameters:
        map(str): A string for a base map Defaults to `map_selector.value`.

    Returns:
        gv.WMTS: A Tile source type from the GeoViews library.
    '''

    basemap = base_map_options[map]
    return basemap
  1. Write new display_map
def display_map(basemap: str, state_list: list[str], streamgauge_ids: str) -> gv.Overlay:
    """
    Docstrings
    """

    # move plot_opts dictionary to here
    plot_opts = {......}

    # create basemap
    basemap = display_basemap(basemap)
    
    # if streamguage_ids are entered, we can just return the basemap and points 
    if streamgauge_ids:
        # Use current logic from `if ids:` to create a gv.Points object

        # return (basemap * gv.Points object).opts(**plot_opts)

    # else `state_list` can be passed to `display_states`and `display_points`
    else:
        # pass `state_list` to functions and create_objects

        # return (basemap * displayed_states * displayed_points).opts(**plot_opts)

If this doesn't snap to the geometries using framewise = True in the plot_opts then set the xlim and ylim programmatically using the Geodataframe.geometry.total_bounds for whichever geometry you need the bounds from.

  1. Rewrite display_points function as only the clip is needed and none of the if/else statements.
  2. Remove all of the displayed_** variables outside the context of display_map
  3. Create displayed_map and use pn.rx to bind the three widgets to it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
model_eval_viz_app Tag for efforts towards building a model viz app
Projects
None yet
Development

No branches or pull requests

2 participants