geemap/geemap.py
def add_xy_data(
        self,
        in_csv,
        x="longitude",
        y="latitude",
        label=None,
        layer_name="Marker cluster",
        to_ee=False,
    ):
        """Adds points from a CSV file containing lat/lon information and display data on the map.

        Args:
            in_csv (str): The file path to the input CSV file.
            x (str, optional): The name of the column containing longitude coordinates. Defaults to "longitude".
            y (str, optional): The name of the column containing latitude coordinates. Defaults to "latitude".
            label (str, optional): The name of the column containing label information to used for marker popup. Defaults to None.
            layer_name (str, optional): The layer name to use. Defaults to "Marker cluster".
            to_ee (bool, optional): Whether to convert the csv to an ee.FeatureCollection.

        Raises:
            FileNotFoundError: The specified input csv does not exist.
            ValueError: The specified x column does not exist.
            ValueError: The specified y column does not exist.
            ValueError: The specified label column does not exist.
        """
        import pandas as pd

        if not in_csv.startswith("http") and (not os.path.exists(in_csv)):
            raise FileNotFoundError("The specified input csv does not exist.")

        df = pd.read_csv(in_csv)
        col_names = df.columns.values.tolist()

        if x not in col_names:
            raise ValueError(f"x must be one of the following: {', '.join(col_names)}")

        if y not in col_names:
            raise ValueError(f"y must be one of the following: {', '.join(col_names)}")

        if label is not None and (label not in col_names):
            raise ValueError(
                f"label must be one of the following: {', '.join(col_names)}"
            )

        self.default_style = {"cursor": "wait"}

        if to_ee:
            fc = csv_to_ee(in_csv, latitude=y, longitude=x)
            self.addLayer(fc, {}, layer_name)

        else:
            points = list(zip(df[y], df[x]))

            if label is not None:
                labels = df[label]
                markers = [
                    ipyleaflet.Marker(
                        location=point,
                        draggable=False,
                        popup=widgets.HTML(str(labels[index])),
                    )
                    for index, point in enumerate(points)
                ]
            else:
                markers = [
                    ipyleaflet.Marker(location=point, draggable=False)
                    for point in points
                ]

            marker_cluster = ipyleaflet.MarkerCluster(markers=markers, name=layer_name)
            self.add_layer(marker_cluster)

        self.default_style = {"cursor": "default"}
Adds points from a CSV file containing lat/lon information and display data on the map.

        Args:
            in_csv (str): The file path to the input CSV file.
            x (str, optional): The name of the column containing longitude coordinates. Defaults to "longitude".
            y (str, optional): The name of the column containing latitude coordinates. Defaults to "latitude".
            label (str, optional): The name of the column containing label information to used for marker popup. Defaults to None.
            layer_name (str, optional): The layer name to use. Defaults to "Marker cluster".
            to_ee (bool, optional): Whether to convert the csv to an ee.FeatureCollection.

        Raises:
            FileNotFoundError: The specified input csv does not exist.
            ValueError: The specified x column does not exist.
            ValueError: The specified y column does not exist.
            ValueError: The specified label column does not exist.
        
Adds points from a CSV file containing lat/lon information and display data on the map.
Adds points from a CSV file containing lat / lon information and display data on the map .
def add_xy_data(
        self,
        in_csv,
        x="longitude",
        y="latitude",
        label=None,
        layer_name="Marker cluster",
        to_ee=False,
    ):
        import pandas as pd
        if not in_csv.startswith("http") and (not os.path.exists(in_csv)):
            raise FileNotFoundError("The specified input csv does not exist.")
        df = pd.read_csv(in_csv)
        col_names = df.columns.values.tolist()
        if x not in col_names:
            raise ValueError(f"x must be one of the following: {', '.join(col_names)}")
        if y not in col_names:
            raise ValueError(f"y must be one of the following: {', '.join(col_names)}")
        if label is not None and (label not in col_names):
            raise ValueError(
                f"label must be one of the following: {', '.join(col_names)}"
            )
        self.default_style = {"cursor": "wait"}
        if to_ee:
            fc = csv_to_ee(in_csv, latitude=y, longitude=x)
            self.addLayer(fc, {}, layer_name)
        else:
            points = list(zip(df[y], df[x]))
            if label is not None:
                labels = df[label]
                markers = [
                    ipyleaflet.Marker(
                        location=point,
                        draggable=False,
                        popup=widgets.HTML(str(labels[index])),
                    )
                    for index, point in enumerate(points)
                ]
            else:
                markers = [
                    ipyleaflet.Marker(location=point, draggable=False)
                    for point in points
                ]
            marker_cluster = ipyleaflet.MarkerCluster(markers=markers, name=layer_name)
            self.add_layer(marker_cluster)
        self.default_style = {"cursor": "default"}
def add_xy_data ( self , in_csv , x = "longitude" , y = "latitude" , label = None , layer_name = "Marker cluster" , to_ee = False , ) : import pandas as pd if not in_csv . startswith ( "http" ) and ( not os . path . exists ( in_csv ) ) : raise FileNotFoundError ( "The specified input csv does not exist." ) df = pd . read_csv ( in_csv ) col_names = df . columns . values . tolist ( ) if x not in col_names : raise ValueError ( f"x must be one of the following: {', '.join(col_names)}" ) if y not in col_names : raise ValueError ( f"y must be one of the following: {', '.join(col_names)}" ) if label is not None and ( label not in col_names ) : raise ValueError ( f"label must be one of the following: {', '.join(col_names)}" ) self . default_style = { "cursor" : "wait" } if to_ee : fc = csv_to_ee ( in_csv , latitude = y , longitude = x ) self . addLayer ( fc , { } , layer_name ) else : points = list ( zip ( df [ y ] , df [ x ] ) ) if label is not None : labels = df [ label ] markers = [ ipyleaflet . Marker ( location = point , draggable = False , popup = widgets . HTML ( str ( labels [ index ] ) ) , ) for index , point in enumerate ( points ) ] else : markers = [ ipyleaflet . Marker ( location = point , draggable = False ) for point in points ] marker_cluster = ipyleaflet . MarkerCluster ( markers = markers , name = layer_name ) self . add_layer ( marker_cluster ) self . default_style = { "cursor" : "default" }
Adds points from a CSV file containing lat/lon information and display data on the map.
Adds points from a CSV file containing lat / lon information and display data on the map .
"""Adds points from a CSV file containing lat/lon information and display data on the map.

        Args:
            in_csv (str): The file path to the input CSV file.
            x (str, optional): The name of the column containing longitude coordinates. Defaults to "longitude".
            y (str, optional): The name of the column containing latitude coordinates. Defaults to "latitude".
            label (str, optional): The name of the column containing label information to used for marker popup. Defaults to None.
            layer_name (str, optional): The layer name to use. Defaults to "Marker cluster".
            to_ee (bool, optional): Whether to convert the csv to an ee.FeatureCollection.

        Raises:
            FileNotFoundError: The specified input csv does not exist.
            ValueError: The specified x column does not exist.
            ValueError: The specified y column does not exist.
            ValueError: The specified label column does not exist.
        """
The specified input csv does not exist.
The specified input csv does not exist .
FileNotFoundError
The specified x column does not exist.
The specified x column does not exist .
ValueError
The specified y column does not exist.
The specified y column does not exist .
ValueError
The specified label column does not exist.
The specified label column does not exist .
ValueError
self
in_csv
The file path to the input CSV file.
The file path to the input CSV file .
x
The name of the column containing longitude coordinates. Defaults to "longitude".
The name of the column containing longitude coordinates . Defaults to " longitude " .
"longitude"
y
The name of the column containing latitude coordinates. Defaults to "latitude".
The name of the column containing latitude coordinates . Defaults to " latitude " .
"latitude"
label
The name of the column containing label information to used for marker popup. Defaults to None.
The name of the column containing label information to used for marker popup . Defaults to None .
None
layer_name
The layer name to use. Defaults to "Marker cluster".
The layer name to use . Defaults to " Marker cluster " .
"Marker cluster"
to_ee
Whether to convert the csv to an ee.FeatureCollection.
Whether to convert the csv to an ee . FeatureCollection .