climate-data-download 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Kayode Adebayo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,274 @@
1
+ Metadata-Version: 2.4
2
+ Name: climate_data_download
3
+ Version: 0.1.0
4
+ Summary: Download and aggregate climate datasets from Google Earth Engine for watershed or polygon AOIs.
5
+ Author: Kayode Adebayo
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/Kaysharp-cloud/climate_data_download
8
+ Project-URL: Repository, https://github.com/Kaysharp-cloud/climate_data_download
9
+ Project-URL: Issues, https://github.com/Kaysharp-cloud/climate_data_download/issues
10
+ Keywords: climate,google-earth-engine,earth-engine,gee,prism,daymet,gridmet,hydrology,geospatial
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Scientific/Engineering :: GIS
21
+ Classifier: Topic :: Scientific/Engineering :: Hydrology
22
+ Requires-Python: >=3.9
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: earthengine-api>=0.1.390
26
+ Requires-Dist: geemap>=0.32.0
27
+ Requires-Dist: geopandas>=0.14.0
28
+ Requires-Dist: pandas>=2.0.0
29
+ Requires-Dist: matplotlib>=3.7.0
30
+ Provides-Extra: dev
31
+ Requires-Dist: build>=1.0.0; extra == "dev"
32
+ Requires-Dist: twine>=5.0.0; extra == "dev"
33
+ Requires-Dist: pytest>=8.0.0; extra == "dev"
34
+ Requires-Dist: ruff>=0.4.0; extra == "dev"
35
+ Dynamic: license-file
36
+
37
+ # climate_data_download
38
+
39
+ `climate_data_download` is a small Python package for extracting climate data from Google Earth Engine over a watershed or polygon shapefile. It was designed for hydrology, water resources, climate, and environmental data workflows.
40
+
41
+ The package currently includes built-in support for:
42
+
43
+ - PRISM monthly: `OREGONSTATE/PRISM/ANm`
44
+ - PRISM daily: `OREGONSTATE/PRISM/ANd`
45
+ - Daymet daily: `NASA/ORNL/DAYMET_V4`
46
+ - GRIDMET daily: `IDAHO_EPSCOR/GRIDMET`
47
+ - Custom Earth Engine ImageCollections
48
+
49
+ For PRISM, the package automatically uses `AN81` through 2020 and `AN91` from 2021 onward. For Daymet and GRIDMET, no PRISM-style `dataset_type` filter is applied.
50
+
51
+ ## Installation
52
+
53
+ ```bash
54
+ pip install climate_data_download
55
+ ```
56
+
57
+ For local development:
58
+
59
+ ```bash
60
+ git clone https://github.com/Kaysharp-cloud/climate_data_download.git
61
+ cd climate_data_download
62
+ pip install -e .[dev]
63
+ ```
64
+
65
+ ## Earth Engine setup
66
+
67
+ Before using the package, you need access to Google Earth Engine and must authenticate once:
68
+
69
+ ```python
70
+ from climate_data_download import authenticate_ee
71
+
72
+ authenticate_ee()
73
+ ```
74
+
75
+ If your Earth Engine setup requires a Google Cloud project ID:
76
+
77
+ ```python
78
+ from climate_data_download import authenticate_ee
79
+
80
+ authenticate_ee(project="your-earth-engine-project-id")
81
+ ```
82
+
83
+ ## Basic usage
84
+
85
+ ```python
86
+ from climate_data_download import authenticate_ee, run_gee_climate_workflow
87
+
88
+ authenticate_ee()
89
+
90
+ shp_path = "Big_sioux_SD_watershed/Big_sioux_SD_watershed.shp"
91
+
92
+ result = run_gee_climate_workflow(
93
+ shp_path=shp_path,
94
+ variables=["ppt"],
95
+ start_year=1996,
96
+ end_year=2025,
97
+ dataset_key="prism_monthly",
98
+ )
99
+
100
+ raw_df = result["raw_df"]
101
+ annual_df = result["annual_df"]
102
+
103
+ print(raw_df.head())
104
+ print(annual_df.head())
105
+ ```
106
+
107
+ By default, the function returns both:
108
+
109
+ - `raw_df`: daily or monthly watershed-average values, depending on the dataset
110
+ - `annual_df`: annual watershed-average values
111
+
112
+ Nothing is saved, plotted, or mapped by default.
113
+
114
+ ## PRISM monthly precipitation, Tmax, and Tmin
115
+
116
+ ```python
117
+ result = run_gee_climate_workflow(
118
+ shp_path=shp_path,
119
+ variables=["ppt", "tmax", "tmin"],
120
+ start_year=1996,
121
+ end_year=2025,
122
+ dataset_key="prism_monthly",
123
+ )
124
+
125
+ raw_df = result["raw_df"]
126
+ annual_df = result["annual_df"]
127
+ ```
128
+
129
+ For PRISM precipitation, monthly `ppt` values are summed to annual precipitation. Temperature variables are averaged to annual values.
130
+
131
+ ## PRISM daily
132
+
133
+ ```python
134
+ result = run_gee_climate_workflow(
135
+ shp_path=shp_path,
136
+ variables=["ppt", "tmax", "tmin"],
137
+ start_year=1996,
138
+ end_year=2025,
139
+ dataset_key="prism_daily",
140
+ )
141
+ ```
142
+
143
+ Daily extraction across many decades can be slow because each daily image is reduced over the AOI. If you only need annual values and the long-term raster, use:
144
+
145
+ ```python
146
+ result = run_gee_climate_workflow(
147
+ shp_path=shp_path,
148
+ variables=["ppt", "tmax", "tmin"],
149
+ start_year=1996,
150
+ end_year=2025,
151
+ dataset_key="prism_daily",
152
+ compute_raw=False,
153
+ )
154
+ ```
155
+
156
+ ## Daymet daily
157
+
158
+ ```python
159
+ result = run_gee_climate_workflow(
160
+ shp_path=shp_path,
161
+ variables=["prcp", "tmax", "tmin"],
162
+ start_year=1996,
163
+ end_year=2024,
164
+ dataset_key="daymet_daily",
165
+ )
166
+ ```
167
+
168
+ ## GRIDMET daily
169
+
170
+ ```python
171
+ result = run_gee_climate_workflow(
172
+ shp_path=shp_path,
173
+ variables=["pr", "tmmx", "tmmn"],
174
+ start_year=1996,
175
+ end_year=2025,
176
+ dataset_key="gridmet_daily",
177
+ convert_gridmet_temp_to_c=True,
178
+ )
179
+ ```
180
+
181
+ By default, GRIDMET `tmmx` and `tmmn` are converted from Kelvin to Celsius.
182
+
183
+ ## Optional map, plots, CSV, and GeoTIFF
184
+
185
+ These are off by default. Turn them on only when needed:
186
+
187
+ ```python
188
+ result = run_gee_climate_workflow(
189
+ shp_path=shp_path,
190
+ variables=["ppt", "tmax", "tmin"],
191
+ start_year=1996,
192
+ end_year=2025,
193
+ dataset_key="prism_monthly",
194
+ show_map=True,
195
+ show_plots=True,
196
+ save_csv=True,
197
+ csv_folder="climate_csv_outputs",
198
+ csv_prefix="big_sioux_prism_monthly",
199
+ save_tiff_local=True,
200
+ local_tiff_folder="climate_tiff_outputs",
201
+ local_tiff_name="big_sioux_prism_monthly_long_term_1996_2025.tif",
202
+ )
203
+ ```
204
+
205
+ The GeoTIFF is the long-term annual average image. For multiple variables, it is exported as a multi-band GeoTIFF.
206
+
207
+ ## Custom Earth Engine ImageCollection
208
+
209
+ ```python
210
+ result = run_gee_climate_workflow(
211
+ shp_path=shp_path,
212
+ dataset_key="custom",
213
+ collection_id="YOUR/GEE/IMAGE_COLLECTION_ID",
214
+ variables=["your_precip_band", "your_temp_band"],
215
+ start_year=2001,
216
+ end_year=2020,
217
+ time_step="daily",
218
+ scale=5000,
219
+ aggregation_rules={
220
+ "your_precip_band": "sum",
221
+ "your_temp_band": "mean",
222
+ },
223
+ )
224
+ ```
225
+
226
+ If your custom dataset requires year-specific property filters, pass a callable:
227
+
228
+ ```python
229
+ def my_yearly_filter(year):
230
+ if year <= 2020:
231
+ return {"version": "old"}
232
+ return {"version": "new"}
233
+
234
+ result = run_gee_climate_workflow(
235
+ shp_path=shp_path,
236
+ dataset_key="custom",
237
+ collection_id="YOUR/GEE/IMAGE_COLLECTION_ID",
238
+ variables=["precip"],
239
+ start_year=1990,
240
+ end_year=2025,
241
+ time_step="monthly",
242
+ scale=5000,
243
+ aggregation_rules={"precip": "sum"},
244
+ yearly_property_filters=my_yearly_filter,
245
+ )
246
+ ```
247
+
248
+ ## Return object
249
+
250
+ The function returns a dictionary with:
251
+
252
+ ```python
253
+ result["raw_df"]
254
+ result["annual_df"]
255
+ result["raw_collection"]
256
+ result["annual_collection"]
257
+ result["long_term_image"]
258
+ result["aoi_gdf"]
259
+ result["aoi_fc"]
260
+ result["aoi"]
261
+ result["map"]
262
+ result["aggregation_rules"]
263
+ ```
264
+
265
+ ## Notes
266
+
267
+ - The package does not download climate data automatically at import time.
268
+ - You must have a working Earth Engine account.
269
+ - Large daily extractions can take time and it is advisable to download in chunks if you are considering downloading daily dataset for a long period of time. Use `compute_raw=False` if annual outputs are enough.
270
+ - For a shapefile, keep `.shp`, `.shx`, `.dbf`, and `.prj` together in the same folder.
271
+
272
+ ## License
273
+
274
+ MIT License.
@@ -0,0 +1,238 @@
1
+ # climate_data_download
2
+
3
+ `climate_data_download` is a small Python package for extracting climate data from Google Earth Engine over a watershed or polygon shapefile. It was designed for hydrology, water resources, climate, and environmental data workflows.
4
+
5
+ The package currently includes built-in support for:
6
+
7
+ - PRISM monthly: `OREGONSTATE/PRISM/ANm`
8
+ - PRISM daily: `OREGONSTATE/PRISM/ANd`
9
+ - Daymet daily: `NASA/ORNL/DAYMET_V4`
10
+ - GRIDMET daily: `IDAHO_EPSCOR/GRIDMET`
11
+ - Custom Earth Engine ImageCollections
12
+
13
+ For PRISM, the package automatically uses `AN81` through 2020 and `AN91` from 2021 onward. For Daymet and GRIDMET, no PRISM-style `dataset_type` filter is applied.
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ pip install climate_data_download
19
+ ```
20
+
21
+ For local development:
22
+
23
+ ```bash
24
+ git clone https://github.com/Kaysharp-cloud/climate_data_download.git
25
+ cd climate_data_download
26
+ pip install -e .[dev]
27
+ ```
28
+
29
+ ## Earth Engine setup
30
+
31
+ Before using the package, you need access to Google Earth Engine and must authenticate once:
32
+
33
+ ```python
34
+ from climate_data_download import authenticate_ee
35
+
36
+ authenticate_ee()
37
+ ```
38
+
39
+ If your Earth Engine setup requires a Google Cloud project ID:
40
+
41
+ ```python
42
+ from climate_data_download import authenticate_ee
43
+
44
+ authenticate_ee(project="your-earth-engine-project-id")
45
+ ```
46
+
47
+ ## Basic usage
48
+
49
+ ```python
50
+ from climate_data_download import authenticate_ee, run_gee_climate_workflow
51
+
52
+ authenticate_ee()
53
+
54
+ shp_path = "Big_sioux_SD_watershed/Big_sioux_SD_watershed.shp"
55
+
56
+ result = run_gee_climate_workflow(
57
+ shp_path=shp_path,
58
+ variables=["ppt"],
59
+ start_year=1996,
60
+ end_year=2025,
61
+ dataset_key="prism_monthly",
62
+ )
63
+
64
+ raw_df = result["raw_df"]
65
+ annual_df = result["annual_df"]
66
+
67
+ print(raw_df.head())
68
+ print(annual_df.head())
69
+ ```
70
+
71
+ By default, the function returns both:
72
+
73
+ - `raw_df`: daily or monthly watershed-average values, depending on the dataset
74
+ - `annual_df`: annual watershed-average values
75
+
76
+ Nothing is saved, plotted, or mapped by default.
77
+
78
+ ## PRISM monthly precipitation, Tmax, and Tmin
79
+
80
+ ```python
81
+ result = run_gee_climate_workflow(
82
+ shp_path=shp_path,
83
+ variables=["ppt", "tmax", "tmin"],
84
+ start_year=1996,
85
+ end_year=2025,
86
+ dataset_key="prism_monthly",
87
+ )
88
+
89
+ raw_df = result["raw_df"]
90
+ annual_df = result["annual_df"]
91
+ ```
92
+
93
+ For PRISM precipitation, monthly `ppt` values are summed to annual precipitation. Temperature variables are averaged to annual values.
94
+
95
+ ## PRISM daily
96
+
97
+ ```python
98
+ result = run_gee_climate_workflow(
99
+ shp_path=shp_path,
100
+ variables=["ppt", "tmax", "tmin"],
101
+ start_year=1996,
102
+ end_year=2025,
103
+ dataset_key="prism_daily",
104
+ )
105
+ ```
106
+
107
+ Daily extraction across many decades can be slow because each daily image is reduced over the AOI. If you only need annual values and the long-term raster, use:
108
+
109
+ ```python
110
+ result = run_gee_climate_workflow(
111
+ shp_path=shp_path,
112
+ variables=["ppt", "tmax", "tmin"],
113
+ start_year=1996,
114
+ end_year=2025,
115
+ dataset_key="prism_daily",
116
+ compute_raw=False,
117
+ )
118
+ ```
119
+
120
+ ## Daymet daily
121
+
122
+ ```python
123
+ result = run_gee_climate_workflow(
124
+ shp_path=shp_path,
125
+ variables=["prcp", "tmax", "tmin"],
126
+ start_year=1996,
127
+ end_year=2024,
128
+ dataset_key="daymet_daily",
129
+ )
130
+ ```
131
+
132
+ ## GRIDMET daily
133
+
134
+ ```python
135
+ result = run_gee_climate_workflow(
136
+ shp_path=shp_path,
137
+ variables=["pr", "tmmx", "tmmn"],
138
+ start_year=1996,
139
+ end_year=2025,
140
+ dataset_key="gridmet_daily",
141
+ convert_gridmet_temp_to_c=True,
142
+ )
143
+ ```
144
+
145
+ By default, GRIDMET `tmmx` and `tmmn` are converted from Kelvin to Celsius.
146
+
147
+ ## Optional map, plots, CSV, and GeoTIFF
148
+
149
+ These are off by default. Turn them on only when needed:
150
+
151
+ ```python
152
+ result = run_gee_climate_workflow(
153
+ shp_path=shp_path,
154
+ variables=["ppt", "tmax", "tmin"],
155
+ start_year=1996,
156
+ end_year=2025,
157
+ dataset_key="prism_monthly",
158
+ show_map=True,
159
+ show_plots=True,
160
+ save_csv=True,
161
+ csv_folder="climate_csv_outputs",
162
+ csv_prefix="big_sioux_prism_monthly",
163
+ save_tiff_local=True,
164
+ local_tiff_folder="climate_tiff_outputs",
165
+ local_tiff_name="big_sioux_prism_monthly_long_term_1996_2025.tif",
166
+ )
167
+ ```
168
+
169
+ The GeoTIFF is the long-term annual average image. For multiple variables, it is exported as a multi-band GeoTIFF.
170
+
171
+ ## Custom Earth Engine ImageCollection
172
+
173
+ ```python
174
+ result = run_gee_climate_workflow(
175
+ shp_path=shp_path,
176
+ dataset_key="custom",
177
+ collection_id="YOUR/GEE/IMAGE_COLLECTION_ID",
178
+ variables=["your_precip_band", "your_temp_band"],
179
+ start_year=2001,
180
+ end_year=2020,
181
+ time_step="daily",
182
+ scale=5000,
183
+ aggregation_rules={
184
+ "your_precip_band": "sum",
185
+ "your_temp_band": "mean",
186
+ },
187
+ )
188
+ ```
189
+
190
+ If your custom dataset requires year-specific property filters, pass a callable:
191
+
192
+ ```python
193
+ def my_yearly_filter(year):
194
+ if year <= 2020:
195
+ return {"version": "old"}
196
+ return {"version": "new"}
197
+
198
+ result = run_gee_climate_workflow(
199
+ shp_path=shp_path,
200
+ dataset_key="custom",
201
+ collection_id="YOUR/GEE/IMAGE_COLLECTION_ID",
202
+ variables=["precip"],
203
+ start_year=1990,
204
+ end_year=2025,
205
+ time_step="monthly",
206
+ scale=5000,
207
+ aggregation_rules={"precip": "sum"},
208
+ yearly_property_filters=my_yearly_filter,
209
+ )
210
+ ```
211
+
212
+ ## Return object
213
+
214
+ The function returns a dictionary with:
215
+
216
+ ```python
217
+ result["raw_df"]
218
+ result["annual_df"]
219
+ result["raw_collection"]
220
+ result["annual_collection"]
221
+ result["long_term_image"]
222
+ result["aoi_gdf"]
223
+ result["aoi_fc"]
224
+ result["aoi"]
225
+ result["map"]
226
+ result["aggregation_rules"]
227
+ ```
228
+
229
+ ## Notes
230
+
231
+ - The package does not download climate data automatically at import time.
232
+ - You must have a working Earth Engine account.
233
+ - Large daily extractions can take time and it is advisable to download in chunks if you are considering downloading daily dataset for a long period of time. Use `compute_raw=False` if annual outputs are enough.
234
+ - For a shapefile, keep `.shp`, `.shx`, `.dbf`, and `.prj` together in the same folder.
235
+
236
+ ## License
237
+
238
+ MIT License.
@@ -0,0 +1,29 @@
1
+ """Utilities for downloading and aggregating climate data from Google Earth Engine."""
2
+
3
+ from .core import (
4
+ aggregate_collection_to_annual_image,
5
+ authenticate_ee,
6
+ build_annual_collection,
7
+ build_climate_collection,
8
+ infer_aggregation_rule,
9
+ make_long_term_average_image,
10
+ read_aoi_from_shapefile,
11
+ run_gee_climate_workflow,
12
+ )
13
+ from .datasets import CLIMATE_DATASETS, get_dataset_config, list_supported_datasets
14
+
15
+ __all__ = [
16
+ "CLIMATE_DATASETS",
17
+ "aggregate_collection_to_annual_image",
18
+ "authenticate_ee",
19
+ "build_annual_collection",
20
+ "build_climate_collection",
21
+ "get_dataset_config",
22
+ "infer_aggregation_rule",
23
+ "list_supported_datasets",
24
+ "make_long_term_average_image",
25
+ "read_aoi_from_shapefile",
26
+ "run_gee_climate_workflow",
27
+ ]
28
+
29
+ __version__ = "0.1.0"