@@ -7765,13 +7765,13 @@ def extract_timeseries_to_point(
77657765 lat,
77667766 lon,
77677767 image_collection,
7768- start_date,
7769- end_date,
7770- band_names,
7768+ start_date=None ,
7769+ end_date=None ,
7770+ band_names=None ,
77717771 scale=None,
77727772 crs=None,
77737773 crsTransform=None,
7774- out_df =None,
7774+ out_csv =None,
77757775):
77767776 """
77777777 Extracts pixel time series from an ee.ImageCollection at a point.
@@ -7780,18 +7780,17 @@ def extract_timeseries_to_point(
77807780 lat (float): Latitude of the point.
77817781 lon (float): Longitude of the point.
77827782 image_collection (ee.ImageCollection): Image collection to sample.
7783- start_date (str): Start date (e.g., '2020-01-01').
7784- end_date (str): End date (e.g., '2020-12-31').
7785- band_names (list): List of bands to extract.
7786- scale (float): Sampling scale in meters.
7783+ start_date (str, optional ): Start date (e.g., '2020-01-01').
7784+ end_date (str, optional ): End date (e.g., '2020-12-31').
7785+ band_names (list, optional ): List of bands to extract.
7786+ scale (float, optional ): Sampling scale in meters.
77877787 crs (str, optional): Projection CRS. Defaults to image CRS.
77887788 crsTransform (list, optional): CRS transform matrix (3x2 row-major). Overrides scale.
7789- out_df (str, optional): File path to save CSV. If None, returns a DataFrame.
7789+ out_csv (str, optional): File path to save CSV. If None, returns a DataFrame.
77907790
77917791 Returns:
77927792 pd.DataFrame or None: Time series data if not exporting to CSV.
77937793 """
7794-
77957794 import pandas as pd
77967795 from datetime import datetime
77977796
@@ -7805,11 +7804,11 @@ def extract_timeseries_to_point(
78057804 point = ee.Geometry.Point([lon, lat])
78067805
78077806 try:
7808- image_collection = (
7809- image_collection.filterBounds(point )
7810- .filterDate(start_date, end_date)
7811- .select(band_names)
7812- )
7807+ if start_date and end_date:
7808+ image_collection = image_collection.filterDate(start_date, end_date )
7809+ if band_names:
7810+ image_collection = image_collection .select(band_names)
7811+ image_collection = image_collection.filterBounds(point )
78137812 except Exception as e:
78147813 raise RuntimeError(f"Error filtering image collection: {e}")
78157814
@@ -7829,8 +7828,8 @@ def extract_timeseries_to_point(
78297828 lambda t: datetime.utcfromtimestamp(t / 1000)
78307829 )
78317830
7832- if out_df :
7833- result_df.to_csv(out_df , index=False)
7831+ if out_csv :
7832+ result_df.to_csv(out_csv , index=False)
78347833 else:
78357834 return result_df
78367835
0 commit comments