공지사항:
2025년 4월 15일 전에 Earth Engine 사용을 위해 등록된 모든 비상업용 프로젝트는 Earth Engine 액세스를 유지하기 위해
비상업용 자격 요건을 인증해야 합니다.
FeatureCollection 필터링
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
FeatureCollection
를 필터링하는 것은 ImageCollection
를 필터링하는 것과 유사합니다. (ImageCollection 필터링 섹션 참고) featureCollection.filterDate()
, featureCollection.filterBounds()
편의 메서드와 관련 ee.Filter
와 함께 사용할 수 있는 featureCollection.filter()
메서드가 있습니다. 예를 들면 다음과 같습니다.
코드 편집기 (JavaScript)
// Load watersheds from a data table.
var sheds = ee.FeatureCollection('USGS/WBD/2017/HUC06')
// Convert 'areasqkm' property from string to number.
.map(function(feature){
var num = ee.Number.parse(feature.get('areasqkm'));
return feature.set('areasqkm', num);
});
// Define a region roughly covering the continental US.
var continentalUS = ee.Geometry.Rectangle(-127.18, 19.39, -62.75, 51.29);
// Filter the table geographically: only watersheds in the continental US.
var filtered = sheds.filterBounds(continentalUS);
// Check the number of watersheds after filtering for location.
print('Count after filter:', filtered.size());
// Filter to get only larger continental US watersheds.
var largeSheds = filtered.filter(ee.Filter.gt('areasqkm', 25000));
// Check the number of watersheds after filtering for size and location.
print('Count after filtering by size:', largeSheds.size());
Python 설정
Python API 및 대화형 개발을 위한 geemap
사용에 관한 자세한 내용은
Python 환경 페이지를 참고하세요.
import ee
import geemap.core as geemap
Colab (Python)
# Load watersheds from a data table.
sheds = (
ee.FeatureCollection('USGS/WBD/2017/HUC06')
# Convert 'areasqkm' property from string to number.
.map(
lambda feature: feature.set(
'areasqkm', ee.Number.parse(feature.get('areasqkm'))
)
)
)
# Define a region roughly covering the continental US.
continental_us = ee.Geometry.Rectangle(-127.18, 19.39, -62.75, 51.29)
# Filter the table geographically: only watersheds in the continental US.
filtered = sheds.filterBounds(continental_us)
# Check the number of watersheds after filtering for location.
display('Count after filter:', filtered.size())
# Filter to get only larger continental US watersheds.
large_sheds = filtered.filter(ee.Filter.gt('areasqkm', 25000))
# Check the number of watersheds after filtering for size and location.
display('Count after filtering by size:', large_sheds.size())
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-07-25(UTC)
[null,null,["최종 업데이트: 2025-07-25(UTC)"],[[["\u003cp\u003eFiltering \u003ccode\u003eFeatureCollection\u003c/code\u003e objects is similar to filtering \u003ccode\u003eImageCollection\u003c/code\u003e objects and can be done using methods like \u003ccode\u003efilterDate()\u003c/code\u003e, \u003ccode\u003efilterBounds()\u003c/code\u003e, and \u003ccode\u003efilter()\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003efilter()\u003c/code\u003e method accepts an \u003ccode\u003eee.Filter\u003c/code\u003e object, allowing for flexible filtering based on various criteria.\u003c/p\u003e\n"],["\u003cp\u003eThe provided examples demonstrate how to filter a dataset of watersheds based on location and size using the \u003ccode\u003efilterBounds()\u003c/code\u003e and \u003ccode\u003efilter()\u003c/code\u003e methods respectively.\u003c/p\u003e\n"],["\u003cp\u003eCode snippets in JavaScript and Python (using \u003ccode\u003egeemap\u003c/code\u003e and Colab) illustrate the implementation of the filtering process.\u003c/p\u003e\n"]]],[],null,["# Filtering a FeatureCollection\n\nFiltering a `FeatureCollection` is analogous to filtering an\n`ImageCollection`. (See the [Filtering an\nImageCollection section](/earth-engine/guides/ic_filtering)). There are the `featureCollection.filterDate()`,\nand `featureCollection.filterBounds()` convenience methods and the\n`featureCollection.filter()` method for use with any applicable\n`ee.Filter`. For example:\n\n### Code Editor (JavaScript)\n\n```javascript\n// Load watersheds from a data table.\nvar sheds = ee.FeatureCollection('USGS/WBD/2017/HUC06')\n // Convert 'areasqkm' property from string to number.\n .map(function(feature){\n var num = ee.Number.parse(feature.get('areasqkm'));\n return feature.set('areasqkm', num);\n });\n\n// Define a region roughly covering the continental US.\nvar continentalUS = ee.Geometry.Rectangle(-127.18, 19.39, -62.75, 51.29);\n\n// Filter the table geographically: only watersheds in the continental US.\nvar filtered = sheds.filterBounds(continentalUS);\n\n// Check the number of watersheds after filtering for location.\nprint('Count after filter:', filtered.size());\n\n// Filter to get only larger continental US watersheds.\nvar largeSheds = filtered.filter(ee.Filter.gt('areasqkm', 25000));\n\n// Check the number of watersheds after filtering for size and location.\nprint('Count after filtering by size:', largeSheds.size());\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 watersheds from a data table.\nsheds = (\n ee.FeatureCollection('USGS/WBD/2017/HUC06')\n # Convert 'areasqkm' property from string to number.\n .map(\n lambda feature: feature.set(\n 'areasqkm', ee.Number.parse(feature.get('areasqkm'))\n )\n )\n)\n\n# Define a region roughly covering the continental US.\ncontinental_us = ee.Geometry.Rectangle(-127.18, 19.39, -62.75, 51.29)\n\n# Filter the table geographically: only watersheds in the continental US.\nfiltered = sheds.filterBounds(continental_us)\n\n# Check the number of watersheds after filtering for location.\ndisplay('Count after filter:', filtered.size())\n\n# Filter to get only larger continental US watersheds.\nlarge_sheds = filtered.filter(ee.Filter.gt('areasqkm', 25000))\n\n# Check the number of watersheds after filtering for size and location.\ndisplay('Count after filtering by size:', large_sheds.size())\n```"]]