お知らせ:
2025 年 4 月 15 日より前に Earth Engine の使用を登録したすべての非商用プロジェクトは、Earth Engine へのアクセスを維持するために
非商用目的での利用資格を確認する必要があります。
ee.Image.clip
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
画像を Geometry または Feature にクリップします。
出力バンドは入力バンドと完全に一致しますが、ジオメトリでカバーされていないデータはマスクされます。出力画像は入力画像のメタデータを保持します。
clipToCollection を使用して、画像を FeatureCollection にクリップします。
クリップされた画像を返します。
用途 | 戻り値 |
---|
Image.clip(geometry) | 画像 |
引数 | タイプ | 詳細 |
---|
これ: image | 画像 | Image インスタンス。 |
geometry | Feature|Geometry|Object | クリップするジオメトリまたはフィーチャー。 |
例
コードエディタ(JavaScript)
// A digital elevation model.
var dem = ee.Image('NASA/NASADEM_HGT/001');
var demVis = {bands: 'elevation', min: 0, max: 1500};
// Clip the DEM by a polygon geometry.
var geomPoly = ee.Geometry.BBox(-121.55, 39.01, -120.57, 39.38);
var demClip = dem.clip(geomPoly);
print('Clipped image retains metadata and band names', demClip);
Map.setCenter(-121.12, 38.13, 8);
Map.addLayer(demClip, demVis, 'Polygon clip');
Map.addLayer(geomPoly, {color: 'green'}, 'Polygon geometry', false);
// Clip the DEM by a line geometry.
var geomLine = ee.Geometry.LinearRing(
[[-121.19, 38.10], [-120.53, 38.54], [-120.22, 37.83], [-121.19, 38.10]]);
Map.addLayer(dem.clip(geomLine), demVis, 'Line clip');
Map.addLayer(geomLine, {color: 'orange'}, 'Line geometry', false);
// Images have geometry; clip the dem image by the geometry of an S2 image.
var s2Img = ee.Image('COPERNICUS/S2_SR/20210109T185751_20210109T185931_T10SEG');
var geomS2Img = s2Img.geometry();
Map.addLayer(dem.clip(geomS2Img), demVis, 'Image geometry clip');
Map.addLayer(geomS2Img, {color: 'blue'}, 'Image geometry', false);
// Don't use ee.Image.clip prior to ee.Image.regionReduction, the "geometry"
// parameter handles it more efficiently.
var zonalMax = dem.select('elevation').reduceRegion({
reducer: ee.Reducer.max(),
geometry: geomPoly
});
print('Max elevation (m)', zonalMax.get('elevation'));
// Don't use ee.Image.clip to clip an image by a FeatureCollection, use
// ee.Image.clipToCollection(collection).
var watersheds = ee.FeatureCollection('USGS/WBD/2017/HUC10')
.filterBounds(ee.Geometry.Point(-122.754, 38.606).buffer(2e4));
Map.addLayer(dem.clipToCollection(watersheds), demVis, 'Watersheds clip');
Map.addLayer(watersheds, {color: 'red'}, 'Watersheds', false);
Python の設定
Python API とインタラクティブな開発での geemap
の使用については、
Python 環境のページをご覧ください。
import ee
import geemap.core as geemap
Colab(Python)
# A digital elevation model.
dem = ee.Image('NASA/NASADEM_HGT/001')
dem_vis = {'bands': 'elevation', 'min': 0, 'max': 1500}
# Clip the DEM by a polygon geometry.
geom_poly = ee.Geometry.BBox(-121.55, 39.01, -120.57, 39.38)
dem_clip = dem.clip(geom_poly)
display('Clipped image retains metadata and band names', dem_clip)
m = geemap.Map()
m.set_center(-121.12, 38.13, 8)
m.add_layer(dem_clip, dem_vis, 'Polygon clip')
m.add_layer(geom_poly, {'color': 'green'}, 'Polygon geometry', False)
# Clip the DEM by a line geometry.
geom_line = ee.Geometry.LinearRing(
[[-121.19, 38.10], [-120.53, 38.54], [-120.22, 37.83], [-121.19, 38.10]]
)
m.add_layer(dem.clip(geom_line), dem_vis, 'Line clip')
m.add_layer(geom_line, {'color': 'orange'}, 'Line geometry', False)
# Images have geometry clip the dem image by the geometry of an S2 image.
s_2_img = ee.Image('COPERNICUS/S2_SR/20210109T185751_20210109T185931_T10SEG')
geom_s_2_img = s_2_img.geometry()
m.add_layer(dem.clip(geom_s_2_img), dem_vis, 'Image geometry clip')
m.add_layer(geom_s_2_img, {'color': 'blue'}, 'Image geometry', False)
# Don't use ee.Image.clip prior to ee.Image.regionReduction, the "geometry"
# parameter handles it more efficiently.
zonal_max = dem.select('elevation').reduceRegion(
reducer=ee.Reducer.max(), geometry=geom_poly
)
display('Max elevation (m)', zonal_max.get('elevation'))
# Don't use ee.Image.clip to clip an image by a FeatureCollection, use
# ee.Image.clipToCollection(collection).
watersheds = ee.FeatureCollection('USGS/WBD/2017/HUC10').filterBounds(
ee.Geometry.Point(-122.754, 38.606).buffer(2e4)
)
m.add_layer(dem.clipToCollection(watersheds), dem_vis, 'Watersheds clip')
m.add_layer(watersheds, {'color': 'red'}, 'Watersheds', False)
m
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-07-29 UTC。
[null,null,["最終更新日 2025-07-29 UTC。"],[[["\u003cp\u003e\u003ccode\u003eImage.clip()\u003c/code\u003e masks an image by a Geometry or Feature, retaining the input image's metadata and bands within the clipped area.\u003c/p\u003e\n"],["\u003cp\u003eThe output of \u003ccode\u003eImage.clip()\u003c/code\u003e is an Image with the same bands as the input, but with data outside the clip geometry masked.\u003c/p\u003e\n"],["\u003cp\u003eWhen clipping to a FeatureCollection, use \u003ccode\u003eclipToCollection()\u003c/code\u003e instead of \u003ccode\u003eImage.clip()\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eFor \u003ccode\u003eregionReduction\u003c/code\u003e operations, specifying the geometry directly in the \u003ccode\u003ereduceRegion\u003c/code\u003e call is more efficient than pre-clipping the image.\u003c/p\u003e\n"]]],[],null,["# ee.Image.clip\n\n\u003cbr /\u003e\n\nClips an image to a Geometry or Feature.\n\n\u003cbr /\u003e\n\nThe output bands correspond exactly to the input bands, except data not covered by the geometry is masked. The output image retains the metadata of the input image.\n\nUse clipToCollection to clip an image to a FeatureCollection.\n\nReturns the clipped image.\n\n| Usage | Returns |\n|------------------------|---------|\n| Image.clip`(geometry)` | Image |\n\n| Argument | Type | Details |\n|---------------|---------------------------|-------------------------------------|\n| this: `image` | Image | The Image instance. |\n| `geometry` | Feature\\|Geometry\\|Object | The Geometry or Feature to clip to. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// A digital elevation model.\nvar dem = ee.Image('NASA/NASADEM_HGT/001');\nvar demVis = {bands: 'elevation', min: 0, max: 1500};\n\n// Clip the DEM by a polygon geometry.\nvar geomPoly = ee.Geometry.BBox(-121.55, 39.01, -120.57, 39.38);\nvar demClip = dem.clip(geomPoly);\nprint('Clipped image retains metadata and band names', demClip);\nMap.setCenter(-121.12, 38.13, 8);\nMap.addLayer(demClip, demVis, 'Polygon clip');\nMap.addLayer(geomPoly, {color: 'green'}, 'Polygon geometry', false);\n\n// Clip the DEM by a line geometry.\nvar geomLine = ee.Geometry.LinearRing(\n [[-121.19, 38.10], [-120.53, 38.54], [-120.22, 37.83], [-121.19, 38.10]]);\nMap.addLayer(dem.clip(geomLine), demVis, 'Line clip');\nMap.addLayer(geomLine, {color: 'orange'}, 'Line geometry', false);\n\n// Images have geometry; clip the dem image by the geometry of an S2 image.\nvar s2Img = ee.Image('COPERNICUS/S2_SR/20210109T185751_20210109T185931_T10SEG');\nvar geomS2Img = s2Img.geometry();\nMap.addLayer(dem.clip(geomS2Img), demVis, 'Image geometry clip');\nMap.addLayer(geomS2Img, {color: 'blue'}, 'Image geometry', false);\n\n// Don't use ee.Image.clip prior to ee.Image.regionReduction, the \"geometry\"\n// parameter handles it more efficiently.\nvar zonalMax = dem.select('elevation').reduceRegion({\n reducer: ee.Reducer.max(),\n geometry: geomPoly\n});\nprint('Max elevation (m)', zonalMax.get('elevation'));\n\n// Don't use ee.Image.clip to clip an image by a FeatureCollection, use\n// ee.Image.clipToCollection(collection).\nvar watersheds = ee.FeatureCollection('USGS/WBD/2017/HUC10')\n .filterBounds(ee.Geometry.Point(-122.754, 38.606).buffer(2e4));\nMap.addLayer(dem.clipToCollection(watersheds), demVis, 'Watersheds clip');\nMap.addLayer(watersheds, {color: 'red'}, 'Watersheds', false);\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# A digital elevation model.\ndem = ee.Image('NASA/NASADEM_HGT/001')\ndem_vis = {'bands': 'elevation', 'min': 0, 'max': 1500}\n\n# Clip the DEM by a polygon geometry.\ngeom_poly = ee.Geometry.BBox(-121.55, 39.01, -120.57, 39.38)\ndem_clip = dem.clip(geom_poly)\ndisplay('Clipped image retains metadata and band names', dem_clip)\nm = geemap.Map()\nm.set_center(-121.12, 38.13, 8)\nm.add_layer(dem_clip, dem_vis, 'Polygon clip')\nm.add_layer(geom_poly, {'color': 'green'}, 'Polygon geometry', False)\n\n# Clip the DEM by a line geometry.\ngeom_line = ee.Geometry.LinearRing(\n [[-121.19, 38.10], [-120.53, 38.54], [-120.22, 37.83], [-121.19, 38.10]]\n)\nm.add_layer(dem.clip(geom_line), dem_vis, 'Line clip')\nm.add_layer(geom_line, {'color': 'orange'}, 'Line geometry', False)\n\n# Images have geometry clip the dem image by the geometry of an S2 image.\ns_2_img = ee.Image('COPERNICUS/S2_SR/20210109T185751_20210109T185931_T10SEG')\ngeom_s_2_img = s_2_img.geometry()\nm.add_layer(dem.clip(geom_s_2_img), dem_vis, 'Image geometry clip')\nm.add_layer(geom_s_2_img, {'color': 'blue'}, 'Image geometry', False)\n\n# Don't use ee.Image.clip prior to ee.Image.regionReduction, the \"geometry\"\n# parameter handles it more efficiently.\nzonal_max = dem.select('elevation').reduceRegion(\n reducer=ee.Reducer.max(), geometry=geom_poly\n)\ndisplay('Max elevation (m)', zonal_max.get('elevation'))\n\n# Don't use ee.Image.clip to clip an image by a FeatureCollection, use\n# ee.Image.clipToCollection(collection).\nwatersheds = ee.FeatureCollection('USGS/WBD/2017/HUC10').filterBounds(\n ee.Geometry.Point(-122.754, 38.606).buffer(2e4)\n)\nm.add_layer(dem.clipToCollection(watersheds), dem_vis, 'Watersheds clip')\nm.add_layer(watersheds, {'color': 'red'}, 'Watersheds', False)\nm\n```"]]