RadGEEToolbox 1.6.4__py3-none-any.whl → 1.6.5__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.
@@ -1,7 +1,9 @@
1
1
  import ee
2
+
3
+
2
4
  def CollectionStitch(img_col1, img_col2, copy_properties_from=1):
3
5
  """
4
- Function to mosaic two RadGEETools image collection objects which share image dates.
6
+ Function to mosaic two RadGEETools image collection objects which share image dates.
5
7
  Mosaics are only formed for dates where both image collections have images. Server-side friendly.
6
8
  Returned image collection is an eeImageCollection object. NOTE this is different from the CollectionStitch function available in the LandsatCollection and SentinelCollection classes.
7
9
 
@@ -23,17 +25,24 @@ def CollectionStitch(img_col1, img_col2, copy_properties_from=1):
23
25
  filtered_col2 = img_col2.image_grab(img_col2.dates_list.index(date))
24
26
  merged_col = ee.ImageCollection.fromImages([filtered_col1, filtered_col2])
25
27
  if copy_properties_from == 1:
26
- mosaic = merged_col.mosaic().copyProperties(filtered_col1) # new collection images contain all image properties of the northern landsat image
28
+ mosaic = merged_col.mosaic().copyProperties(
29
+ filtered_col1
30
+ ) # new collection images contain all image properties of the northern landsat image
27
31
  elif copy_properties_from == 2:
28
- mosaic = merged_col.mosaic().copyProperties(filtered_col2) # new collection images contain all image properties of the southern landsat image
32
+ mosaic = merged_col.mosaic().copyProperties(
33
+ filtered_col2
34
+ ) # new collection images contain all image properties of the southern landsat image
29
35
  else:
30
- raise ValueError("Invalid value for 'copy_properties_from'. Must be 1 or 2.") # new collection images contain all image properties of the northern landsat image
36
+ raise ValueError(
37
+ "Invalid value for 'copy_properties_from'. Must be 1 or 2."
38
+ ) # new collection images contain all image properties of the northern landsat image
31
39
  image_list.append(mosaic)
32
40
  else:
33
41
  None # If the condition isn't met, do nothing and keep going through the list
34
42
  new_col = ee.ImageCollection.fromImages(image_list)
35
43
  return new_col
36
44
 
45
+
37
46
  def MosaicByDate(img_col):
38
47
  """
39
48
  Function to mosaic collection images that share the same date. Server-side friendly. Requires images to have date property of "Date_Filter"
@@ -45,20 +54,21 @@ def MosaicByDate(img_col):
45
54
  ee.ImageCollection: ee.ImageCollection with mosaiced imagery
46
55
  """
47
56
  input_collection = img_col
48
- # Function to mosaic images of the same date and accumulate them
57
+
58
+ # Function to mosaic images of the same date and accumulate them
49
59
  def mosaic_and_accumulate(date, list_accumulator):
50
60
  # date = ee.Date(date)
51
61
  list_accumulator = ee.List(list_accumulator)
52
- date_filter = ee.Filter.eq('Date_Filter', date)
62
+ date_filter = ee.Filter.eq("Date_Filter", date)
53
63
  date_collection = input_collection.filter(date_filter)
54
-
64
+
55
65
  # Create mosaic
56
- mosaic = date_collection.mosaic().set('Date_Filter', date)
66
+ mosaic = date_collection.mosaic().set("Date_Filter", date)
57
67
 
58
68
  return list_accumulator.add(mosaic)
59
69
 
60
70
  # Get distinct dates
61
- distinct_dates = input_collection.aggregate_array('Date_Filter').distinct()
71
+ distinct_dates = input_collection.aggregate_array("Date_Filter").distinct()
62
72
 
63
73
  # Initialize an empty list as the accumulator
64
74
  initial = ee.List([])
@@ -69,4 +79,4 @@ def MosaicByDate(img_col):
69
79
  new_col = ee.ImageCollection.fromImages(mosaic_list)
70
80
 
71
81
  # Convert the list of mosaics to an ImageCollection
72
- return new_col
82
+ return new_col
@@ -4,23 +4,117 @@ def get_palette(name):
4
4
 
5
5
  Args:
6
6
  name (str): options are 'algae', 'dense', 'greens', 'haline', 'inferno', 'jet', 'matter', 'pubu', 'soft_blue_green_red', 'thermal', 'turbid', 'ylord'
7
-
7
+
8
8
  Returns:
9
9
  list: list of colors to be used for image visualization in GEE vis params
10
-
10
+
11
11
  """
12
12
  palettes = {
13
- 'jet': ['#00007F', '#002AFF', '#00D4FF', '#7FFF7F', '#FFD400', '#FF2A00', '#7F0000'],
14
- 'soft_blue_green_red': ['#deeaee', '#b1cbbb', '#eea29a', '#c94c4c'],
15
- 'inferno': ['#000004', '#320A5A', '#781B6C', '#BB3654', '#EC6824', '#FBB41A', '#FCFFA4'],
16
- 'thermal': ['#042333', '#2c3395', '#744992', '#b15f82', '#eb7958', '#fbb43d', '#e8fa5b'],
17
- 'algae': ['#d7f9d0', '#a2d595', '#64b463', '#129450', '#126e45', '#1a482f', '#122414'],
18
- 'turbid': ['#e9f6ab', '#d3c671', '#bf9747', '#a1703b', '#795338', '#4d392d', '#221f1b'],
19
- 'dense': ['#e6f1f1', '#a2cee2', '#76a4e5', '#7871d5', '#7642a5', '#621d62', '#360e24'],
20
- 'matter': ['#feedb0', '#f7b37c', '#eb7858', '#ce4356', '#9f2462', '#66185c', '#2f0f3e'],
21
- 'haline': ['#2a186c', '14439c', '#206e8b', '#3c9387', '#5ab978', '#aad85c', '#fdef9a'],
22
- 'ylord': ['#ffffcc', '#ffeda0', '#fed976', '#feb24c', '#fd8d3c', '#fc4e2a', '#e31a1c', '#bd0026', '#800026'],
23
- 'pubu': ['#fff7fb', '#ece7f2', '#d0d1e6', '#a6bddb', '#74a9cf', '#3690c0', '#0570b0', '#045a8d', '#023858'][::-1],
24
- 'greens': ['#f7fcf5', '#e5f5e0', '#c7e9c0', '#a1d99b', '#74c476', '#41ab5d', '#238b45', '#006d2c', '#00441b']
13
+ "jet": [
14
+ "#00007F",
15
+ "#002AFF",
16
+ "#00D4FF",
17
+ "#7FFF7F",
18
+ "#FFD400",
19
+ "#FF2A00",
20
+ "#7F0000",
21
+ ],
22
+ "soft_blue_green_red": ["#deeaee", "#b1cbbb", "#eea29a", "#c94c4c"],
23
+ "inferno": [
24
+ "#000004",
25
+ "#320A5A",
26
+ "#781B6C",
27
+ "#BB3654",
28
+ "#EC6824",
29
+ "#FBB41A",
30
+ "#FCFFA4",
31
+ ],
32
+ "thermal": [
33
+ "#042333",
34
+ "#2c3395",
35
+ "#744992",
36
+ "#b15f82",
37
+ "#eb7958",
38
+ "#fbb43d",
39
+ "#e8fa5b",
40
+ ],
41
+ "algae": [
42
+ "#d7f9d0",
43
+ "#a2d595",
44
+ "#64b463",
45
+ "#129450",
46
+ "#126e45",
47
+ "#1a482f",
48
+ "#122414",
49
+ ],
50
+ "turbid": [
51
+ "#e9f6ab",
52
+ "#d3c671",
53
+ "#bf9747",
54
+ "#a1703b",
55
+ "#795338",
56
+ "#4d392d",
57
+ "#221f1b",
58
+ ],
59
+ "dense": [
60
+ "#e6f1f1",
61
+ "#a2cee2",
62
+ "#76a4e5",
63
+ "#7871d5",
64
+ "#7642a5",
65
+ "#621d62",
66
+ "#360e24",
67
+ ],
68
+ "matter": [
69
+ "#feedb0",
70
+ "#f7b37c",
71
+ "#eb7858",
72
+ "#ce4356",
73
+ "#9f2462",
74
+ "#66185c",
75
+ "#2f0f3e",
76
+ ],
77
+ "haline": [
78
+ "#2a186c",
79
+ "14439c",
80
+ "#206e8b",
81
+ "#3c9387",
82
+ "#5ab978",
83
+ "#aad85c",
84
+ "#fdef9a",
85
+ ],
86
+ "ylord": [
87
+ "#ffffcc",
88
+ "#ffeda0",
89
+ "#fed976",
90
+ "#feb24c",
91
+ "#fd8d3c",
92
+ "#fc4e2a",
93
+ "#e31a1c",
94
+ "#bd0026",
95
+ "#800026",
96
+ ],
97
+ "pubu": [
98
+ "#fff7fb",
99
+ "#ece7f2",
100
+ "#d0d1e6",
101
+ "#a6bddb",
102
+ "#74a9cf",
103
+ "#3690c0",
104
+ "#0570b0",
105
+ "#045a8d",
106
+ "#023858",
107
+ ][::-1],
108
+ "greens": [
109
+ "#f7fcf5",
110
+ "#e5f5e0",
111
+ "#c7e9c0",
112
+ "#a1d99b",
113
+ "#74c476",
114
+ "#41ab5d",
115
+ "#238b45",
116
+ "#006d2c",
117
+ "#00441b",
118
+ ],
25
119
  }
26
- return palettes.get(name, None)
120
+ return palettes.get(name, None)