RadGEEToolbox 1.7.2__tar.gz → 1.7.3__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.
Files changed (23) hide show
  1. {radgeetoolbox-1.7.2 → radgeetoolbox-1.7.3}/PKG-INFO +11 -7
  2. {radgeetoolbox-1.7.2 → radgeetoolbox-1.7.3}/README.md +10 -6
  3. radgeetoolbox-1.7.3/RadGEEToolbox/Export.py +233 -0
  4. {radgeetoolbox-1.7.2 → radgeetoolbox-1.7.3}/RadGEEToolbox/GenericCollection.py +637 -12
  5. {radgeetoolbox-1.7.2 → radgeetoolbox-1.7.3}/RadGEEToolbox/LandsatCollection.py +692 -64
  6. {radgeetoolbox-1.7.2 → radgeetoolbox-1.7.3}/RadGEEToolbox/Sentinel1Collection.py +627 -7
  7. {radgeetoolbox-1.7.2 → radgeetoolbox-1.7.3}/RadGEEToolbox/Sentinel2Collection.py +670 -27
  8. {radgeetoolbox-1.7.2 → radgeetoolbox-1.7.3}/RadGEEToolbox/__init__.py +3 -1
  9. {radgeetoolbox-1.7.2 → radgeetoolbox-1.7.3}/RadGEEToolbox.egg-info/PKG-INFO +11 -7
  10. {radgeetoolbox-1.7.2 → radgeetoolbox-1.7.3}/RadGEEToolbox.egg-info/SOURCES.txt +1 -0
  11. {radgeetoolbox-1.7.2 → radgeetoolbox-1.7.3}/pyproject.toml +1 -1
  12. {radgeetoolbox-1.7.2 → radgeetoolbox-1.7.3}/setup.py +1 -1
  13. {radgeetoolbox-1.7.2 → radgeetoolbox-1.7.3}/LICENSE.txt +0 -0
  14. {radgeetoolbox-1.7.2 → radgeetoolbox-1.7.3}/RadGEEToolbox/CollectionStitch.py +0 -0
  15. {radgeetoolbox-1.7.2 → radgeetoolbox-1.7.3}/RadGEEToolbox/GetPalette.py +0 -0
  16. {radgeetoolbox-1.7.2 → radgeetoolbox-1.7.3}/RadGEEToolbox/VisParams.py +0 -0
  17. {radgeetoolbox-1.7.2 → radgeetoolbox-1.7.3}/RadGEEToolbox.egg-info/dependency_links.txt +0 -0
  18. {radgeetoolbox-1.7.2 → radgeetoolbox-1.7.3}/RadGEEToolbox.egg-info/requires.txt +0 -0
  19. {radgeetoolbox-1.7.2 → radgeetoolbox-1.7.3}/RadGEEToolbox.egg-info/top_level.txt +0 -0
  20. {radgeetoolbox-1.7.2 → radgeetoolbox-1.7.3}/setup.cfg +0 -0
  21. {radgeetoolbox-1.7.2 → radgeetoolbox-1.7.3}/tests/test_landsat_collection.py +0 -0
  22. {radgeetoolbox-1.7.2 → radgeetoolbox-1.7.3}/tests/test_sentinel1_collection.py +0 -0
  23. {radgeetoolbox-1.7.2 → radgeetoolbox-1.7.3}/tests/test_sentinel2_collection.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: RadGEEToolbox
3
- Version: 1.7.2
3
+ Version: 1.7.3
4
4
  Summary: Streamlined Multispectral & SAR Analysis for Google Earth Engine Python API
5
5
  Home-page: https://github.com/radwinskis/RadGEEToolbox
6
6
  Author: Mark Radwin
@@ -43,7 +43,7 @@ Designed for both new and advanced users of Google Earth Engine, RadGEEToolbox m
43
43
 
44
44
  Although similar packages exist (eemont, geetools, etc.), `RadGEEToolbox` extends functionality and provides cohesive, chainable methods for research oriented projects working with Landsat TM & OLI, Sentinel-1 SAR, and/or Sentinel-2 MSI datasets (Table 1). The ultimate goal of `RadGEEToolbox` is to make satellite image processing easier and faster for real world applications relying on the most commonly utilized remote sensing platforms.
45
45
 
46
- As of version `1.7.2`, `RadGEEToolbox` supports any generic image collection via the `GenericCollection` module which allows for utilization of the same data management, temporal reduction, zonal statistics, and data export tools available for the `LandsatCollection`, `Sentinel1Collection`, and `Sentinel2Collection` modules. This allows users to provide their own image collection of choice, such as PRISM or MODIS data, to benefit from the tools available with `RadGEEToolbox`.
46
+ As of version `1.7.3`, `RadGEEToolbox` supports any generic image collection via the `GenericCollection` module which allows for utilization of the same data management, temporal reduction, zonal statistics, and data export tools available for the `LandsatCollection`, `Sentinel1Collection`, and `Sentinel2Collection` modules. This allows users to provide their own image collection of choice, such as PRISM or MODIS data, to benefit from the tools available with `RadGEEToolbox`.
47
47
 
48
48
  ***Table 1.*** *Comparison of functionality between RadGEEToolbox, eemont, and geetools.*
49
49
 
@@ -54,6 +54,7 @@ As of version `1.7.2`, `RadGEEToolbox` supports any generic image collection via
54
54
  | **Zonal Time-series Extraction** | **YES** | **YES** | **YES** |
55
55
  | **Area Time-series Extraction** | **YES** | NO | NO |
56
56
  | **Transect Time-series Extraction** | **YES** | NO | NO |
57
+ | **Mann-Kendall & Sen's Slope Trend Analysis** | **YES** | NO | NO |
57
58
  | **Comprehensive Preprocessing Operations** | **YES** | **YES** | **YES** |
58
59
  | **Reflectance Scaling** | **YES** | **YES** | **YES** |
59
60
  | **Land Surface Temperature Calculation (Landsat)** | **YES** | NO | NO |
@@ -65,6 +66,8 @@ As of version `1.7.2`, `RadGEEToolbox` supports any generic image collection via
65
66
  | **Image Selection by Date or Index** | **YES** | **YES** | NO |
66
67
  | **Visualization Presets/Tools** | **YES** | NO | NO |
67
68
  | **Batch Export to GEE Asset** | **YES** | **YES** | **YES** |
69
+ | **Batch Export to Google Drive** | **YES** | **YES** | **YES** |
70
+
68
71
  _________
69
72
  ## Getting Started with Google Earth Engine
70
73
 
@@ -140,9 +143,10 @@ _________
140
143
  - Image anomaly calculation
141
144
  - SAR utilities for **multilooking**, **speckle filtering**, and **backscatter conversion**
142
145
  - Automated and flexible extraction of **transect and zonal statistics (supporting multiple coordinates or geometries)** across image collections
146
+ - Calculation of Mann-Kendall and Sen's Slope timeseries trend analysis
143
147
  - Easy conversion between RadGEEToolbox and standard Earth Engine objects
144
148
  - Server-side–friendly workflows and caching for **faster, scalable** processing
145
- - Automatically **batch export image collections to GEE assets**
149
+ - Automatically **batch export image collections to GEE assets or to Google Drive**
146
150
 
147
151
  **List of all spectral index calculations available for
148
152
  Landsat (TM & OLI) and Sentinel-2 (MSI) imagery:**
@@ -181,15 +185,15 @@ _____________
181
185
 
182
186
  ### Installing via pip
183
187
 
184
- To install `RadGEEToolbox` version 1.7.2 using pip (NOTE: it is recommended to create a new virtual environment):
188
+ To install `RadGEEToolbox` version 1.7.3 using pip (NOTE: it is recommended to create a new virtual environment):
185
189
 
186
190
  ```bash
187
- pip install RadGEEToolbox==1.7.2
191
+ pip install RadGEEToolbox==1.7.3
188
192
  ```
189
193
 
190
194
  ### Installing via Conda
191
195
 
192
- To install `RadGEEToolbox` version 1.7.2 using conda-forge (NOTE: it is recommended to create a new virtual environment):
196
+ To install `RadGEEToolbox` version 1.7.3 using conda-forge (NOTE: it is recommended to create a new virtual environment):
193
197
 
194
198
  ```bash
195
199
  conda install conda-forge::radgeetoolbox
@@ -220,7 +224,7 @@ To verify that `RadGEEToolbox` was installed correctly:
220
224
  python -c "import RadGEEToolbox; print(RadGEEToolbox.__version__)"
221
225
  ```
222
226
 
223
- You should see `1.7.2` printed as the version number.
227
+ You should see `1.7.3` printed as the version number.
224
228
 
225
229
  ### Want to Visualize Data? Install These Too
226
230
 
@@ -14,7 +14,7 @@ Designed for both new and advanced users of Google Earth Engine, RadGEEToolbox m
14
14
 
15
15
  Although similar packages exist (eemont, geetools, etc.), `RadGEEToolbox` extends functionality and provides cohesive, chainable methods for research oriented projects working with Landsat TM & OLI, Sentinel-1 SAR, and/or Sentinel-2 MSI datasets (Table 1). The ultimate goal of `RadGEEToolbox` is to make satellite image processing easier and faster for real world applications relying on the most commonly utilized remote sensing platforms.
16
16
 
17
- As of version `1.7.2`, `RadGEEToolbox` supports any generic image collection via the `GenericCollection` module which allows for utilization of the same data management, temporal reduction, zonal statistics, and data export tools available for the `LandsatCollection`, `Sentinel1Collection`, and `Sentinel2Collection` modules. This allows users to provide their own image collection of choice, such as PRISM or MODIS data, to benefit from the tools available with `RadGEEToolbox`.
17
+ As of version `1.7.3`, `RadGEEToolbox` supports any generic image collection via the `GenericCollection` module which allows for utilization of the same data management, temporal reduction, zonal statistics, and data export tools available for the `LandsatCollection`, `Sentinel1Collection`, and `Sentinel2Collection` modules. This allows users to provide their own image collection of choice, such as PRISM or MODIS data, to benefit from the tools available with `RadGEEToolbox`.
18
18
 
19
19
  ***Table 1.*** *Comparison of functionality between RadGEEToolbox, eemont, and geetools.*
20
20
 
@@ -25,6 +25,7 @@ As of version `1.7.2`, `RadGEEToolbox` supports any generic image collection via
25
25
  | **Zonal Time-series Extraction** | **YES** | **YES** | **YES** |
26
26
  | **Area Time-series Extraction** | **YES** | NO | NO |
27
27
  | **Transect Time-series Extraction** | **YES** | NO | NO |
28
+ | **Mann-Kendall & Sen's Slope Trend Analysis** | **YES** | NO | NO |
28
29
  | **Comprehensive Preprocessing Operations** | **YES** | **YES** | **YES** |
29
30
  | **Reflectance Scaling** | **YES** | **YES** | **YES** |
30
31
  | **Land Surface Temperature Calculation (Landsat)** | **YES** | NO | NO |
@@ -36,6 +37,8 @@ As of version `1.7.2`, `RadGEEToolbox` supports any generic image collection via
36
37
  | **Image Selection by Date or Index** | **YES** | **YES** | NO |
37
38
  | **Visualization Presets/Tools** | **YES** | NO | NO |
38
39
  | **Batch Export to GEE Asset** | **YES** | **YES** | **YES** |
40
+ | **Batch Export to Google Drive** | **YES** | **YES** | **YES** |
41
+
39
42
  _________
40
43
  ## Getting Started with Google Earth Engine
41
44
 
@@ -111,9 +114,10 @@ _________
111
114
  - Image anomaly calculation
112
115
  - SAR utilities for **multilooking**, **speckle filtering**, and **backscatter conversion**
113
116
  - Automated and flexible extraction of **transect and zonal statistics (supporting multiple coordinates or geometries)** across image collections
117
+ - Calculation of Mann-Kendall and Sen's Slope timeseries trend analysis
114
118
  - Easy conversion between RadGEEToolbox and standard Earth Engine objects
115
119
  - Server-side–friendly workflows and caching for **faster, scalable** processing
116
- - Automatically **batch export image collections to GEE assets**
120
+ - Automatically **batch export image collections to GEE assets or to Google Drive**
117
121
 
118
122
  **List of all spectral index calculations available for
119
123
  Landsat (TM & OLI) and Sentinel-2 (MSI) imagery:**
@@ -152,15 +156,15 @@ _____________
152
156
 
153
157
  ### Installing via pip
154
158
 
155
- To install `RadGEEToolbox` version 1.7.2 using pip (NOTE: it is recommended to create a new virtual environment):
159
+ To install `RadGEEToolbox` version 1.7.3 using pip (NOTE: it is recommended to create a new virtual environment):
156
160
 
157
161
  ```bash
158
- pip install RadGEEToolbox==1.7.2
162
+ pip install RadGEEToolbox==1.7.3
159
163
  ```
160
164
 
161
165
  ### Installing via Conda
162
166
 
163
- To install `RadGEEToolbox` version 1.7.2 using conda-forge (NOTE: it is recommended to create a new virtual environment):
167
+ To install `RadGEEToolbox` version 1.7.3 using conda-forge (NOTE: it is recommended to create a new virtual environment):
164
168
 
165
169
  ```bash
166
170
  conda install conda-forge::radgeetoolbox
@@ -191,7 +195,7 @@ To verify that `RadGEEToolbox` was installed correctly:
191
195
  python -c "import RadGEEToolbox; print(RadGEEToolbox.__version__)"
192
196
  ```
193
197
 
194
- You should see `1.7.2` printed as the version number.
198
+ You should see `1.7.3` printed as the version number.
195
199
 
196
200
  ### Want to Visualize Data? Install These Too
197
201
 
@@ -0,0 +1,233 @@
1
+ import ee
2
+
3
+ class ExportToDrive:
4
+ """
5
+ A class to handle exporting Earth Engine images and image collections to Google Drive.
6
+
7
+ This class supports exporting both native Earth Engine objects (ee.Image, ee.ImageCollection)
8
+ and RadGEEToolbox objects (e.g., LandsatCollection, Sentinel2Collection).
9
+
10
+ It is designed to intelligently handle RadGEEToolbox collections by utilizing their cached
11
+ `.dates` property for naming files, ensuring readable filenames (e.g., 'MyExport_2023-06-01')
12
+ instead of long system IDs.
13
+
14
+ Args:
15
+ input_data (ee.Image, ee.ImageCollection, or RadGEEToolbox object): The data to export.
16
+ Can be a single image, a collection, or a RadGEEToolbox wrapper object.
17
+ description (str): A description of the export task. This serves as the task name in the
18
+ GEE code editor and the default prefix for filenames. Defaults to 'export'.
19
+ folder (str, optional): The name of the destination folder in Google Drive. Defaults to None (root).
20
+ fileNamePrefix (str, optional): The filename prefix. For collections, this is prepended
21
+ to the generated unique name. If None, it defaults to the `description`.
22
+ scale (int): The resolution in meters per pixel. Defaults to 30.
23
+ region (ee.Geometry, optional): The region/geometry to export. Defaults to None (uses image footprint).
24
+ crs (str, optional): The coordinate reference system (e.g., 'EPSG:4326'). Defaults to None (uses image CRS).
25
+ maxPixels (int, optional): The maximum number of pixels allowed in the export. Defaults to 1e13.
26
+ fileFormat (str, optional): The output file format (e.g., 'GeoTIFF', 'TFRecord'). Defaults to 'GeoTIFF'.
27
+ name_pattern (str, optional): A string pattern for naming files when exporting a collection.
28
+ Supported placeholders:
29
+ - {date}: The date of the image. Prioritizes the RadGEEToolbox cached '.dates' list,
30
+ then 'Date_Filter' property, then formatted 'system:time_start'.
31
+ - {id}: The system:index of the image.
32
+ Defaults to '{date}'. The final filename will generally be "{fileNamePrefix}_{name_pattern}".
33
+ date_pattern (str, optional): The date format string to use if falling back to 'system:time_start'
34
+ (e.g., 'YYYY-MM-dd'). Defaults to 'YYYY-MM-dd'.
35
+ **kwargs: Additional keyword arguments passed directly to ee.batch.Export.image.toDrive
36
+ (e.g., 'formatOptions', 'shardSize').
37
+
38
+ Raises:
39
+ ValueError: If the input data type is not supported or if required arguments (like scale) are missing/invalid.
40
+ """
41
+
42
+ def __init__(
43
+ self,
44
+ input_data,
45
+ description="export",
46
+ folder=None,
47
+ fileNamePrefix=None,
48
+ scale=30,
49
+ region=None,
50
+ crs=None,
51
+ maxPixels=1e13,
52
+ fileFormat="GeoTIFF",
53
+ name_pattern="{date}",
54
+ date_pattern="YYYY-MM-dd",
55
+ **kwargs
56
+ ):
57
+ # 1. Capture RadGEEToolbox Metadata BEFORE unwrapping
58
+ # We explicitly look for the cached .dates list which is standard in RadGEEToolbox collections
59
+ self.radgee_dates = getattr(input_data, "dates", None)
60
+
61
+ # 2. Input Processing & Conversion
62
+ self.ee_object = self._validate_and_convert_input(input_data)
63
+
64
+ # Determine strict type of the resulting EE object
65
+ self.is_collection = isinstance(self.ee_object, ee.ImageCollection)
66
+ self.is_image = isinstance(self.ee_object, ee.Image)
67
+
68
+ if not self.is_collection and not self.is_image:
69
+ raise ValueError(
70
+ "Processed input must be an ee.Image or ee.ImageCollection. "
71
+ f"Got type: {type(self.ee_object)}"
72
+ )
73
+
74
+ # 3. Argument Validation
75
+ if scale is None:
76
+ raise ValueError("The 'scale' argument is required for export.")
77
+
78
+ if description is None or not isinstance(description, str):
79
+ raise ValueError("The 'description' argument must be a valid string.")
80
+
81
+ # Check for extraneous collection arguments when exporting a single image
82
+ if self.is_image:
83
+ if name_pattern != "{date}" or date_pattern != "YYYY-MM-dd":
84
+ print(
85
+ "Info: Extra arguments 'name_pattern' and/or 'date_pattern' were provided "
86
+ "but will be ignored because the input is a single image."
87
+ )
88
+
89
+ # 4. Store Attributes
90
+ self.description = description
91
+ self.folder = folder
92
+ self.fileNamePrefix = fileNamePrefix if fileNamePrefix else description
93
+ self.scale = scale
94
+ self.region = region
95
+ self.crs = crs
96
+ self.maxPixels = maxPixels
97
+ self.fileFormat = fileFormat
98
+ self.name_pattern = name_pattern
99
+ self.date_pattern = date_pattern
100
+ self.extra_kwargs = kwargs
101
+
102
+ def _validate_and_convert_input(self, input_data):
103
+ """
104
+ Helper to unwrap RadGEEToolbox objects or verify EE objects.
105
+ """
106
+ # Check if it's a RadGEEToolbox object (duck typing checks for 'collection' attribute)
107
+ if hasattr(input_data, "collection") and isinstance(input_data.collection, ee.ImageCollection):
108
+ return input_data.collection
109
+
110
+ # Check if it is already a valid EE object
111
+ if isinstance(input_data, (ee.Image, ee.ImageCollection)):
112
+ return input_data
113
+
114
+ # Attempt to handle computed objects that are implicitly images
115
+ try:
116
+ return ee.Image(input_data)
117
+ except Exception:
118
+ pass
119
+
120
+ raise ValueError(
121
+ "Input data is not a recognized RadGEEToolbox object, ee.Image, or ee.ImageCollection."
122
+ )
123
+
124
+ def export(self):
125
+ """
126
+ Initiates the export process. Detects whether to run a single task
127
+ or iterate through a collection.
128
+ """
129
+ if self.is_image:
130
+ self._export_single_image()
131
+ elif self.is_collection:
132
+ self._export_collection()
133
+
134
+ def _export_single_image(self):
135
+ """Internal method to export a single image."""
136
+ print(f"Starting export task for single image: {self.description}")
137
+
138
+ # Construct parameters dict, filtering out None values
139
+ params = {
140
+ "image": self.ee_object,
141
+ "description": self.description,
142
+ "folder": self.folder,
143
+ "fileNamePrefix": self.fileNamePrefix,
144
+ "scale": self.scale,
145
+ "region": self.region,
146
+ "crs": self.crs,
147
+ "maxPixels": self.maxPixels,
148
+ "fileFormat": self.fileFormat,
149
+ }
150
+ # Merge basic params with any extra kwargs provided
151
+ params.update(self.extra_kwargs)
152
+ # Remove keys with None values to allow GEE defaults to take over
153
+ params = {k: v for k, v in params.items() if v is not None}
154
+
155
+ task = ee.batch.Export.image.toDrive(**params)
156
+ task.start()
157
+ print(f"Task ID: {task.id}")
158
+
159
+ def _export_collection(self):
160
+ """Internal method to iterate and export a collection."""
161
+ # Get the size of the collection locally
162
+ try:
163
+ count = self.ee_object.size().getInfo()
164
+ except Exception as e:
165
+ raise ValueError(f"Could not determine collection size. Error: {e}")
166
+
167
+ if count == 0:
168
+ print("The image collection is empty. No export tasks were started.")
169
+ return
170
+
171
+ print(f"Processing collection export... ({count} images found)")
172
+
173
+ # Convert collection to list for iteration
174
+ col_list = self.ee_object.toList(count)
175
+
176
+ for i in range(count):
177
+ img = ee.Image(col_list.get(i))
178
+
179
+ # Fetch metadata efficiently in one call
180
+ meta = {}
181
+ try:
182
+ meta = img.toDictionary(["Date_Filter", "system:time_start", "system:index"]).getInfo()
183
+ except Exception:
184
+ pass
185
+
186
+ # --- Resolve Date ---
187
+ # Priority 1: Use the cached client-side list from RadGEEToolbox if available
188
+ if self.radgee_dates and i < len(self.radgee_dates):
189
+ date_val = self.radgee_dates[i]
190
+ # Priority 2: Check for 'Date_Filter' property (RadGEEToolbox standard)
191
+ elif "Date_Filter" in meta:
192
+ date_val = meta["Date_Filter"]
193
+ # Priority 3: Fallback to 'system:time_start'
194
+ elif "system:time_start" in meta:
195
+ date_val = ee.Date(meta["system:time_start"]).format(self.date_pattern).getInfo()
196
+ else:
197
+ date_val = "no_date"
198
+
199
+ # --- Resolve ID ---
200
+ # Use metadata dictionary or fallback to generated index
201
+ sys_index = meta.get("system:index", f"img_{i}")
202
+
203
+ # --- Generate Filename ---
204
+ # Apply pattern. Default is "{date}".
205
+ name_str = self.name_pattern.format(id=sys_index, date=date_val)
206
+
207
+ # Combine with global prefix.
208
+ # If prefix is "MyExport" and date is "2023-01-01", result is "MyExport_2023-01-01"
209
+ final_filename = f"{self.fileNamePrefix}_{name_str}" if self.fileNamePrefix else name_str
210
+
211
+ # Ensure unique description for the task (must be unique per task)
212
+ # We use the date in the description to make it easier to track in the GEE Task Manager
213
+ final_desc = f"{self.description}_{date_val}_{i}"
214
+
215
+ # Construct parameters
216
+ params = {
217
+ "image": img,
218
+ "description": final_desc,
219
+ "folder": self.folder,
220
+ "fileNamePrefix": final_filename,
221
+ "scale": self.scale,
222
+ "region": self.region,
223
+ "crs": self.crs,
224
+ "maxPixels": self.maxPixels,
225
+ "fileFormat": self.fileFormat,
226
+ }
227
+ params.update(self.extra_kwargs)
228
+ params = {k: v for k, v in params.items() if v is not None}
229
+
230
+ task = ee.batch.Export.image.toDrive(**params)
231
+ task.start()
232
+
233
+ print(f"Successfully queued {count} export tasks.")