ee.Image.clip
Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Découpe une image selon une géométrie ou une entité.
Les bandes de sortie correspondent exactement aux bandes d'entrée, sauf que les données non couvertes par la géométrie sont masquées. L'image de sortie conserve les métadonnées de l'image d'entrée.
Utilisez clipToCollection pour découper une image selon une FeatureCollection.
Renvoie l'image rognée.
Utilisation | Renvoie |
---|
Image.clip(geometry) | Image |
Argument | Type | Détails |
---|
ceci : image | Image | Instance Image. |
geometry | Feature|Geometry|Object | Géométrie ou entité à laquelle effectuer le clipping. |
Exemples
Éditeur de code (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);
Configuration de Python
Consultez la page
Environnement Python pour en savoir plus sur l'API Python et sur l'utilisation de geemap
pour le développement interactif.
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
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/07/29 (UTC).
[null,null,["Dernière mise à jour le 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```"]]