geemap/geemap.py
def ts_inspector(
        self,
        left_ts,
        right_ts,
        left_names,
        right_names,
        left_vis={},
        right_vis={},
        width="130px",
        **kwargs,
    ):
        """Creates a split-panel map for inspecting timeseries images.

        Args:
            left_ts (object): An ee.ImageCollection to show on the left panel.
            right_ts (object): An ee.ImageCollection to show on the right panel.
            left_names (list): A list of names to show under the left dropdown.
            right_names (list): A list of names to show under the right dropdown.
            left_vis (dict, optional): Visualization parameters for the left layer. Defaults to {}.
            right_vis (dict, optional): Visualization parameters for the right layer. Defaults to {}.
            width (str, optional): The width of the dropdown list. Defaults to '130px'.
        """
        controls = self.controls
        layers = self.layers

        left_count = int(left_ts.size().getInfo())
        right_count = int(right_ts.size().getInfo())

        if left_count != len(left_names):
            print(
                "The number of images in left_ts must match the number of layer names in left_names."
            )
            return
        if right_count != len(right_names):
            print(
                "The number of images in right_ts must match the number of layer names in right_names."
            )
            return

        left_layer = ipyleaflet.TileLayer(
            url="https://mt1.google.com/vt/lyrs=m&x={x}&y={y}&z={z}",
            attribution="Google",
            name="Google Maps",
        )
        right_layer = ipyleaflet.TileLayer(
            url="https://mt1.google.com/vt/lyrs=m&x={x}&y={y}&z={z}",
            attribution="Google",
            name="Google Maps",
        )

        self.clear_controls()
        left_dropdown = widgets.Dropdown(options=left_names, value=None)
        right_dropdown = widgets.Dropdown(options=right_names, value=None)
        left_dropdown.layout.max_width = width
        right_dropdown.layout.max_width = width

        left_control = ipyleaflet.WidgetControl(
            widget=left_dropdown, position="topleft"
        )
        right_control = ipyleaflet.WidgetControl(
            widget=right_dropdown, position="topright"
        )

        self.add_control(control=left_control)
        self.add_control(control=right_control)

        self.add_control(ipyleaflet.ZoomControl(position="topleft"))
        self.add_control(ipyleaflet.ScaleControl(position="bottomleft"))
        self.add_control(ipyleaflet.FullScreenControl())

        def left_dropdown_change(change):
            left_dropdown_index = left_dropdown.index
            if left_dropdown_index is not None and left_dropdown_index >= 0:
                try:
                    if isinstance(left_ts, ee.ImageCollection):
                        left_image = left_ts.toList(left_ts.size()).get(
                            left_dropdown_index
                        )
                    elif isinstance(left_ts, ee.List):
                        left_image = left_ts.get(left_dropdown_index)
                    else:
                        print("The left_ts argument must be an ImageCollection.")
                        return

                    if isinstance(left_image, ee.ImageCollection):
                        left_image = ee.Image(left_image.mosaic())
                    elif isinstance(left_image, ee.Image):
                        pass
                    else:
                        left_image = ee.Image(left_image)

                    left_image = ee_tile_layer(
                        left_image, left_vis, left_names[left_dropdown_index]
                    )
                    left_layer.url = left_image.url
                except Exception as e:
                    print(e)
                    return

        left_dropdown.observe(left_dropdown_change, names="value")

        def right_dropdown_change(change):
            right_dropdown_index = right_dropdown.index
            if right_dropdown_index is not None and right_dropdown_index >= 0:
                try:
                    if isinstance(right_ts, ee.ImageCollection):
                        right_image = right_ts.toList(left_ts.size()).get(
                            right_dropdown_index
                        )
                    elif isinstance(right_ts, ee.List):
                        right_image = right_ts.get(right_dropdown_index)
                    else:
                        print("The left_ts argument must be an ImageCollection.")
                        return

                    if isinstance(right_image, ee.ImageCollection):
                        right_image = ee.Image(right_image.mosaic())
                    elif isinstance(right_image, ee.Image):
                        pass
                    else:
                        right_image = ee.Image(right_image)

                    right_image = ee_tile_layer(
                        right_image,
                        right_vis,
                        right_names[right_dropdown_index],
                    )
                    right_layer.url = right_image.url
                except Exception as e:
                    print(e)
                    return

        right_dropdown.observe(right_dropdown_change, names="value")

        close_button = widgets.ToggleButton(
            value=False,
            tooltip="Close the tool",
            icon="times",
            # button_style="primary",
            layout=widgets.Layout(
                height="28px", width="28px", padding="0px 0px 0px 4px"
            ),
        )

        def close_btn_click(change):
            if change["new"]:
                self.controls = controls
                self.clear_layers()
                self.layers = layers

        close_button.observe(close_btn_click, "value")
        close_control = ipyleaflet.WidgetControl(
            widget=close_button, position="bottomright"
        )

        try:

            split_control = ipyleaflet.SplitMapControl(
                left_layer=left_layer, right_layer=right_layer
            )
            self.add_control(split_control)

            self.add_control(close_control)

        except Exception as e:
            raise Exception(e)
Creates a split-panel map for inspecting timeseries images.

        Args:
            left_ts (object): An ee.ImageCollection to show on the left panel.
            right_ts (object): An ee.ImageCollection to show on the right panel.
            left_names (list): A list of names to show under the left dropdown.
            right_names (list): A list of names to show under the right dropdown.
            left_vis (dict, optional): Visualization parameters for the left layer. Defaults to {}.
            right_vis (dict, optional): Visualization parameters for the right layer. Defaults to {}.
            width (str, optional): The width of the dropdown list. Defaults to '130px'.
        
Creates a split-panel map for inspecting timeseries images.
Creates a split - panel map for inspecting timeseries images .
def ts_inspector(
        self,
        left_ts,
        right_ts,
        left_names,
        right_names,
        left_vis={},
        right_vis={},
        width="130px",
        **kwargs,
    ):
        controls = self.controls
        layers = self.layers
        left_count = int(left_ts.size().getInfo())
        right_count = int(right_ts.size().getInfo())
        if left_count != len(left_names):
            print(
                "The number of images in left_ts must match the number of layer names in left_names."
            )
            return
        if right_count != len(right_names):
            print(
                "The number of images in right_ts must match the number of layer names in right_names."
            )
            return
        left_layer = ipyleaflet.TileLayer(
            url="https://mt1.google.com/vt/lyrs=m&x={x}&y={y}&z={z}",
            attribution="Google",
            name="Google Maps",
        )
        right_layer = ipyleaflet.TileLayer(
            url="https://mt1.google.com/vt/lyrs=m&x={x}&y={y}&z={z}",
            attribution="Google",
            name="Google Maps",
        )
        self.clear_controls()
        left_dropdown = widgets.Dropdown(options=left_names, value=None)
        right_dropdown = widgets.Dropdown(options=right_names, value=None)
        left_dropdown.layout.max_width = width
        right_dropdown.layout.max_width = width
        left_control = ipyleaflet.WidgetControl(
            widget=left_dropdown, position="topleft"
        )
        right_control = ipyleaflet.WidgetControl(
            widget=right_dropdown, position="topright"
        )
        self.add_control(control=left_control)
        self.add_control(control=right_control)
        self.add_control(ipyleaflet.ZoomControl(position="topleft"))
        self.add_control(ipyleaflet.ScaleControl(position="bottomleft"))
        self.add_control(ipyleaflet.FullScreenControl())
        def left_dropdown_change(change):
            left_dropdown_index = left_dropdown.index
            if left_dropdown_index is not None and left_dropdown_index >= 0:
                try:
                    if isinstance(left_ts, ee.ImageCollection):
                        left_image = left_ts.toList(left_ts.size()).get(
                            left_dropdown_index
                        )
                    elif isinstance(left_ts, ee.List):
                        left_image = left_ts.get(left_dropdown_index)
                    else:
                        print("The left_ts argument must be an ImageCollection.")
                        return
                    if isinstance(left_image, ee.ImageCollection):
                        left_image = ee.Image(left_image.mosaic())
                    elif isinstance(left_image, ee.Image):
                        pass
                    else:
                        left_image = ee.Image(left_image)
                    left_image = ee_tile_layer(
                        left_image, left_vis, left_names[left_dropdown_index]
                    )
                    left_layer.url = left_image.url
                except Exception as e:
                    print(e)
                    return
        left_dropdown.observe(left_dropdown_change, names="value")
        def right_dropdown_change(change):
            right_dropdown_index = right_dropdown.index
            if right_dropdown_index is not None and right_dropdown_index >= 0:
                try:
                    if isinstance(right_ts, ee.ImageCollection):
                        right_image = right_ts.toList(left_ts.size()).get(
                            right_dropdown_index
                        )
                    elif isinstance(right_ts, ee.List):
                        right_image = right_ts.get(right_dropdown_index)
                    else:
                        print("The left_ts argument must be an ImageCollection.")
                        return
                    if isinstance(right_image, ee.ImageCollection):
                        right_image = ee.Image(right_image.mosaic())
                    elif isinstance(right_image, ee.Image):
                        pass
                    else:
                        right_image = ee.Image(right_image)
                    right_image = ee_tile_layer(
                        right_image,
                        right_vis,
                        right_names[right_dropdown_index],
                    )
                    right_layer.url = right_image.url
                except Exception as e:
                    print(e)
                    return
        right_dropdown.observe(right_dropdown_change, names="value")
        close_button = widgets.ToggleButton(
            value=False,
            tooltip="Close the tool",
            icon="times",
            layout=widgets.Layout(
                height="28px", width="28px", padding="0px 0px 0px 4px"
            ),
        )
        def close_btn_click(change):
            if change["new"]:
                self.controls = controls
                self.clear_layers()
                self.layers = layers
        close_button.observe(close_btn_click, "value")
        close_control = ipyleaflet.WidgetControl(
            widget=close_button, position="bottomright"
        )
        try:
            split_control = ipyleaflet.SplitMapControl(
                left_layer=left_layer, right_layer=right_layer
            )
            self.add_control(split_control)
            self.add_control(close_control)
        except Exception as e:
            raise Exception(e)
def ts_inspector ( self , left_ts , right_ts , left_names , right_names , left_vis = { } , right_vis = { } , width = "130px" , ** kwargs , ) : controls = self . controls layers = self . layers left_count = int ( left_ts . size ( ) . getInfo ( ) ) right_count = int ( right_ts . size ( ) . getInfo ( ) ) if left_count != len ( left_names ) : print ( "The number of images in left_ts must match the number of layer names in left_names." ) return if right_count != len ( right_names ) : print ( "The number of images in right_ts must match the number of layer names in right_names." ) return left_layer = ipyleaflet . TileLayer ( url = "https://mt1.google.com/vt/lyrs=m&x={x}&y={y}&z={z}" , attribution = "Google" , name = "Google Maps" , ) right_layer = ipyleaflet . TileLayer ( url = "https://mt1.google.com/vt/lyrs=m&x={x}&y={y}&z={z}" , attribution = "Google" , name = "Google Maps" , ) self . clear_controls ( ) left_dropdown = widgets . Dropdown ( options = left_names , value = None ) right_dropdown = widgets . Dropdown ( options = right_names , value = None ) left_dropdown . layout . max_width = width right_dropdown . layout . max_width = width left_control = ipyleaflet . WidgetControl ( widget = left_dropdown , position = "topleft" ) right_control = ipyleaflet . WidgetControl ( widget = right_dropdown , position = "topright" ) self . add_control ( control = left_control ) self . add_control ( control = right_control ) self . add_control ( ipyleaflet . ZoomControl ( position = "topleft" ) ) self . add_control ( ipyleaflet . ScaleControl ( position = "bottomleft" ) ) self . add_control ( ipyleaflet . FullScreenControl ( ) ) def left_dropdown_change ( change ) : left_dropdown_index = left_dropdown . index if left_dropdown_index is not None and left_dropdown_index >= 0 : try : if isinstance ( left_ts , ee . ImageCollection ) : left_image = left_ts . toList ( left_ts . size ( ) ) . get ( left_dropdown_index ) elif isinstance ( left_ts , ee . List ) : left_image = left_ts . get ( left_dropdown_index ) else : print ( "The left_ts argument must be an ImageCollection." ) return if isinstance ( left_image , ee . ImageCollection ) : left_image = ee . Image ( left_image . mosaic ( ) ) elif isinstance ( left_image , ee . Image ) : pass else : left_image = ee . Image ( left_image ) left_image = ee_tile_layer ( left_image , left_vis , left_names [ left_dropdown_index ] ) left_layer . url = left_image . url except Exception as e : print ( e ) return left_dropdown . observe ( left_dropdown_change , names = "value" ) def right_dropdown_change ( change ) : right_dropdown_index = right_dropdown . index if right_dropdown_index is not None and right_dropdown_index >= 0 : try : if isinstance ( right_ts , ee . ImageCollection ) : right_image = right_ts . toList ( left_ts . size ( ) ) . get ( right_dropdown_index ) elif isinstance ( right_ts , ee . List ) : right_image = right_ts . get ( right_dropdown_index ) else : print ( "The left_ts argument must be an ImageCollection." ) return if isinstance ( right_image , ee . ImageCollection ) : right_image = ee . Image ( right_image . mosaic ( ) ) elif isinstance ( right_image , ee . Image ) : pass else : right_image = ee . Image ( right_image ) right_image = ee_tile_layer ( right_image , right_vis , right_names [ right_dropdown_index ] , ) right_layer . url = right_image . url except Exception as e : print ( e ) return right_dropdown . observe ( right_dropdown_change , names = "value" ) close_button = widgets . ToggleButton ( value = False , tooltip = "Close the tool" , icon = "times" , layout = widgets . Layout ( height = "28px" , width = "28px" , padding = "0px 0px 0px 4px" ) , ) def close_btn_click ( change ) : if change [ "new" ] : self . controls = controls self . clear_layers ( ) self . layers = layers close_button . observe ( close_btn_click , "value" ) close_control = ipyleaflet . WidgetControl ( widget = close_button , position = "bottomright" ) try : split_control = ipyleaflet . SplitMapControl ( left_layer = left_layer , right_layer = right_layer ) self . add_control ( split_control ) self . add_control ( close_control ) except Exception as e : raise Exception ( e )
Creates a split-panel map for inspecting timeseries images.
Creates a split - panel map for inspecting timeseries images .
"""Creates a split-panel map for inspecting timeseries images.

        Args:
            left_ts (object): An ee.ImageCollection to show on the left panel.
            right_ts (object): An ee.ImageCollection to show on the right panel.
            left_names (list): A list of names to show under the left dropdown.
            right_names (list): A list of names to show under the right dropdown.
            left_vis (dict, optional): Visualization parameters for the left layer. Defaults to {}.
            right_vis (dict, optional): Visualization parameters for the right layer. Defaults to {}.
            width (str, optional): The width of the dropdown list. Defaults to '130px'.
        """ # button_style="primary",

self
left_ts
An ee.ImageCollection to show on the left panel.
An ee . ImageCollection to show on the left panel .
right_ts
An ee.ImageCollection to show on the right panel.
An ee . ImageCollection to show on the right panel .
left_names
A list of names to show under the left dropdown.
A list of names to show under the left dropdown .
right_names
A list of names to show under the right dropdown.
A list of names to show under the right dropdown .
left_vis
Visualization parameters for the left layer. Defaults to {}.
Visualization parameters for the left layer . Defaults to {} .
{}
right_vis
Visualization parameters for the right layer. Defaults to {}.
Visualization parameters for the right layer . Defaults to {} .
{}
width
The width of the dropdown list. Defaults to '130px'.
The width of the dropdown list . Defaults to ' 130px ' .
'130px'