@google/earthengine 0.1.377 → 0.1.379

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@google/earthengine",
3
- "version": "0.1.377",
3
+ "version": "0.1.379",
4
4
  "description": "JavaScript client for Google Earth Engine API.",
5
5
  "author": "Google LLC",
6
6
  "license": "Apache-2.0",
package/src/apiclient.js CHANGED
@@ -6,7 +6,6 @@ goog.module.declareLegacyNamespace();
6
6
 
7
7
  const GoogConst = goog.require('goog.string.Const');
8
8
  const Throttle = goog.require('goog.async.Throttle');
9
- const TrustedResourceUrl = goog.require('goog.html.TrustedResourceUrl');
10
9
  const Uri = goog.require('goog.Uri');
11
10
  const XhrIo = goog.require('goog.net.XhrIo');
12
11
  const XhrLike = goog.requireType('goog.net.XhrLike');
@@ -21,11 +20,12 @@ const jsloader = goog.require('goog.net.jsloader');
21
20
  const {MakeRequestParams, processParams} = goog.require('eeapiclient.request_params');
22
21
  const {NULL_VALUE, Serializable, SerializableCtor, deserialize, serialize} = goog.require('eeapiclient.domain_object');
23
22
  const {PromiseRequestService} = goog.require('eeapiclient.promise_request_service');
23
+ const {trustedResourceUrl} = goog.require('safevalues');
24
24
 
25
25
  /** @namespace */
26
26
  const apiclient = {};
27
27
 
28
- const API_CLIENT_VERSION = '0.1.377';
28
+ const API_CLIENT_VERSION = '0.1.379';
29
29
 
30
30
  exports.VERSION = apiVersion.VERSION;
31
31
  exports.API_CLIENT_VERSION = API_CLIENT_VERSION;
@@ -1147,8 +1147,9 @@ apiclient.ensureAuthLibLoaded_ = function(callback) {
1147
1147
  delete goog.global[callbackName];
1148
1148
  done();
1149
1149
  };
1150
- jsloader.safeLoad(TrustedResourceUrl.format(
1151
- apiclient.AUTH_LIBRARY_URL_, {'onload': callbackName}));
1150
+ jsloader.safeLoad(
1151
+ trustedResourceUrl`https://apis.google.com/js/client.js?onload=${
1152
+ callbackName}`);
1152
1153
  }
1153
1154
  };
1154
1155
 
package/src/ee.js CHANGED
@@ -378,8 +378,7 @@ ee.promote_ = function(arg, klass) {
378
378
  return new ee.Image(/** @type {Object} */ (arg));
379
379
  case 'Feature':
380
380
  if (arg instanceof ee.Collection) {
381
- // TODO(user): Decide whether we want to leave this in. It can be
382
- // quite dangerous on large collections.
381
+ // This can be quite dangerous on large collections.
383
382
  return ee.ApiFunction._call(
384
383
  'Feature', ee.ApiFunction._call('Collection.geometry', arg));
385
384
  } else {
@@ -1,3 +1,4 @@
1
+ // g3-format-clang
1
2
  import {Serializable, serialize} from './domain_object';
2
3
  import {GeneratedRequestParams} from './generated_types';
3
4
  import {MultipartRequest} from './multipart_request';
@@ -1,3 +1,4 @@
1
+ // g3-format-clang
1
2
  import {GeneratedRequestParams} from './generated_types';
2
3
 
3
4
  export interface ApiClientRequestHook {
@@ -1,4 +1,5 @@
1
1
  /**
2
+ * g3-format-clang
2
3
  * Utility map for ClassMetadata to describe how to create instances of child
3
4
  * properties.
4
5
  */
@@ -1,3 +1,4 @@
1
+ // g3-format-clang
1
2
  import {Serializable, SerializableCtor} from './domain_object';
2
3
  import {MultipartRequest} from './multipart_request';
3
4
 
@@ -1,3 +1,4 @@
1
+ // g3-format-clang
1
2
  import {Serializable, serialize} from './domain_object';
2
3
 
3
4
  export class MultipartRequest {
@@ -1,3 +1,4 @@
1
+ // g3-format-clang
1
2
  import {ApiClient, toMakeRequestParams, toMultipartMakeRequestParams} from './api_client';
2
3
  import {ApiClientHookFactory, getRequestHook} from './api_request_hook';
3
4
  import {Serializable} from './domain_object';
@@ -1,3 +1,4 @@
1
+ // g3-format-clang
1
2
  import {deserialize, Serializable, SerializableCtor} from './domain_object';
2
3
  import {MakeRequestParams, processParams} from './request_params';
3
4
 
@@ -1,3 +1,4 @@
1
+ // g3-format-clang
1
2
  import * as httpCors from 'goog:goog.net.rpc.HttpCors';
2
3
 
3
4
  import {GeneratedQueryParams} from './generated_types';
@@ -1,3 +1,4 @@
1
+ // g3-format-clang
1
2
  import 'jasmine';
2
3
 
3
4
  import {buildQueryParams, bypassCorsPreflight, MakeRequestParams} from './request_params';
@@ -0,0 +1,35 @@
1
+ // This example demonstrates how to use Cloud Score+ QA bands to generate a
2
+ // clear median composite for a specified date range.
3
+
4
+ // Harmonized Sentinel-2 Level 2A collection.
5
+ var s2 = ee.ImageCollection('COPERNICUS/S2_SR_HARMONIZED');
6
+
7
+ // Cloud Score+ image collection. Note Cloud Score+ is produced from Sentinel-2
8
+ // Level 1C data and can be applied to either L1C or L2A collections.
9
+ var csPlus = ee.ImageCollection('GOOGLE/CLOUD_SCORE_PLUS/V1/S2_HARMONIZED');
10
+
11
+ // Region of interest.
12
+ var ROI = ee.Geometry.Point(-119.9087, 37.4159);
13
+
14
+ // Use 'cs' or 'cs_cdf', depending on your use-case; see docs for guidance.
15
+ var QA_BAND = 'cs_cdf';
16
+
17
+ // The threshold for masking; values between 0.50 and 0.65 generally work well.
18
+ // Higher values will remove thin clouds, haze & cirrus shadows.
19
+ var CLEAR_THRESHOLD = 0.60;
20
+
21
+ // Make composite.
22
+ var composite = s2
23
+ .filterBounds(ROI)
24
+ .filterDate('2023-01-01', '2023-02-01')
25
+ .linkCollection(csPlus, [QA_BAND])
26
+ .map(function(img) {
27
+ return img.updateMask(img.select(QA_BAND).gte(CLEAR_THRESHOLD));
28
+ })
29
+ .median();
30
+
31
+ // Sentinel-2 visualization parameters.
32
+ var s2Viz = {bands: ['B4', 'B3', 'B2'], min: 0, max: 2500};
33
+
34
+ Map.addLayer(composite, s2Viz, 'median composite');
35
+ Map.centerObject(ROI, 11);
@@ -1,57 +0,0 @@
1
- // This example demonstrates how to use Cloud Score+ QA bands to
2
- // create a clear Sentinel-2 median composite.
3
- //
4
-
5
-
6
- // Region of interest.
7
- var roi = ee.Geometry.Rectangle([-124.8697, 35.5806, -119.9917, 39.9554]);
8
-
9
- // Harmonized Sentinel-2 Level 2A collection.
10
- var s2 = ee.ImageCollection('COPERNICUS/S2_SR_HARMONIZED');
11
-
12
- // Cloud Score+ image collection. Note Cloud Score+ is produced
13
- // from Sentinel-2 Level 1C data and can be applied to either L1C
14
- // or L2A collections.
15
- var csPlus = ee.ImageCollection('GOOGLE/CLOUD_SCORE_PLUS/V1/S2_HARMONIZED');
16
-
17
- // Get list of Sentinel-2 bands.
18
- var csPlusBands = csPlus.first().bandNames();
19
-
20
- // Link S2 and CS+ results.
21
- var linkedCollection = s2.linkCollection(csPlus, csPlusBands);
22
- // Date range for median composite.
23
- var dateStart = '2023-03-01';
24
- var dateEnd = '2023-09-01';
25
-
26
- /**
27
- * Masks pixels with low CS+ QA scores.
28
- * @param {ee.Image} image Sentinel-2 image
29
- * @return {ee.Image} masked Sentinel-2 image
30
- */
31
- function maskLowQA(image) {
32
- // CS+ QA band to use for masking. Options are 'cs' and 'cs_cdf'.
33
- var qaBand = 'cs';
34
-
35
- // Adjustable threshold for converting CS+ QA to a binary mask.
36
- // Higher thresholds will mask out partial occlusions like thin clouds, haze &
37
- // cirrus shadows. Lower thresholds will be more permissive of these
38
- // occlusions.
39
- var clearThreshold = 0.60;
40
- var mask = image.select(qaBand).gte(clearThreshold);
41
-
42
- return image.updateMask(mask);
43
- }
44
-
45
-
46
- // Filter collection, mask pixels with low QA scores, and
47
- // generate median composite.
48
- var composite = linkedCollection.filterBounds(roi)
49
- .filterDate(dateStart, dateEnd)
50
- .map(maskLowQA)
51
- .median();
52
-
53
- // Sentinel-2 visualization parameters.
54
- var s2Viz = {bands: ['B4', 'B3', 'B2'], min: 0, max: 3000};
55
-
56
- Map.addLayer(composite, s2Viz, 'median composite');
57
- Map.centerObject(roi, 11);