跳至正文
OpenAgentSkill
浏览已开放 · 目录记录日期 2026-11-21 · 自动更新和账户服务暂时关闭。
数据与分析

google-earth-engine

Invoke when Earth Engine, GEE, ee., or geemap is named; when work needs its server-side catalog; or when choosing Earth Engine versus local xarray or desktop processing for a large area or long archive. Covers image collections, masking, compositing, reducers, zonal statistics, time series, classification, quota-aware batching, and exports. This is an execution platform skill; combine it with remote-sensing-analysis or change-detection when those skills own the scientific method.

Muhammed Enes Duran · 已有静态检查记录

安装与使用

运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。

npx skills add muend/geoai-skills --skill google-earth-engine

技能说明


name: google-earth-engine description: >- Invoke when Earth Engine, GEE, ee., or geemap is named; when work needs its server-side catalog; or when choosing Earth Engine versus local xarray or desktop processing for a large area or long archive. Covers image collections, masking, compositing, reducers, zonal statistics, time series, classification, quota-aware batching, and exports. This is an execution platform skill; combine it with remote-sensing-analysis or change-detection when those skills own the scientific method. license: MIT metadata: author: Muhammed Enes Duran

Google Earth Engine

Purpose: use GEE's server-side model correctly. The recurring failure modes are client/server confusion (calling .getInfo() in loops, Python if on server objects), unbounded computation (timeouts from unscaled reductions), and silent default scales (statistics computed at the wrong resolution).

Should this run here at all? — Earth Engine versus local

Answer this before writing any ee. code. The decision turns on six things, and you cannot make it without them, so establish them first — asking alongside a provisional recommendation, never instead of one:

  1. Archive extent and duration — area, and how many years at what revisit. This is what makes server-side worth its constraints; a single scene does not.
  2. Algorithm expressibility — can the work be written as masks, reducers and band math? Anything needing arbitrary per-pixel iteration, a custom solver, or a Python library GEE does not host belongs local.
  3. Data locality and sensitivity — restricted or offline data cannot be uploaded, and that ends the discussion regardless of scale.
  4. Interactive limits versus batch — see Quotas and etiquette. Anything beyond a ~5 minute interactive request has to be designed as a batch export from the start, not retrofitted when getInfo times out.
  5. Export volume — what actually comes back: a few reduced statistics, or full-resolution per-pixel stacks you will store and reprocess locally.
  6. Reproducibility cost — the real price of moving server-side. The catalog version can shift under you and the computation leaves no local trace, so choosing GEE obliges you to ship the provenance record. State this cost when you recommend GEE; a recommendation that omits it is incomplete.

Recommend Earth Engine only when 1 and 2 favour it and 3 permits it. When the answer is genuinely balanced, say so and name the deciding question rather than defaulting to the platform this skill is about. xee and STAC + stackstac / odc-stac are the middle paths worth naming: catalog access with local compute.

Mental model — everything is deferred

ee.Image, ee.ImageCollection, ee.FeatureCollection are server-side descriptions, not data. Nothing computes until an output is requested (getInfo, export, map tile). Consequences:

  • Never use Python if/for on server values — use ee.Algorithms.If sparingly, prefer .map() + filters. A Python loop that calls .getInfo() per element is the #1 GEE performance bug.
  • .getInfo() blocks and transfers; use it for tiny scalars only. Anything sized → Export (to Drive/GCS/Asset).
  • Debug with .aggregate_array(), .first(), .limit(3) probes — not by printing whole collections.

Canonical pipeline (Sentinel-2 cloud-free composite)

import ee
ee.Initialize(project="my-project")

aoi = ee.Geometry.Rectangle([27.0, 38.3, 27.4, 38.6])

def mask_s2(img):
    # Cloud Score+ is the current best practice (threshold ~0.5-0.65)
    cs = img.linkCollection(csplus, ["cs_cdf"]).select("cs_cdf")
    return img.updateMask(cs.gte(0.6))

csplus = ee.ImageCollection("GOOGLE/CLOUD_SCORE_PLUS/V1/S2_HARMONIZED")
s2 = (ee.ImageCollection("COPERNICUS/S2_SR_HARMONIZED")
      .filterBounds(aoi)
      .filterDate("2025-05-01", "2025-09-30")
      .map(mask_s2))
composite = s2.median().clip(aoi)
ndvi = composite.normalizedDifference(["B8", "B4"]).rename("ndvi")

Collection choices: S2_SR_HARMONIZED (post-2022 offset harmonized), LANDSAT/LC08/C02/T1_L2 + friends (apply scale factors: optical *0.0000275 - 0.2), MODIS/061/... for daily/coarse, ERA5-Land for climate. Record collection IDs + date filters in the deliverable.

Reducers and zonal statistics — scale is not optional

stats = ndvi.reduceRegions(
    collection=districts,
    reducer=ee.Reducer.mean().combine(ee.Reducer.stdDev(), sharedInputs=True),
    scale=10,                    # ALWAYS explicit — native resolution
    tileScale=4,                 # raise when "computation timed out"
)
  • scale defaults to the map zoom level in some paths — silently coarse statistics. Always set it to the data's native resolution (or state the deliberate coarsening).
  • bestEffort=True silently degrades scale to fit limits — avoid in analysis; prefer tileScale + exports.
  • Large reductions → Export.table.toDrive, not .getInfo().
  • Weighted vs unweighted reducers differ at polygon edges (.unweighted() for counts of whole pixels); state which you used.

Time series

  • Build per-period composites with a mapped function over ee.List.sequence of dates (monthly/seasonal medians), then reduce — don't export daily stacks you'll aggregate anyway.
  • For per-pixel trends: ee.Reducer.sensSlope() (robust) or linearFit; harmonic regression (.addBands of sin/cos terms) for phenology. Mask by count of valid observations — trends from 4 pixels of 200 possible are noise; report the count band.
  • For break detection at archive scale (LandTrendr/CCDC available in GEE), method selection follows change-detection.

Classification in GEE

ee.Classifier.smileRandomForest covers most cases. Training samples via image.sampleRegions; split train/test spatially (add a grid-cell attribute and filter — random randomColumn

阅读完整来源 ↗