[null,null,["最后更新时间 (UTC):2025-07-25。"],[[["\u003cp\u003e\u003ccode\u003efeatureCollection.reduceColumns()\u003c/code\u003e is used to reduce properties of features in a FeatureCollection by applying a reducer to specified selectors.\u003c/p\u003e\n"],["\u003cp\u003eReducers on FeatureCollections must be explicitly repeated using \u003ccode\u003erepeat()\u003c/code\u003e for multiple input properties, unlike ImageCollections where it's automatic for bands.\u003c/p\u003e\n"],["\u003cp\u003eFiltering for non-null values using \u003ccode\u003enotNull()\u003c/code\u003e before reducing is recommended to avoid errors due to missing data in calculations.\u003c/p\u003e\n"],["\u003cp\u003eThe output of \u003ccode\u003ereduceColumns()\u003c/code\u003e is a Dictionary containing the aggregated property values according to the specified reducer.\u003c/p\u003e\n"]]],[],null,["# Statistics of FeatureCollection Columns\n\nTo reduce properties of features in a `FeatureCollection`, use\n`featureCollection.reduceColumns()`. Consider the following toy example:\n\n### Code Editor (JavaScript)\n\n```javascript\n// Make a toy FeatureCollection.\nvar aFeatureCollection = ee.FeatureCollection([\n ee.Feature(null, {foo: 1, weight: 1}),\n ee.Feature(null, {foo: 2, weight: 2}),\n ee.Feature(null, {foo: 3, weight: 3}),\n]);\n\n// Compute a weighted mean and display it.\nprint(aFeatureCollection.reduceColumns({\n reducer: ee.Reducer.mean(),\n selectors: ['foo'],\n weightSelectors: ['weight']\n}));\n```\nPython setup\n\nSee the [Python Environment](/earth-engine/guides/python_install) page for information on the Python API and using\n`geemap` for interactive development. \n\n```python\nimport ee\nimport geemap.core as geemap\n```\n\n### Colab (Python)\n\n```python\n# Make a toy FeatureCollection.\na_feature_collection = ee.FeatureCollection([\n ee.Feature(None, {'foo': 1, 'weight': 1}),\n ee.Feature(None, {'foo': 2, 'weight': 2}),\n ee.Feature(None, {'foo': 3, 'weight': 3}),\n])\n\n# Compute a weighted mean and display it.\ndisplay(\n a_feature_collection.reduceColumns(\n reducer=ee.Reducer.mean(), selectors=['foo'], weightSelectors=['weight']\n )\n)\n```\n\nNote that the inputs are weighted according to the specified `weight`\nproperty. The result is therefore: \n\n```\nmean: 2.333333333333333\n \n```\n\nAs a more complex example, consider a `FeatureCollection` of US census blocks\nwith census data as attributes. The variables of interest are total population and\ntotal housing units. You can get their sum(s) by supplying a summing reducer argument\nto `reduceColumns()` and printing the result:\n\n### Code Editor (JavaScript)\n\n```javascript\n// Load US census data as a FeatureCollection.\nvar census = ee.FeatureCollection('TIGER/2010/Blocks');\n\n// Filter the collection to include only Benton County, OR.\nvar benton = census.filter(\n ee.Filter.and(\n ee.Filter.eq('statefp10', '41'),\n ee.Filter.eq('countyfp10', '003')\n )\n);\n\n// Display Benton County census blocks.\nMap.setCenter(-123.27, 44.57, 13);\nMap.addLayer(benton);\n\n// Compute sums of the specified properties.\nvar properties = ['pop10', 'housing10'];\nvar sums = benton\n .filter(ee.Filter.notNull(properties))\n .reduceColumns({\n reducer: ee.Reducer.sum().repeat(2),\n selectors: properties\n });\n\n// Print the resultant Dictionary.\nprint(sums);\n```\nPython setup\n\nSee the [Python Environment](/earth-engine/guides/python_install) page for information on the Python API and using\n`geemap` for interactive development. \n\n```python\nimport ee\nimport geemap.core as geemap\n```\n\n### Colab (Python)\n\n```python\n# Load US census data as a FeatureCollection.\ncensus = ee.FeatureCollection('TIGER/2010/Blocks')\n\n# Filter the collection to include only Benton County, OR.\nbenton = census.filter(\n ee.Filter.And(\n ee.Filter.eq('statefp10', '41'), ee.Filter.eq('countyfp10', '003')\n )\n)\n\n# Display Benton County census blocks.\nm = geemap.Map()\nm.set_center(-123.27, 44.57, 13)\nm.add_layer(benton)\ndisplay(m)\n\n# Compute sums of the specified properties.\nproperties = ['pop10', 'housing10']\nsums = benton.filter(ee.Filter.notNull(properties)).reduceColumns(\n reducer=ee.Reducer.sum().repeat(2), selectors=properties\n)\n\n# Print the resultant Dictionary.\ndisplay(sums)\n```\n\nThe output is a `Dictionary` representing the aggregated property according\nto the specified reducer: \n\n```\nsum: [85579,36245]\n \n```\n\nNote that the above example uses the `notNull()` filter to include only\nfeatures with non-null entries for selected properties in the collection being reduced.\nIt is good practice to check for null entries to catch unexpected missing data and avoid\nerrors resulting from calculations that include null values.\n\nAlso note that unlike `imageCollection.reduce()`, in which reducers are\nautomatically repeated for each band, reducers on a `FeatureCollection` must be\nexplicitly repeated using `repeat()`. Specifically, repeat the reducer *m*\ntimes for *m* inputs. The following error may be thrown as a result of not repeating\nthe reducer:\n| Dictionary (Error) \n| Collection.reduceColumns: Need 1 inputs for \\\u003cReducer\\\u003e, got 2."]]