Skip to content

Add utility function for extracting point-based time series from Earth Engine + example notebook#2278

Merged
giswqs merged 7 commits intogee-community:masterfrom
geonextgis:features
Jul 10, 2025
Merged

Add utility function for extracting point-based time series from Earth Engine + example notebook#2278
giswqs merged 7 commits intogee-community:masterfrom
geonextgis:features

Conversation

@geonextgis
Copy link
Copy Markdown
Contributor

@geonextgis geonextgis commented Jun 29, 2025

This PR introduces a new helper function extract_timeseries_to_point() for extracting pixel-level time series from a Google Earth Engine ImageCollection at a given geographic coordinate.

✅ Highlights:

  • Extracts time series from daily or multi-temporal Earth observation collections at a specific point.

  • Supports:

    • Band selection (band_names)
    • Date filtering (start_date, end_date)
    • Custom projection and resolution via scale, crs, and crsTransform
  • Returns a pandas.DataFrame or saves the result directly to CSV.

  • Includes clear error handling for invalid inputs and empty results.

📘 New Example Notebook:

  • Added 152_extract_timeseries_to_point.ipynb to demonstrate how to use the function with the ERA5-Land Daily Aggregated dataset:
lat = 28.60
lon = 77.22
start_date = '2000-01-01'
end_date = '2015-12-31'

image_collection = ee.ImageCollection("ECMWF/ERA5_LAND/DAILY_AGGR")
band_names = ['temperature_2m_min', 'temperature_2m_max', 'total_precipitation_sum']
scale = 11132

result = geemap.extract_timeseries_to_point(
    lat=lat,
    lon=lon,
    image_collection=image_collection,
    band_names=band_names,
    start_date=start_date,
    end_date=end_date,
    scale=scale
)

print(result.shape)
result.head()

💡 Use Cases:

  • Point-based climate data extraction for crop modeling, weather forecasting, or agronomic simulations.
  • Simplifies access to long time series at specific coordinates for research and operational workflows.

@giswqs
Copy link
Copy Markdown
Member

giswqs commented Jun 29, 2025

Thank you for the PR. This added functionality seems to be very similar to the extract_values_to_points() function. Although it requires an ee.Image, you can turn any ee.ImageCollection into an ee.Image using collection.toBands().

https://geemap.org/common/#geemap.common.extract_values_to_points

@geonextgis
Copy link
Copy Markdown
Contributor Author

Thank you for the PR. This added functionality seems to be very similar to the extract_values_to_points() function. Although it requires an ee.Image, you can turn any ee.ImageCollection into an ee.Image using collection.toBands().

https://geemap.org/common/#geemap.common.extract_values_to_points

Dear Dr. Qiusheng,

Thank you for the feedback. You're absolutely right — extract_values_to_points() is a great utility. However, in my experience, it can struggle with large-scale time series extraction, and it doesn’t preserve the timestamp information in a time series–friendly format.

The new function is designed specifically to address this. It extracts values while retaining the temporal dimension, which is crucial for applications like agricultural modeling where consistent time steps and clean time series data are essential.

I’d be happy to adjust or integrate the functionality more closely with existing methods if needed.

Best regards,
Krishnagopal

Here is a screenshot of the output.
{B9288B15-D682-456A-B1AF-D51E3255C059}

@giswqs
Copy link
Copy Markdown
Member

giswqs commented Jun 29, 2025

That makes sense. Please also modify mkdocs.yml so that the notebook example shows up on the website.

https://github.com/gee-community/geemap/blob/master/mkdocs.yml#L314

@geonextgis
Copy link
Copy Markdown
Contributor Author

Thanks! I've updated the mkdocs.yml file as requested. Let me know if there's anything else you'd like me to adjust. 😊

@geonextgis
Copy link
Copy Markdown
Contributor Author

Dear Dr. Qiusheng,

Just a quick follow-up regarding my recent pull request to the geemap repository. I've incorporated your suggestion by updating mkdocs.yml to ensure the notebook example appears correctly on the website.

Please let me know if there's anything further needed from my side. If everything looks good, I'd appreciate it if you could consider merging it once all the checks pass.

Thank you again for your time and valuable feedback.

Best regards,
Krishnagopal

@geonextgis
Copy link
Copy Markdown
Contributor Author

The earlier failure might be due to missing GDAL system dependencies during the build process. I have added the following lines to docs-build.yml, which should resolve the issue. Hopefully it will work.

- name: Install GDAL system dependencies  
  run: sudo apt-get update && sudo apt-get install -y gdal-bin libgdal-dev

@geonextgis
Copy link
Copy Markdown
Contributor Author

Dear Dr. Quisheng,

I’ve updated the branch to resolve the issue that occurred earlier during merging. Could you please take a look when you get a chance and let me know if everything looks okay to merge?

Thank you very much for your time and help! 🙏

Comment thread geemap/common.py
Comment on lines +7768 to +7770
start_date,
end_date,
band_names,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess these three params can be optional. If not specified, just don't use filterDate or select bands.

Comment thread geemap/common.py
scale=None,
crs=None,
crsTransform=None,
out_df=None,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest changing param name to output or out_csv. out_df is a bit confusing as the output here is not really a df.

@giswqs giswqs merged commit 6dab1fe into gee-community:master Jul 10, 2025
14 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants