geemap/geemap.py
def extract_values_to_points(self, filename):
        """Exports pixel values to a csv file based on user-drawn geometries.

        Args:
            filename (str): The output file path to the csv file or shapefile.
        """
        import csv

        filename = os.path.abspath(filename)
        allowed_formats = ["csv", "shp"]
        ext = filename[-3:]

        if ext not in allowed_formats:
            print(
                "The output file must be one of the following: {}".format(
                    ", ".join(allowed_formats)
                )
            )
            return

        out_dir = os.path.dirname(filename)
        out_csv = filename[:-3] + "csv"
        out_shp = filename[:-3] + "shp"
        if not os.path.exists(out_dir):
            os.makedirs(out_dir)

        count = len(self.chart_points)
        out_list = []
        if count > 0:
            header = ["id", "longitude", "latitude"] + self.chart_labels
            out_list.append(header)

            for i in range(0, count):
                id = i + 1
                line = [id] + self.chart_points[i] + self.chart_values[i]
                out_list.append(line)

            with open(out_csv, "w", newline="") as f:
                writer = csv.writer(f)
                writer.writerows(out_list)

            if ext == "csv":
                print(f"The csv file has been saved to: {out_csv}")
            else:
                csv_to_shp(out_csv, out_shp)
                print(f"The shapefile has been saved to: {out_shp}")
Exports pixel values to a csv file based on user-drawn geometries.

        Args:
            filename (str): The output file path to the csv file or shapefile.
        
Exports pixel values to a csv file based on user-drawn geometries.
Exports pixel values to a csv file based on user - drawn geometries .
def extract_values_to_points(self, filename):
        import csv
        filename = os.path.abspath(filename)
        allowed_formats = ["csv", "shp"]
        ext = filename[-3:]
        if ext not in allowed_formats:
            print(
                "The output file must be one of the following: {}".format(
                    ", ".join(allowed_formats)
                )
            )
            return
        out_dir = os.path.dirname(filename)
        out_csv = filename[:-3] + "csv"
        out_shp = filename[:-3] + "shp"
        if not os.path.exists(out_dir):
            os.makedirs(out_dir)
        count = len(self.chart_points)
        out_list = []
        if count > 0:
            header = ["id", "longitude", "latitude"] + self.chart_labels
            out_list.append(header)
            for i in range(0, count):
                id = i + 1
                line = [id] + self.chart_points[i] + self.chart_values[i]
                out_list.append(line)
            with open(out_csv, "w", newline="") as f:
                writer = csv.writer(f)
                writer.writerows(out_list)
            if ext == "csv":
                print(f"The csv file has been saved to: {out_csv}")
            else:
                csv_to_shp(out_csv, out_shp)
                print(f"The shapefile has been saved to: {out_shp}")
def extract_values_to_points ( self , filename ) : import csv filename = os . path . abspath ( filename ) allowed_formats = [ "csv" , "shp" ] ext = filename [ - 3 : ] if ext not in allowed_formats : print ( "The output file must be one of the following: {}" . format ( ", " . join ( allowed_formats ) ) ) return out_dir = os . path . dirname ( filename ) out_csv = filename [ : - 3 ] + "csv" out_shp = filename [ : - 3 ] + "shp" if not os . path . exists ( out_dir ) : os . makedirs ( out_dir ) count = len ( self . chart_points ) out_list = [ ] if count > 0 : header = [ "id" , "longitude" , "latitude" ] + self . chart_labels out_list . append ( header ) for i in range ( 0 , count ) : id = i + 1 line = [ id ] + self . chart_points [ i ] + self . chart_values [ i ] out_list . append ( line ) with open ( out_csv , "w" , newline = "" ) as f : writer = csv . writer ( f ) writer . writerows ( out_list ) if ext == "csv" : print ( f"The csv file has been saved to: {out_csv}" ) else : csv_to_shp ( out_csv , out_shp ) print ( f"The shapefile has been saved to: {out_shp}" )
Exports pixel values to a csv file based on user-drawn geometries.
Exports pixel values to a csv file based on user - drawn geometries .
"""Exports pixel values to a csv file based on user-drawn geometries.

        Args:
            filename (str): The output file path to the csv file or shapefile.
        """
self
filename
The output file path to the csv file or shapefile.
The output file path to the csv file or shapefile .