RadGEEToolbox 1.6.1__py3-none-any.whl → 1.6.3__py3-none-any.whl
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.
- RadGEEToolbox/LandsatCollection.py +38 -209
- RadGEEToolbox/Sentinel1Collection.py +47 -132
- RadGEEToolbox/Sentinel2Collection.py +37 -199
- RadGEEToolbox/__init__.py +13 -1
- {radgeetoolbox-1.6.1.dist-info → radgeetoolbox-1.6.3.dist-info}/METADATA +103 -12
- radgeetoolbox-1.6.3.dist-info/RECORD +12 -0
- {radgeetoolbox-1.6.1.dist-info → radgeetoolbox-1.6.3.dist-info}/WHEEL +1 -1
- radgeetoolbox-1.6.1.dist-info/RECORD +0 -12
- {radgeetoolbox-1.6.1.dist-info → radgeetoolbox-1.6.3.dist-info}/licenses/LICENSE.txt +0 -0
- {radgeetoolbox-1.6.1.dist-info → radgeetoolbox-1.6.3.dist-info}/top_level.txt +0 -0
|
@@ -3,221 +3,50 @@ import pandas as pd
|
|
|
3
3
|
import numpy as np
|
|
4
4
|
class LandsatCollection:
|
|
5
5
|
"""
|
|
6
|
-
|
|
6
|
+
Represents a user-defined collection of NASA/USGS Landsat 5, 8, and 9 TM & OLI surface reflectance satellite images at 30 m/px from Google Earth Engine (GEE).
|
|
7
7
|
|
|
8
|
-
This class
|
|
8
|
+
This class enables simplified definition, filtering, masking, and processing of multispectral Landsat imagery.
|
|
9
|
+
It supports multiple spatial and temporal filters, caching for efficient computation, and direct computation of
|
|
10
|
+
key spectral indices like NDWI, NDVI, halite index, and more. It also includes utilities for cloud masking,
|
|
11
|
+
mosaicking, zonal statistics, and transect analysis.
|
|
9
12
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
Arguments:
|
|
13
|
-
start_date (str): Start date string in format of yyyy-mm-dd for filtering collection (required unless collection is provided)
|
|
14
|
-
|
|
15
|
-
end_date (str): End date string in format of yyyy-mm-dd for filtering collection (required unless collection is provided)
|
|
16
|
-
|
|
17
|
-
tile_row (int or list): WRS-2 tile row of Landsat image (required unless boundary or collection is provided) - see https://www.usgs.gov/landsat-missions/landsat-shapefiles-and-kml-files
|
|
13
|
+
Initialization can be done by providing filtering parameters or directly passing in a pre-filtered GEE collection.
|
|
18
14
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
cloud_percentage_threshold (int): Integer percentage threshold where only imagery with cloud % less than threshold will be provided (defaults to 100)
|
|
15
|
+
Inspect the documentation or source code for details on the methods and properties available.
|
|
22
16
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
Args:
|
|
18
|
+
start_date (str): Start date in 'YYYY-MM-DD' format. Required unless `collection` is provided.
|
|
19
|
+
end_date (str): End date in 'YYYY-MM-DD' format. Required unless `collection` is provided.
|
|
20
|
+
tile_row (int or list of int): WRS-2 tile row(s) to filter by. Ignored if `boundary` or `collection` is provided. See https://www.usgs.gov/landsat-missions/landsat-shapefiles-and-kml-files
|
|
21
|
+
tile_path (int or list of int): WRS-2 tile row(s) to filter by. Ignored if `boundary` or `collection` is provided. See https://www.usgs.gov/landsat-missions/landsat-shapefiles-and-kml-files
|
|
22
|
+
cloud_percentage_threshold (int, optional): Max allowed cloud cover percentage. Defaults to 100.
|
|
23
|
+
boundary (ee.Geometry, optional): A geometry for filtering to images that intersect with the boundary shape. Overrides `tile_path` and `tile_row` if provided.
|
|
24
|
+
collection (ee.ImageCollection, optional): A pre-filtered Landsat ee.ImageCollection object to be converted to a LandsatCollection object. Overrides all other filters.
|
|
26
25
|
|
|
27
26
|
Attributes:
|
|
28
|
-
collection
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
_geometry_masked_collection: Cache storage for mask_to_polygon method
|
|
53
|
-
|
|
54
|
-
_geometry_masked_out_collection: Cache storage for mask_out_polygon method
|
|
55
|
-
|
|
56
|
-
_median: Cache storage for median property attribute
|
|
57
|
-
|
|
58
|
-
_mean: Cache storage for mean property attribute
|
|
59
|
-
|
|
60
|
-
_max: Cache storage for max property attribute
|
|
61
|
-
|
|
62
|
-
_min: Cache storage for min property attribute
|
|
63
|
-
|
|
64
|
-
_ndwi: Cache storage for ndwi property attribute
|
|
65
|
-
|
|
66
|
-
_ndvi: Cache storage for ndvi property attribute
|
|
67
|
-
|
|
68
|
-
_halite: Cache storage for halite property attribute
|
|
69
|
-
|
|
70
|
-
_gypsum: Cache storage for gypsum property attribute
|
|
71
|
-
|
|
72
|
-
_turbidity: Cache storage for turbidity property attribute
|
|
73
|
-
|
|
74
|
-
_chlorophyll: Cache storage for chlorophyll property attribute
|
|
75
|
-
|
|
76
|
-
_LST: Cache storage for LST property attribute
|
|
77
|
-
|
|
78
|
-
_MosaicByDate: Cache storage for MosaicByDate property attribute
|
|
79
|
-
|
|
80
|
-
Property attributes:
|
|
81
|
-
dates_list (returns: Server-Side List): Unreadable Earth Engine list of image dates (server-side)
|
|
82
|
-
|
|
83
|
-
dates (returns: Client-Side List): Readable pythonic list of image dates (client-side)
|
|
84
|
-
|
|
85
|
-
masked_clouds_collection (returns: LandsatCollection image collection): Returns collection with clouds masked (transparent) for each image
|
|
86
|
-
|
|
87
|
-
masked_water_collection (returns: LandsatCollection image collection): Returns collection with water pixels masked (transparent) for each image
|
|
88
|
-
|
|
89
|
-
masked_to_water_collection (returns: LandsatCollection image collection): Returns collection with pixels masked to water (transparent) for each image (masks land and cloud pixels)
|
|
90
|
-
|
|
91
|
-
max (returns: ee.Image): Returns a temporally reduced max image (calculates max at each pixel)
|
|
92
|
-
|
|
93
|
-
median (returns: ee.Image): Returns a temporally reduced median image (calculates median at each pixel)
|
|
94
|
-
|
|
95
|
-
mean (returns: ee.Image): Returns a temporally reduced mean image (calculates mean at each pixel)
|
|
96
|
-
|
|
97
|
-
min (returns: ee.Image): Returns a temporally reduced min image (calculates min at each pixel)
|
|
98
|
-
|
|
99
|
-
MosaicByDate (returns: LandsatCollection image collection): Mosaics image collection where images with the same date are mosaiced into the same image. Calculates total cloud percentage for subsequent filtering of cloudy mosaics.
|
|
100
|
-
|
|
101
|
-
gypsum (returns: ee.ImageCollection): Returns LandsatCollection image collection of singleband gypsum index rasters
|
|
102
|
-
|
|
103
|
-
halite (returns: ee.ImageCollection): Returns LandsatCollection image collection of singleband halite index rasters
|
|
104
|
-
|
|
105
|
-
LST (returns: ee.ImageCollection): Returns LandsatCollection image collection of singleband land-surface-temperature rasters (Celcius)
|
|
106
|
-
|
|
107
|
-
ndwi (returns: ee.ImageCollection): Returns LandsatCollection image collection of singleband NDWI (water) rasters
|
|
108
|
-
|
|
109
|
-
ndvi (returns: ee.ImageCollection): Returns LandsatCollection image collection of singleband NDVI (vegetation) rasters
|
|
110
|
-
|
|
111
|
-
turbidity (returns: ee.ImageCollection): Returns LandsatCollection image collection of singleband NDTI (turbidity) rasters
|
|
112
|
-
|
|
113
|
-
chlorophyll (returns: ee.ImageCollection): Returns LandsatCollection image collection of singleband KIVU (relative chlorophyll-a) rasters
|
|
114
|
-
|
|
115
|
-
Methods:
|
|
116
|
-
get_filtered_collection(self)
|
|
117
|
-
|
|
118
|
-
get_boundary_filtered_collection(self)
|
|
119
|
-
|
|
120
|
-
ndwi_collection(self, threshold, ng_threshold=None)
|
|
121
|
-
|
|
122
|
-
ndvi_collection(self, threshold, ng_threshold=None)
|
|
123
|
-
|
|
124
|
-
halite_collection(self, threshold, ng_threshold=None)
|
|
125
|
-
|
|
126
|
-
gypsum_collection(self, threshold, ng_threshold=None)
|
|
127
|
-
|
|
128
|
-
turbidity_collection(self, threshold, ng_threshold=None)
|
|
129
|
-
|
|
130
|
-
chlorophyll_collection(self, threshold, ng_threshold=None)
|
|
131
|
-
|
|
132
|
-
masked_water_collection_NDWI(self, threshold)
|
|
133
|
-
|
|
134
|
-
masked_to_water_collection_NDWI(self, threshold)
|
|
135
|
-
|
|
136
|
-
surface_temperature_collection(self)
|
|
137
|
-
|
|
138
|
-
mask_to_polygon(self, polygon)
|
|
139
|
-
|
|
140
|
-
mask_out_polygon(self, polygon)
|
|
141
|
-
|
|
142
|
-
mask_halite(self, threshold, ng_threshold=None)
|
|
143
|
-
|
|
144
|
-
mask_halite_and_gypsum(self, halite_threshold, gypsum_threshold, halite_ng_threshold=None, gypsum_ng_threshold=None)
|
|
145
|
-
|
|
146
|
-
PixelAreaSumCollection(self, band_name, geometry, threshold, scale, maxPixels)
|
|
147
|
-
|
|
148
|
-
image_grab(self, img_selector)
|
|
149
|
-
|
|
150
|
-
custom_image_grab(self, img_col, img_selector)
|
|
151
|
-
|
|
152
|
-
image_pick(self, img_date)
|
|
153
|
-
|
|
154
|
-
CollectionStitch(self, img_col2)
|
|
155
|
-
|
|
156
|
-
transect_iterator(self, lines, line_names, save_folder_path, reducer='mean', n_segments=None, dist_interval=30, to_pandas=True)
|
|
157
|
-
|
|
158
|
-
iterate_zonal_stats(self, coordinates, buffer_size=1, reducer_type='mean', scale=10, tileScale=1, coordinate_names=None, file_path=None, dates=None)
|
|
159
|
-
|
|
160
|
-
Static Methods:
|
|
161
|
-
image_dater(image)
|
|
162
|
-
|
|
163
|
-
landsat5bandrename(img)
|
|
164
|
-
|
|
165
|
-
landsat_ndwi_fn(image, threshold, ng_threshold=None)
|
|
166
|
-
|
|
167
|
-
landsat_ndvi_fn(image, threshold, ng_threshold=None)
|
|
168
|
-
|
|
169
|
-
landsat_halite_fn(image, threshold, ng_threshold=None)
|
|
170
|
-
|
|
171
|
-
landsat_gypsum_fn(image, threshold, ng_threshold=None)
|
|
172
|
-
|
|
173
|
-
landsat_ndti_fn(image, threshold, ng_threshold=None)
|
|
174
|
-
|
|
175
|
-
landsat_kivu_chla_fn(image, threshold, ng_threshold=None)
|
|
176
|
-
|
|
177
|
-
MaskWaterLandsat(image)
|
|
178
|
-
|
|
179
|
-
MaskToWaterLandsat(image)
|
|
180
|
-
|
|
181
|
-
MaskWaterLandsatByNDWI(image, threshold, ng_threshold=None)
|
|
182
|
-
|
|
183
|
-
MaskToWaterLandsatByNDWI(image, threshold, ng_threshold=None)
|
|
184
|
-
|
|
185
|
-
halite_mask(image, threshold, ng_threshold=None)
|
|
186
|
-
|
|
187
|
-
gypsum_and_halite_mask(image, halite_threshold, gypsum_threshold, halite_ng_threshold=None, gypsum_ng_threshold=None)
|
|
188
|
-
|
|
189
|
-
maskL8clouds(image)
|
|
190
|
-
|
|
191
|
-
temperature_bands(img)
|
|
192
|
-
|
|
193
|
-
landsat_LST(image)
|
|
194
|
-
|
|
195
|
-
PixelAreaSum(image, band_name, geometry, threshold=-1, scale=30, maxPixels=1e12)
|
|
196
|
-
|
|
197
|
-
dNDWIPixelAreaSum(image, geometry, band_name='ndwi', scale=30, maxPixels=1e12)
|
|
198
|
-
|
|
199
|
-
extract_transect(image, line, reducer="mean", n_segments=100, dist_interval=None, scale=None, crs=None, crsTransform=None, tileScale=1.0, to_pandas=False)
|
|
200
|
-
|
|
201
|
-
transect(image, lines, line_names, reducer='mean', n_segments=None, dist_interval=30, to_pandas=True)
|
|
202
|
-
|
|
203
|
-
extract_zonal_stats_from_buffer(image, coordinates, buffer_size=1, reducer_type='mean', scale=10, tileScale=1, coordinate_names=None)
|
|
204
|
-
|
|
205
|
-
Usage:
|
|
206
|
-
The LandsatCollection object alone acts as a base object for which to further filter or process to indices or spatial reductions
|
|
207
|
-
|
|
208
|
-
To use the LandsatCollection functionality, use any of the built in class attributes or method functions. For example, using class attributes:
|
|
209
|
-
|
|
210
|
-
image_collection = LandsatCollection(start_date, end_date, tile_row, tile_path, cloud_percentage_threshold)
|
|
211
|
-
|
|
212
|
-
ee_image_collection = image_collection.collection #returns ee.ImageCollection from provided argument filters
|
|
213
|
-
|
|
214
|
-
latest_image = image_collection.image_grab(-1) #returns latest image in collection as ee.Image
|
|
215
|
-
|
|
216
|
-
cloud_masked_collection = image_collection.masked_clouds_collection #returns cloud-masked LandsatCollection image collection
|
|
217
|
-
|
|
218
|
-
NDWI_collection = image_collection.ndwi #returns NDWI LandsatCollection image collection
|
|
219
|
-
|
|
220
|
-
latest_NDWI_image = NDWI_collection.image_grab(-1) #Example showing how class functions work with any LandsatCollection image collection object, returning latest ndwi image
|
|
27
|
+
collection (ee.ImageCollection): The filtered or user-supplied image collection converted to an ee.ImageCollection object.
|
|
28
|
+
|
|
29
|
+
Raises:
|
|
30
|
+
ValueError: Raised if required filter parameters are missing, or if both `collection` and other filters are provided.
|
|
31
|
+
|
|
32
|
+
Note:
|
|
33
|
+
See full usage examples in the documentation or notebooks:
|
|
34
|
+
https://github.com/radwinskis/RadGEEToolbox/tree/main/Example%20Notebooks
|
|
35
|
+
|
|
36
|
+
Examples:
|
|
37
|
+
>>> from RadGEEToolbox import LandsatCollection
|
|
38
|
+
>>> import ee
|
|
39
|
+
>>> ee.Initialize()
|
|
40
|
+
>>> image_collection = LandsatCollection(
|
|
41
|
+
... start_date='2023-06-01',
|
|
42
|
+
... end_date='2023-06-30',
|
|
43
|
+
... tile_row=32,
|
|
44
|
+
... tile_path=38,
|
|
45
|
+
... cloud_percentage_threshold=20
|
|
46
|
+
... )
|
|
47
|
+
>>> cloud_masked = image_collection.masked_clouds_collection
|
|
48
|
+
>>> latest_image = cloud_masked.image_grab(-1)
|
|
49
|
+
>>> ndwi_collection = image_collection.ndwi
|
|
221
50
|
"""
|
|
222
51
|
def __init__(self, start_date=None, end_date=None, tile_row=None, tile_path=None, cloud_percentage_threshold=None, boundary=None, collection=None):
|
|
223
52
|
if collection is None and (start_date is None or end_date is None):
|
|
@@ -4,144 +4,59 @@ import pandas as pd
|
|
|
4
4
|
import numpy as np
|
|
5
5
|
class Sentinel1Collection:
|
|
6
6
|
"""
|
|
7
|
-
|
|
7
|
+
Represents a user-defined collection of ESA Sentinel-1 C-band Synthetic Aperture Radar (SAR) GRD data at 10 m/px resolution from Google Earth Engine (GEE). Units of backscatter are in decibels (dB) by default.
|
|
8
8
|
|
|
9
|
-
This class
|
|
9
|
+
This class enables simplified definition, filtering, masking, and processing of Seninel-1 SAR imagery.
|
|
10
|
+
It supports multiple spatial and temporal filters, multilooking and speckle filtering, caching for efficient computation, and direct conversion between log and linear backscatter scales. It also includes utilities for
|
|
11
|
+
mosaicking, zonal statistics, and transect analysis.
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
Arguments:
|
|
14
|
-
start_date (str): Start date string in format of yyyy-mm-dd for filtering collection (required unless collection is provided)
|
|
15
|
-
|
|
16
|
-
end_date (str): End date string in format of yyyy-mm-dd for filtering collection (required unless collection is provided)
|
|
17
|
-
|
|
18
|
-
relative_orbit_start (int or list): Relative orbit start number for filtering collection (required unless collection is provided)
|
|
19
|
-
|
|
20
|
-
relative_orbit_stop (int or list): Relative orbit stop number for filtering collection (required unless collection is provided)
|
|
21
|
-
|
|
22
|
-
instrument_mode (str or list): Instrument mode for filtering collection, with options of IW, EW, or SM (optional - defaults to IW)
|
|
23
|
-
|
|
24
|
-
polarization (str or list): Polarization bands in image for filtering collection. Options: ['VV'], ['HH'], ['VV', 'VH'], or ['HH', 'HV'] (optional; default is ['VV', 'VH'])
|
|
25
|
-
|
|
26
|
-
bands (str or list): Band(s) of interest in each image (optional, must match polarization type; default is ['VV', 'VH'])
|
|
13
|
+
Initialization can be done by providing filtering parameters or directly passing in a pre-filtered GEE collection.
|
|
27
14
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
boundary (ee.Geometry): Boundary for filtering images to images that intersect with the boundary shape (optional)
|
|
15
|
+
Inspect the documentation or source code for details on the methods and properties available.
|
|
31
16
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
17
|
+
Args:
|
|
18
|
+
start_date (str): Start date in 'YYYY-MM-DD' format. Required unless `collection` is provided.
|
|
19
|
+
end_date (str): End date in 'YYYY-MM-DD' format. Required unless `collection` is provided.
|
|
20
|
+
relative_orbit_start (int or list): Relative orbit start number for filtering collection. Required unless `collection` is provided.
|
|
21
|
+
relative_orbit_stop (int or list): Relative orbit stop number for filtering collection. Required unless `collection` is provided.
|
|
22
|
+
instrument_mode (str or list, optional): Instrument mode for filtering collection, with options of 'IW', 'EW', or 'SM'. Defaults to 'IW'
|
|
23
|
+
polarization (str or list, optional): Polarization bands in image for filtering collection. Options: ['VV'], ['HH'], ['VV', 'VH'], or ['HH', 'HV']. Default is ['VV', 'VH'].
|
|
24
|
+
bands (str or list, optional): Desired band(s). Must match polarization type. Default is ['VV', 'VH']
|
|
25
|
+
orbit_direction (str or list): Orbit direction for filtering collection. Options: 'ASCENDING' and/or 'DESCENDING'. Required unless `collection` is provided. For example, ['ASCENDING', 'DESCENDING'] will include both ascending and descending images.
|
|
26
|
+
boundary (ee.Geometry, optional): A geometry for filtering to images that intersect with the boundary shape. Overrides `relative_orbit_start` and `relative_orbit_stop` if provided.
|
|
27
|
+
resolution_meters (int): Resolution in meters for filtering collection. Options of 10, 25, or 40. Required unless collection is provided. NOTE: this is for filtering the GEE collection, not multilooking/reprojecting)
|
|
28
|
+
collection (ee.ImageCollection, optional): A pre-filtered Sentinel-1 ee.ImageCollection object to be converted to a Sentinel1Collection object. Overrides all other filters.
|
|
35
29
|
|
|
36
30
|
Attributes:
|
|
37
|
-
collection
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
Property attributes:
|
|
68
|
-
dates_list (returns: Server-Side List): Unreadable Earth Engine list of image dates (server-side)
|
|
69
|
-
|
|
70
|
-
dates (returns: Client-Side List): Readable pythonic list of image dates (client-side)
|
|
71
|
-
|
|
72
|
-
max (returns: ee.Image): Returns a temporally reduced max image (calculates max at each pixel)
|
|
73
|
-
|
|
74
|
-
median (returns: ee.Image): Returns a temporally reduced median image (calculates median at each pixel)
|
|
75
|
-
|
|
76
|
-
mean (returns: ee.Image): Returns a temporally reduced mean image (calculates mean at each pixel)
|
|
77
|
-
|
|
78
|
-
min (returns: ee.Image): Returns a temporally reduced min image (calculates min at each pixel)
|
|
79
|
-
|
|
80
|
-
MosaicByDate (returns: Sentinel1Collection image collection): Mosaics image collection where images with the same date are mosaiced into the same image. Calculates total cloud percentage for subsequent filtering of cloudy mosaics.
|
|
81
|
-
|
|
82
|
-
Sigma0FromDb (returns: Sentinel1Collection image collection): Converts image collection from decibels to sigma0
|
|
83
|
-
|
|
84
|
-
DbFromSigma0 (returns: Sentinel1Collection image collection): Converts image collection from sigma0 to decibels
|
|
85
|
-
|
|
86
|
-
multilook (returns: Sentinel1Collection image collection): Multilooks image collection by specified number of looks (1, 2, 3, or 4)
|
|
87
|
-
|
|
88
|
-
speckle_filter (returns: Sentinel1Collection image collection): Applies speckle filter to image collection
|
|
89
|
-
|
|
90
|
-
Methods:
|
|
91
|
-
get_filtered_collection(self)
|
|
92
|
-
|
|
93
|
-
get_boundary_filtered_collection(self)
|
|
94
|
-
|
|
95
|
-
mask_to_polygon(self, polygon)
|
|
96
|
-
|
|
97
|
-
mask_out_polygon(self, polygon)
|
|
98
|
-
|
|
99
|
-
PixelAreaSumCollection(self, band_name, geometry, threshold, scale, maxPixels)
|
|
100
|
-
|
|
101
|
-
image_grab(self, img_selector)
|
|
102
|
-
|
|
103
|
-
custom_image_grab(self, img_col, img_selector)
|
|
104
|
-
|
|
105
|
-
image_pick(self, img_date)
|
|
106
|
-
|
|
107
|
-
CollectionStitch(self, img_col2)
|
|
108
|
-
|
|
109
|
-
transect_iterator(self, lines, line_names, save_folder_path, reducer='mean', n_segments=None, dist_interval=30, to_pandas=True)
|
|
110
|
-
|
|
111
|
-
iterate_zonal_stats(self, coordinates, buffer_size=1, reducer_type='mean', scale=40, tileScale=1, coordinate_names=None, file_path=None, dates=None)
|
|
112
|
-
|
|
113
|
-
Static Methods:
|
|
114
|
-
image_dater(image)
|
|
115
|
-
|
|
116
|
-
PixelAreaSum(image, band_name, geometry, threshold=-1, scale=30, maxPixels=1e12)
|
|
117
|
-
|
|
118
|
-
multilook_fn(image, looks)
|
|
119
|
-
|
|
120
|
-
leesigma(image, KERNEL_SIZE, geometry, Tk=7, sigma=0.9, looks=1)
|
|
121
|
-
|
|
122
|
-
extract_transect(image, line, reducer="mean", n_segments=100, dist_interval=None, scale=None, crs=None, crsTransform=None, tileScale=1.0, to_pandas=False)
|
|
123
|
-
|
|
124
|
-
transect(image, lines, line_names, reducer='mean', n_segments=None, dist_interval=30, to_pandas=True)
|
|
125
|
-
|
|
126
|
-
extract_zonal_stats_from_buffer(image, coordinates, buffer_size=1, reducer_type='mean', scale=40, tileScale=1, coordinate_names=None)
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
Usage:
|
|
130
|
-
The Sentinel1Collection object alone acts as a base object for which to further filter or process to indices or spatial reductions
|
|
131
|
-
|
|
132
|
-
To use the Sentinel1Collection functionality, use any of the built in class attributes or method functions. For example, using class attributes:
|
|
133
|
-
|
|
134
|
-
image_collection = Sentinel1Collection(start_date, end_date, tile_row, tile_path, cloud_percentage_threshold)
|
|
135
|
-
|
|
136
|
-
ee_image_collection = image_collection.collection #returns ee.ImageCollection from provided argument filters
|
|
137
|
-
|
|
138
|
-
latest_image = image_collection.image_grab(-1) #returns latest image in collection as ee.Image
|
|
139
|
-
|
|
140
|
-
cloud_masked_collection = image_collection.masked_clouds_collection #returns cloud-masked Sentinel1Collection image collection
|
|
141
|
-
|
|
142
|
-
NDWI_collection = image_collection.ndwi #returns NDWI Sentinel1Collection image collection
|
|
143
|
-
|
|
144
|
-
latest_NDWI_image = NDWI_collection.image_grab(-1) #Example showing how class functions work with any Sentinel1Collection image collection object, returning latest ndwi image
|
|
31
|
+
collection (ee.ImageCollection): The filtered or user-supplied image collection converted to an ee.ImageCollection object.
|
|
32
|
+
|
|
33
|
+
Raises:
|
|
34
|
+
ValueError: Raised if required filter parameters are missing, or if both `collection` and other filters are provided.
|
|
35
|
+
|
|
36
|
+
Note:
|
|
37
|
+
See full usage examples in the documentation or notebooks:
|
|
38
|
+
https://github.com/radwinskis/RadGEEToolbox/tree/main/Example%20Notebooks
|
|
39
|
+
|
|
40
|
+
Examples:
|
|
41
|
+
>>> from RadGEEToolbox import Sentinel1Collection
|
|
42
|
+
>>> import ee
|
|
43
|
+
>>> ee.Initialize()
|
|
44
|
+
>>> counties = ee.FeatureCollection('TIGER/2018/Counties')
|
|
45
|
+
>>> salt_lake_county = counties.filter(ee.Filter.And(
|
|
46
|
+
... ee.Filter.eq('NAME', 'Salt Lake'),
|
|
47
|
+
... ee.Filter.eq('STATEFP', '49')))
|
|
48
|
+
>>> salt_lake_geometry = salt_lake_county.geometry()
|
|
49
|
+
>>> SAR_collection = Sentinel1Collection(
|
|
50
|
+
... start_date='2024-05-01',
|
|
51
|
+
... end_date='2024-05-31',
|
|
52
|
+
... instrument_mode='IW',
|
|
53
|
+
... polarization=['VV', 'VH'],
|
|
54
|
+
... orbit_direction='DESCENDING',
|
|
55
|
+
... boundary=salt_lake_geometry,
|
|
56
|
+
... resolution_meters=10
|
|
57
|
+
... )
|
|
58
|
+
>>> latest_image = SAR_collection.image_grab(-1)
|
|
59
|
+
>>> mean_SAR_backscatter = SAR_collection.mean
|
|
145
60
|
"""
|
|
146
61
|
def __init__(self, start_date=None, end_date=None, relative_orbit_start=None, relative_orbit_stop=None, instrument_mode=None, polarization=None, bands=None, orbit_direction=None, boundary=None, resolution=None, resolution_meters=None, collection=None):
|
|
147
62
|
if collection is None and (start_date is None or end_date is None):
|
|
@@ -3,214 +3,52 @@ import pandas as pd
|
|
|
3
3
|
import numpy as np
|
|
4
4
|
class Sentinel2Collection:
|
|
5
5
|
"""
|
|
6
|
-
|
|
6
|
+
Represents a user-defined collection of ESA Sentinel-2 MSI surface reflectance satellite images at 10 m/px from Google Earth Engine (GEE).
|
|
7
7
|
|
|
8
|
-
This class
|
|
8
|
+
This class enables simplified definition, filtering, masking, and processing of multispectral Sentinel-2 imagery.
|
|
9
|
+
It supports multiple spatial and temporal filters, caching for efficient computation, and direct computation of
|
|
10
|
+
key spectral indices like NDWI, NDVI, halite index, and more. It also includes utilities for cloud masking,
|
|
11
|
+
mosaicking, zonal statistics, and transect analysis.
|
|
9
12
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
Arguments:
|
|
13
|
-
start_date (str): Start date string in format of yyyy-mm-dd for filtering collection (required unless collection is provided)
|
|
14
|
-
|
|
15
|
-
end_date (str): End date string in format of yyyy-mm-dd for filtering collection (required unless collection is provided)
|
|
16
|
-
|
|
17
|
-
tile (str or list): MGRS tile(s) of Sentinel image (required unless boundary, relative_orbit_number, or collection is provided) | user is allowed to provide multiple tiles as list (note tile specifications will override boundary or orbits) - see https://hls.gsfc.nasa.gov/products-description/tiling-system/
|
|
18
|
-
|
|
19
|
-
cloud_percentage_threshold (int): Integer percentage threshold where only imagery with cloud % less than threshold will be provided (defaults to 100)
|
|
13
|
+
Initialization can be done by providing filtering parameters or directly passing in a pre-filtered GEE collection.
|
|
20
14
|
|
|
21
|
-
|
|
15
|
+
Inspect the documentation or source code for details on the methods and properties available.
|
|
22
16
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
17
|
+
Args:
|
|
18
|
+
start_date (str): Start date in 'YYYY-MM-DD' format. Required unless `collection` is provided.
|
|
19
|
+
end_date (str): End date in 'YYYY-MM-DD' format. Required unless `collection` is provided.
|
|
20
|
+
tile (str or list): MGRS tile(s) of Sentinel image. Required unless `boundary`, `relative_orbit_number`, or `collection` is provided. The user is allowed to provide multiple tiles as list (note tile specifications will override boundary or orbits). See https://hls.gsfc.nasa.gov/products-description/tiling-system/
|
|
21
|
+
cloud_percentage_threshold (int, optional): Max allowed cloud cover percentage. Defaults to 100.
|
|
22
|
+
nodata_threshold (int, optional): Integer percentage threshold where only imagery with nodata pixels encompassing a % less than the threshold will be provided (defaults to 100)
|
|
23
|
+
boundary (ee.Geometry, optional): A geometry for filtering to images that intersect with the boundary shape. Overrides `tile` if provided.
|
|
24
|
+
relative_orbit_number (int or list, optional): Relative orbit number(s) to filter collection. Provide multiple values as list
|
|
25
|
+
collection (ee.ImageCollection, optional): A pre-filtered Sentinel-2 ee.ImageCollection object to be converted to a Sentinel2Collection object. Overrides all other filters.
|
|
28
26
|
|
|
29
27
|
Attributes:
|
|
30
|
-
collection (
|
|
31
|
-
|
|
32
|
-
_dates_list: Cache storage for dates_list property attribute
|
|
33
|
-
|
|
34
|
-
_dates: Cahce storgage for dates property attribute
|
|
35
|
-
|
|
36
|
-
ndwi_threshold: Default threshold for masking ndwi imagery
|
|
37
|
-
|
|
38
|
-
ndvi_threshold: Default threshold for masking ndvi imagery
|
|
39
|
-
|
|
40
|
-
halite_threshold: Default threshold for masking halite imagery
|
|
41
|
-
|
|
42
|
-
gypsum_threshold: Default threshold for masking gypsum imagery
|
|
43
|
-
|
|
44
|
-
turbidity_threshold: Default threshold for masking turbidity imagery
|
|
45
|
-
|
|
46
|
-
chlorophyll_threshold: Default threshold for masking chlorophyll imagery
|
|
47
|
-
|
|
48
|
-
_masked_clouds_collection: Cache storage for masked_clouds_collection property attribute
|
|
49
|
-
|
|
50
|
-
_masked_water_collection: Cache storage for masked_water_collection property attribute
|
|
51
|
-
|
|
52
|
-
_masked_to_water_collection: Cache storage for masked_to_water_collection property attribute
|
|
53
|
-
|
|
54
|
-
_geometry_masked_collection: Cache storage for mask_to_polygon method
|
|
55
|
-
|
|
56
|
-
_geometry_masked_out_collection: Cache storage for mask_out_polygon method
|
|
57
|
-
|
|
58
|
-
_median: Cache storage for median property attribute
|
|
59
|
-
|
|
60
|
-
_mean: Cache storage for mean property attribute
|
|
61
|
-
|
|
62
|
-
_max: Cache storage for max property attribute
|
|
28
|
+
collection (ee.ImageCollection): The filtered or user-supplied image collection converted to an ee.ImageCollection object.
|
|
63
29
|
|
|
64
|
-
|
|
30
|
+
Raises:
|
|
31
|
+
ValueError: Raised if required filter parameters are missing, or if both `collection` and other filters are provided.
|
|
65
32
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
_halite: Cache storage for halite property attribute
|
|
71
|
-
|
|
72
|
-
_gypsum: Cache storage for gypsum property attribute
|
|
73
|
-
|
|
74
|
-
_turbidity: Cache storage for turbidity property attribute
|
|
75
|
-
|
|
76
|
-
_chlorophyll: Cache storage for chlorophyll property attribute
|
|
77
|
-
|
|
78
|
-
_MosaicByDate: Cache storage for MosaicByDate property attribute
|
|
79
|
-
|
|
80
|
-
Property Attributes:
|
|
81
|
-
dates_list (returns: Server-Side List): Unreadable Earth Engine list of image dates (server-side)
|
|
82
|
-
|
|
83
|
-
dates (returns: Client-Side List): Readable pythonic list of image dates (client-side)
|
|
84
|
-
|
|
85
|
-
masked_clouds_collection (returns: Sentinel2Collection image collection): Returns collection with clouds masked (transparent) for each image
|
|
86
|
-
|
|
87
|
-
masked_to_water_collection (returns: Sentinel2Collection image collection): Returns collection masked to just water pixels
|
|
88
|
-
|
|
89
|
-
masked_water_collection (returns: Sentinel2Collection image collection): Returns collection with water pixels masked
|
|
90
|
-
|
|
91
|
-
max (returns: ee.Image): Returns a temporally reduced max image (calculates max at each pixel)
|
|
92
|
-
|
|
93
|
-
median (returns: ee.Image): Returns a temporally reduced median image (calculates median at each pixel)
|
|
94
|
-
|
|
95
|
-
mean (returns: ee.Image): Returns a temporally reduced mean image (calculates mean at each pixel)
|
|
96
|
-
|
|
97
|
-
min (returns: ee.Image): Returns a temporally reduced min image (calculates min at each pixel)
|
|
98
|
-
|
|
99
|
-
ndwi (returns: ee.ImageCollection): Returns Sentinel2Collection image collection of singleband NDWI (water) rasters
|
|
100
|
-
|
|
101
|
-
ndvi (returns: ee.ImageCollection): Returns Sentinel2Collection image collection of singleband NDVI (vegetation) rasters
|
|
102
|
-
|
|
103
|
-
halite (returns: ee.ImageCollection): Returns Sentinel2Collection image collection of singleband halite index rasters
|
|
104
|
-
|
|
105
|
-
gypsum (returns: ee.ImageCollection): Returns Sentinel2Collection image collection of singleband gypsum index rasters
|
|
106
|
-
|
|
107
|
-
turbidity (returns: ee.ImageCollection): Returns Sentinel2Collection image collection of singleband NDTI (turbidity) rasters
|
|
108
|
-
|
|
109
|
-
chlorophyll (returns: ee.ImageCollection): Returns Sentinel2Collection image collection of singleband 2BDA (relative chlorophyll-a) rasters
|
|
110
|
-
|
|
111
|
-
MosaicByDate (returns: Sentinel2Collection image collection): Mosaics image collection where images with the same date are mosaiced into the same image. Calculates total cloud percentage for subsequent filtering of cloudy mosaics.
|
|
112
|
-
|
|
113
|
-
Methods:
|
|
114
|
-
ndwi_collection(self, threshold)
|
|
115
|
-
|
|
116
|
-
ndvi_collection(self, threshold)
|
|
33
|
+
Note:
|
|
34
|
+
See full usage examples in the documentation or notebooks:
|
|
35
|
+
https://github.com/radwinskis/RadGEEToolbox/tree/main/Example%20Notebooks
|
|
117
36
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
mask_to_polygon(self, polygon)
|
|
135
|
-
|
|
136
|
-
mask_out_polygon(self, polygon)
|
|
137
|
-
|
|
138
|
-
masked_water_collection_NDWI(self, threshold)
|
|
139
|
-
|
|
140
|
-
masked_to_water_collection_NDWI(self, threshold)
|
|
141
|
-
|
|
142
|
-
mask_halite(self, threshold)
|
|
143
|
-
|
|
144
|
-
mask_halite_and_gypsum(self, halite_threshold, gypsum_threshold)
|
|
145
|
-
|
|
146
|
-
PixelAreaSumCollection(self, band_name, geometry, threshold, scale, maxPixels)
|
|
147
|
-
|
|
148
|
-
image_grab(self, img_selector)
|
|
149
|
-
|
|
150
|
-
custom_image_grab(self, img_col, img_selector)
|
|
151
|
-
|
|
152
|
-
image_pick(self, img_date)
|
|
153
|
-
|
|
154
|
-
CollectionStitch(self, img_col2)
|
|
155
|
-
|
|
156
|
-
transect_iterator(self, lines, line_names, save_folder_path, reducer='mean', n_segments=None, dist_interval=30, to_pandas=True)
|
|
157
|
-
|
|
158
|
-
iterate_zonal_stats(self, coordinates, buffer_size=1, reducer_type='mean', scale=10, tileScale=1, coordinate_names=None, file_path=None, dates=None)
|
|
159
|
-
|
|
160
|
-
Static Methods:
|
|
161
|
-
image_dater(image)
|
|
162
|
-
|
|
163
|
-
sentinel_ndwi_fn(image, threshold)
|
|
164
|
-
|
|
165
|
-
sentinel_ndvi_fn(image, threshold)
|
|
166
|
-
|
|
167
|
-
sentinel_halite_fn(image, threshold)
|
|
168
|
-
|
|
169
|
-
sentinel_gypsum_fn(image, threshold)
|
|
170
|
-
|
|
171
|
-
sentinel_turbidity_fn(image, threshold)
|
|
172
|
-
|
|
173
|
-
sentinel_chlorophyll_fn(image, threshold)
|
|
174
|
-
|
|
175
|
-
MaskWaterS2(image)
|
|
176
|
-
|
|
177
|
-
MaskToWaterS2(image)
|
|
178
|
-
|
|
179
|
-
MaskWaterS2ByNDWI(image, threshold)
|
|
180
|
-
|
|
181
|
-
MaskToWaterS2ByNDWI(image, threshold)
|
|
182
|
-
|
|
183
|
-
halite_mask(image, threshold)
|
|
184
|
-
|
|
185
|
-
gypsum_and_halite_mask(image, halite_threshold, gypsum_threshold)
|
|
186
|
-
|
|
187
|
-
MaskCloudsS2(image)
|
|
188
|
-
|
|
189
|
-
PixelAreaSum(image, band_name, geometry, threshold=-1, scale=30, maxPixels=1e12)
|
|
190
|
-
|
|
191
|
-
extract_transect(image, line, reducer="mean", n_segments=100, dist_interval=None, scale=None, crs=None, crsTransform=None, tileScale=1.0, to_pandas=False)
|
|
192
|
-
|
|
193
|
-
transect(image, lines, line_names, reducer='mean', n_segments=None, dist_interval=30, to_pandas=True)
|
|
194
|
-
|
|
195
|
-
extract_zonal_stats_from_buffer(image, coordinates, buffer_size=1, reducer_type='mean', scale=10, tileScale=1, coordinate_names=None)
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
Usage:
|
|
199
|
-
The Sentinel2Collection object alone acts as a base object for which to further filter or process to indices or spatial reductions
|
|
200
|
-
|
|
201
|
-
To use the Sentinel2Collection functionality, use any of the built in class attributes or method functions. For example, using class attributes:
|
|
202
|
-
|
|
203
|
-
image_collection = Sentinel2Collection(start_date, end_date, tile, cloud_percentage_threshold)
|
|
204
|
-
|
|
205
|
-
ee_image_collection = image_collection.collection #returns ee.ImageCollection from provided argument filters
|
|
206
|
-
|
|
207
|
-
latest_image = image_collection.image_grab(-1) #returns latest image in collection as ee.Image
|
|
208
|
-
|
|
209
|
-
cloud_masked_collection = image_collection.masked_clouds_collection #returns cloud-masked Sentinel2Collection image collection
|
|
210
|
-
|
|
211
|
-
NDWI_collection = image_collection.ndwi #returns NDWI Sentinel2Collection image collection
|
|
212
|
-
|
|
213
|
-
latest_NDWI_image = NDWI_collection.image_grab(-1) #Example showing how class functions work with any Sentinel2Collection image collection object, returning latest ndwi image
|
|
37
|
+
Examples:
|
|
38
|
+
>>> from RadGEEToolbox import Sentinel2Collection
|
|
39
|
+
>>> import ee
|
|
40
|
+
>>> ee.Initialize()
|
|
41
|
+
>>> image_collection = Sentinel2Collection(
|
|
42
|
+
... start_date='2023-06-01',
|
|
43
|
+
... end_date='2023-06-30',
|
|
44
|
+
... tile=['12TUL', '12TUM', '12TUN'],
|
|
45
|
+
... cloud_percentage_threshold=20,
|
|
46
|
+
... nodata_threshold=10,
|
|
47
|
+
... )
|
|
48
|
+
>>> mosaic_collection = image_collection.MosaicByDate #mosaic images/tiles with same date
|
|
49
|
+
>>> cloud_masked = mosaic_collection.masked_clouds_collection #mask out clouds
|
|
50
|
+
>>> latest_image = cloud_masked.image_grab(-1) #grab latest image for viewing
|
|
51
|
+
>>> ndwi_collection = cloud_masked.ndwi #calculate ndwi for all images
|
|
214
52
|
"""
|
|
215
53
|
|
|
216
54
|
def __init__(self, start_date=None, end_date=None, tile=None, cloud_percentage_threshold=None, nodata_threshold=None, boundary=None, relative_orbit_number=None, collection=None):
|
RadGEEToolbox/__init__.py
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
|
+
__version__ = "1.6.3"
|
|
2
|
+
|
|
1
3
|
from .CollectionStitch import CollectionStitch, MosaicByDate
|
|
2
4
|
from .GetPalette import get_palette
|
|
3
5
|
from .LandsatCollection import LandsatCollection
|
|
4
6
|
from .Sentinel1Collection import Sentinel1Collection
|
|
5
7
|
from .Sentinel2Collection import Sentinel2Collection
|
|
6
|
-
from .VisParams import get_visualization_params
|
|
8
|
+
from .VisParams import get_visualization_params
|
|
9
|
+
|
|
10
|
+
__all__ = [
|
|
11
|
+
"CollectionStitch",
|
|
12
|
+
"MosaicByDate",
|
|
13
|
+
"get_palette",
|
|
14
|
+
"LandsatCollection",
|
|
15
|
+
"Sentinel1Collection",
|
|
16
|
+
"Sentinel2Collection",
|
|
17
|
+
"get_visualization_params"
|
|
18
|
+
]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: RadGEEToolbox
|
|
3
|
-
Version: 1.6.
|
|
3
|
+
Version: 1.6.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
|
|
@@ -31,7 +31,7 @@ Dynamic: requires-python
|
|
|
31
31
|
|
|
32
32
|
# RadGEEToolbox 🛠
|
|
33
33
|
|
|
34
|
-

|
|
35
35
|
|
|
36
36
|
### 🌎 Streamlined Multispectral & SAR Analysis for Google Earth Engine Python API
|
|
37
37
|
|
|
@@ -41,6 +41,69 @@ Dynamic: requires-python
|
|
|
41
41
|
|
|
42
42
|
Designed for both new and advanced users of Google Earth Engine, RadGEEToolbox minimizes repetitive scripting, accelerates common remote sensing workflows, and aims to maximize efficiency within the constraints of the Google Earth Engine API. Whether you’re building a time series of vegetation indices or extracting surface properties along transects, this package helps get results faster.
|
|
43
43
|
|
|
44
|
+
_________
|
|
45
|
+
## Getting Started with Google Earth Engine
|
|
46
|
+
|
|
47
|
+
**RadGEEToolbox requires [access](https://developers.google.com/earth-engine/guides/access) to [Google Earth Engine (GEE)](https://earthengine.google.com/) and proper [authentication](https://developers.google.com/earth-engine/guides/auth) with the Python API.**
|
|
48
|
+
|
|
49
|
+
For more details, see the official [Google Earth Engine Python API Getting Started Guide](https://developers.google.com/earth-engine/guides/quickstart_python) or [Python Installation Guide](https://developers.google.com/earth-engine/guides/python_install).
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
### 1. Sign Up for Earth Engine
|
|
53
|
+
Apply for access here: [https://earthengine.google.com/signup/](https://earthengine.google.com/signup/) using a Google account. Approval typically takes a few days.
|
|
54
|
+
|
|
55
|
+
### 2. Install the Earth Engine Python API
|
|
56
|
+
**The Earth Engine API is installed automatically when you install `RadGEEToolbox`.** However, if you would like to install manually:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
pip install earthengine-api
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### 3. Authenticate & Initialize
|
|
63
|
+
Prior to using the Earth Engine Python client library, you need to authenticate and use the resultant credentials to initialize the Python client. The authentication flows use Cloud Projects to authenticate, and they're used for unpaid (free, noncommercial) use as well as paid use.
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
**Run the following during your first use:**
|
|
67
|
+
```python
|
|
68
|
+
import ee
|
|
69
|
+
ee.Authenticate()
|
|
70
|
+
```
|
|
71
|
+
***NOTE: Your GEE credentials will not permanantly be stored on your PC and you will periodically need to re-run `ee.Authenticate()` when `ee.Initialize()` returns an authentication error.***
|
|
72
|
+
|
|
73
|
+
`ee.Autheticate()` will select the best authentication mode for your environment, and prompt you to confirm access for your scripts. To initialize, you will need to provide a project that you own, or have permissions to use. This project will be used for running all Earth Engine operations:
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
ee.Initialize(project='my-project')
|
|
77
|
+
```
|
|
78
|
+
Replacing 'my-project' with the name of the Google Cloud Project you created on sign-up or any Google Cloud Project that has the GEE API enabled.
|
|
79
|
+
|
|
80
|
+
### 4. Authentication Best Practices
|
|
81
|
+
It is reccomended to use the following authentication procedure once you have completed your initial authentication:
|
|
82
|
+
```python
|
|
83
|
+
import ee
|
|
84
|
+
|
|
85
|
+
try:
|
|
86
|
+
ee.Initialize()
|
|
87
|
+
except Exception as e:
|
|
88
|
+
ee.Authenticate()
|
|
89
|
+
ee.Initialize()
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### 5. Troubleshooting
|
|
93
|
+
`AttributeError: module 'ee' has no attribute 'Initialize'`
|
|
94
|
+
|
|
95
|
+
➤ Ensure that earthengine-api is installed properly.
|
|
96
|
+
|
|
97
|
+
`403 Access Denied`
|
|
98
|
+
|
|
99
|
+
➤ Your GEE account might not be approved, or the API is not enabled for your project.
|
|
100
|
+
|
|
101
|
+
`Initialization fails`
|
|
102
|
+
|
|
103
|
+
➤ Try using `ee.Initialize(project='your-project-id')` explicitly in case you are just calling `ee.Initialize()`
|
|
104
|
+
|
|
105
|
+
See the official [GEE documentation for authentication »](https://developers.google.com/earth-engine/guides/auth)
|
|
106
|
+
|
|
44
107
|
_________
|
|
45
108
|
|
|
46
109
|
## Key Features
|
|
@@ -67,15 +130,15 @@ _____________
|
|
|
67
130
|
|
|
68
131
|
### Installing via pip
|
|
69
132
|
|
|
70
|
-
To install `RadGEEToolbox` version 1.6.
|
|
133
|
+
To install `RadGEEToolbox` version 1.6.3 using pip (NOTE: it is recommended to create a new virtual environment):
|
|
71
134
|
|
|
72
135
|
```bash
|
|
73
|
-
pip install RadGEEToolbox==1.6.
|
|
136
|
+
pip install RadGEEToolbox==1.6.3
|
|
74
137
|
```
|
|
75
138
|
|
|
76
139
|
### Installing via Conda
|
|
77
140
|
|
|
78
|
-
To install `RadGEEToolbox` version 1.6.
|
|
141
|
+
To install `RadGEEToolbox` version 1.6.3 using conda-forge (NOTE: it is recommended to create a new virtual environment):
|
|
79
142
|
|
|
80
143
|
```bash
|
|
81
144
|
conda install conda-forge::radgeetoolbox
|
|
@@ -106,8 +169,32 @@ To verify that `RadGEEToolbox` was installed correctly:
|
|
|
106
169
|
python -c "import RadGEEToolbox; print(RadGEEToolbox.__version__)"
|
|
107
170
|
```
|
|
108
171
|
|
|
109
|
-
You should see `1.6.
|
|
172
|
+
You should see `1.6.3` printed as the version number.
|
|
173
|
+
|
|
174
|
+
### Want to Visualize Data? Install These Too
|
|
175
|
+
|
|
176
|
+
The core functionality of this package is focused on the processing of geospatial and remote sensing data using Google Earth Engine. It does **not** include interactive mapping functionality by default.
|
|
110
177
|
|
|
178
|
+
**If you wish to view GEE data on interactive maps (e.g., following along with the mapping portions of the [example notebooks](https://github.com/radwinskis/RadGEEToolbox/tree/main/Example%20Notebooks)), you will need to install the [optional `geemap` package](https://geemap.org) in the environment that `RadGEEToolbox` is installed:**
|
|
179
|
+
|
|
180
|
+
```python
|
|
181
|
+
pip install geemap
|
|
182
|
+
```
|
|
183
|
+
or
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
conda install conda-forge::geemap
|
|
187
|
+
```
|
|
188
|
+
**If you plan to use `geemap` in a Jupyter Notebook, you will also need to install `ipykernel`:**
|
|
189
|
+
|
|
190
|
+
```python
|
|
191
|
+
pip install ipykernel
|
|
192
|
+
```
|
|
193
|
+
or
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
conda install anaconda::ipykernel
|
|
197
|
+
```
|
|
111
198
|
________
|
|
112
199
|
# Usage Example
|
|
113
200
|
|
|
@@ -122,7 +209,7 @@ from RadGEEToolbox import LandsatCollection
|
|
|
122
209
|
|
|
123
210
|
# 2. Authenticate & Initialize GEE API
|
|
124
211
|
ee.Authenticate()
|
|
125
|
-
ee.Initialize()
|
|
212
|
+
ee.Initialize(project='my-cloud-project-ID) #replace with your Google Cloud project ID
|
|
126
213
|
|
|
127
214
|
# 3. Define study area boundary - in this case Lake Powell, Utah
|
|
128
215
|
study_area = ee.Geometry.Polygon(
|
|
@@ -145,6 +232,9 @@ collection = LandsatCollection(
|
|
|
145
232
|
dates = collection.dates
|
|
146
233
|
print(dates)
|
|
147
234
|
```
|
|
235
|
+
```
|
|
236
|
+
['2020-01-13', '2020-02-14', '2020-05-04', '2020-05-20', '2020-07-07', '2020-08-08', '2020-08-24', '2020-09-25', '2020-10-11', '2020-10-27', '2020-11-28', '2020-12-30', '2021-01-15', '2021-01-31', '2021-04-05', '2021-05-07', '2021-06-08', '2021-07-10', '2021-08-27', '2021-10-30', '2021-11-10', '2021-11-10', '2021-12-01', '2021-12-17', '2022-01-02', '2022-01-10', '2022-01-26', '2022-02-11', '2022-02-19', '2022-02-27', '2022-03-23', '2022-04-08', '2022-05-02', '2022-05-18', '2022-05-26', '2022-06-11', '2022-06-27', '2022-07-13', '2022-08-06', '2022-08-22', '2022-08-30', '2022-09-07', '2022-09-23', '2022-10-01', '2022-10-09', '2022-10-17', '2022-10-25', '2022-11-10', '2023-01-21', '2023-03-18', '2023-04-11', '2023-06-22', '2023-06-30', '2023-07-08', '2023-07-16', '2023-09-18', '2023-09-26', '2023-10-04', '2023-10-20', '2023-11-13', '2023-11-21', '2023-12-07', '2023-12-15', '2023-12-31', '2024-01-16', '2024-03-20', '2024-04-13', '2024-04-21', '2024-05-07', '2024-05-23', '2024-06-08', '2024-06-16', '2024-07-02', '2024-07-10', '2024-07-26', '2024-08-19', '2024-08-27', '2024-09-04', '2024-09-12', '2024-09-20', '2024-09-28', '2024-10-06', '2024-10-22', '2024-10-30', '2024-11-07', '2024-11-15', '2024-12-01']
|
|
237
|
+
```
|
|
148
238
|
### 2. Apply a Cloud Mask and Compute NDWI
|
|
149
239
|
```python
|
|
150
240
|
# 1. Mask clouds
|
|
@@ -156,15 +246,16 @@ water_classification_maps = cloud_masked_collection.ndwi_collection(
|
|
|
156
246
|
threshold=0
|
|
157
247
|
)
|
|
158
248
|
```
|
|
159
|
-

|
|
160
249
|
|
|
161
|
-
Visualization of true color and classified water (in blue) from one of the dates in the collection
|
|
250
|
+

|
|
251
|
+
|
|
252
|
+
***Visualization of true color and classified water (in blue) from one of the dates in the collection. To see the code used to display this image, please view [this Example Notebook](https://github.com/radwinskis/RadGEEToolbox/blob/main/Example%20Notebooks/Complete_ReadMe_Example.ipynb)***
|
|
162
253
|
|
|
163
254
|
### 3. Calculate Water Area Time Series
|
|
164
255
|
```python
|
|
165
256
|
calculate_water_area = cloud_masked_NDWI_collection.PixelAreaSumCollection(
|
|
166
257
|
band_name='ndwi', #specify band to use from collection
|
|
167
|
-
geometry=study_area
|
|
258
|
+
geometry=study_area, #ee.Geometry() of your study area
|
|
168
259
|
threshold=0, #binary classification threshold for unclassified rasters,
|
|
169
260
|
scale=90 #pixel size for zonal statistics
|
|
170
261
|
)
|
|
@@ -172,9 +263,9 @@ water_area_time_series = calculate_water_area.aggregate_array('ndwi').getInfo()
|
|
|
172
263
|
print('List of square meters of water in images:', water_area_time_series)
|
|
173
264
|
```
|
|
174
265
|
|
|
175
|
-

|
|
176
267
|
|
|
177
|
-
|
|
268
|
+
***To see the code used to display this plot, please view [this Example Notebook](https://github.com/radwinskis/RadGEEToolbox/blob/main/Example%20Notebooks/Complete_ReadMe_Example.ipynb)***
|
|
178
269
|
|
|
179
270
|
For details about Sentinel-1 SAR and Sentinel-2 MSI modules, and all other available Landsat or cross-module functions, please refer to the [RadGEEToolbox documentation](https://radgeetoolbox.readthedocs.io/en/latest/). You can also explore [`/Example Notebooks`](https://github.com/radwinskis/RadGEEToolbox/tree/main/Example%20Notebooks) for more usage examples.
|
|
180
271
|
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
RadGEEToolbox/CollectionStitch.py,sha256=ojat9aY-zJm4mK3FukKFTVRjp64x0EuY6O_1hbCXLNg,3759
|
|
2
|
+
RadGEEToolbox/GetPalette.py,sha256=kF28nTw-iPxY4DEBtZSTGsOEGAsezmUPlJH4NVkF3vI,1666
|
|
3
|
+
RadGEEToolbox/LandsatCollection.py,sha256=Tq-hwFPolqZI1rL-ORS5dPcjBa3QGEy2ruhc_Tk4hRI,85995
|
|
4
|
+
RadGEEToolbox/Sentinel1Collection.py,sha256=Z32YszIUC_eswMtravMGrNHCP0RA5LK_qyPHQT6stVk,62040
|
|
5
|
+
RadGEEToolbox/Sentinel2Collection.py,sha256=6jx5sMKKDgkr6okQzDQogUBE6t_aBubViZ1OIuIt5K8,67494
|
|
6
|
+
RadGEEToolbox/VisParams.py,sha256=knGnu0zdxkDC1jqvgybNUKUY5IrJaQGgd-7j4odcRQE,5197
|
|
7
|
+
RadGEEToolbox/__init__.py,sha256=2ZG1sQoQVj7g7xTLQE2sbu0uchpPeto8lsq7CGg7pTM,529
|
|
8
|
+
radgeetoolbox-1.6.3.dist-info/licenses/LICENSE.txt,sha256=5Xj9dwVkawz6d8zhCwJy0SmXvm0U4K_msJnOrkHLO1w,1089
|
|
9
|
+
radgeetoolbox-1.6.3.dist-info/METADATA,sha256=7XOL6h_su7U0ncn45se2dNh9M3q04mouNz1YcrUbxc4,13145
|
|
10
|
+
radgeetoolbox-1.6.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
11
|
+
radgeetoolbox-1.6.3.dist-info/top_level.txt,sha256=W2E520tugQoptDkhctKFbzsheL2l_DyYLKqKXkD9G_E,14
|
|
12
|
+
radgeetoolbox-1.6.3.dist-info/RECORD,,
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
RadGEEToolbox/CollectionStitch.py,sha256=ojat9aY-zJm4mK3FukKFTVRjp64x0EuY6O_1hbCXLNg,3759
|
|
2
|
-
RadGEEToolbox/GetPalette.py,sha256=kF28nTw-iPxY4DEBtZSTGsOEGAsezmUPlJH4NVkF3vI,1666
|
|
3
|
-
RadGEEToolbox/LandsatCollection.py,sha256=9DIBWqS3hsAQeShmYSwnK2znXMyS2HEWbAep9ggMRYU,93496
|
|
4
|
-
RadGEEToolbox/Sentinel1Collection.py,sha256=slLt-ApN3LaIpIcYnedK_82UsTotJB9ycXw6xb6xF6M,65557
|
|
5
|
-
RadGEEToolbox/Sentinel2Collection.py,sha256=iXr1GY-2CEbODFqmWOgG4348xOL0OiQZHv9ZVwW77dI,74042
|
|
6
|
-
RadGEEToolbox/VisParams.py,sha256=knGnu0zdxkDC1jqvgybNUKUY5IrJaQGgd-7j4odcRQE,5197
|
|
7
|
-
RadGEEToolbox/__init__.py,sha256=t0qJcUKAO0EIh0zLDPyjO7zQOjnrSLJUjZ4Q_k1w_Ig,304
|
|
8
|
-
radgeetoolbox-1.6.1.dist-info/licenses/LICENSE.txt,sha256=5Xj9dwVkawz6d8zhCwJy0SmXvm0U4K_msJnOrkHLO1w,1089
|
|
9
|
-
radgeetoolbox-1.6.1.dist-info/METADATA,sha256=rSd86nUQgIq3bZSlRrkAHnAR8HX0sDkshkWj3i6B0kM,7713
|
|
10
|
-
radgeetoolbox-1.6.1.dist-info/WHEEL,sha256=A8Eltl-h0W-qZDVezsLjjslosEH_pdYC2lQ0JcbgCzs,91
|
|
11
|
-
radgeetoolbox-1.6.1.dist-info/top_level.txt,sha256=W2E520tugQoptDkhctKFbzsheL2l_DyYLKqKXkD9G_E,14
|
|
12
|
-
radgeetoolbox-1.6.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|