إشعار: يجب
إثبات أهلية جميع المشاريع غير التجارية المسجّلة لاستخدام Earth Engine قبل
15 أبريل 2025 من أجل الحفاظ على إمكانية الوصول إلى Earth Engine.
ee.Image.pixelArea
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
أنشئ صورة تكون فيها قيمة كل بكسل هي مساحة هذا البكسل بالمتر المربع. تحتوي الصورة التي تم إرجاعها على نطاق واحد يُسمى "المنطقة".
الاستخدام | المرتجعات |
---|
ee.Image.pixelArea() | صورة |
لا توجد وسيطات.
أمثلة
محرّر الرموز البرمجية (JavaScript)
// Create a pixel area image. Pixel values are square meters based on
// a given CRS and scale (or CRS transform).
var pixelArea = ee.Image.pixelArea();
// The default projection is WGS84 with 1-degree scale.
print('Pixel area default projection', pixelArea.projection());
// When inspecting the output in the Code Editor map, the scale of analysis is
// determined by the zoom level. As you zoom in and out, you'll notice that the
// area of the clicked pixel changes. To set a specific pixel scale when
// performing a computation, provide an argument to the `scale` or
// `crsTransform` parameters whenever a function gives you the option.
Map.addLayer(pixelArea, null, 'Pixel area for inspection', false);
// The "area" band produced by the `pixelArea` function can be useful for
// calculating the area of a certain condition of another image. For example,
// here we use the sum reducer to determine the area above 2250m in the North
// Cascades ecoregion, according to a 30m digital elevation model.
// Import a DEM and subset the "elevation" band.
var elev = ee.Image('NASA/NASADEM_HGT/001').select('elevation');
// Define a high elevation mask where pixels with elevation greater than 2250m
// are set to 1, otherwise 0.
var highElevMask = elev.gt(2250);
// Apply the high elevation mask to the pixel area image.
var highElevArea = pixelArea.updateMask(highElevMask);
// Import an ecoregion feature collection and filter it by ecoregion name.
var ecoregion = ee.FeatureCollection('RESOLVE/ECOREGIONS/2017')
.filter('ECO_NAME == "North Cascades conifer forests"');
// Display the ecoregion and high elevation area.
Map.setCenter(-121.127, 48.389, 7);
Map.addLayer(ecoregion, null, 'North Cascades ecoregion');
Map.addLayer(highElevArea.clip(ecoregion),
{palette: 'yellow'}, 'High elevation area');
// Sum the area of high elevation pixels in the North Cascades ecoregion.
var area = highElevArea.reduceRegion({
reducer: ee.Reducer.sum(),
geometry: ecoregion,
crs: elev.projection(), // DEM coordinate reference system
crsTransform: elev.projection().getInfo().transform, // DEM grid alignment
maxPixels: 1e8
});
// Fetch the summed area property from the resulting dictionary and convert
// square meters to square kilometers.
var squareMeters = area.getNumber('area');
var squareKilometers = squareMeters.divide(1e6);
print('Square meters above 2250m elevation', squareMeters);
print('Square kilometers above 2250m elevation', squareKilometers);
إعداد Python
راجِع صفحة
بيئة Python للحصول على معلومات حول واجهة برمجة التطبيقات Python واستخدام
geemap
للتطوير التفاعلي.
import ee
import geemap.core as geemap
Colab (Python)
# Create a pixel area image. Pixel values are square meters based on
# a given CRS and scale (or CRS transform).
pixel_area = ee.Image.pixelArea()
# The default projection is WGS84 with 1-degree scale.
display('Pixel area default projection', pixel_area.projection())
# When inspecting the output in the Code Editor map, the scale of analysis is
# determined by the zoom level. As you zoom in and out, you'll notice that the
# area of the clicked pixel changes. To set a specific pixel scale when
# performing a computation, provide an argument to the `scale` or
# `crsTransform` parameters whenever a function gives you the option.
m = geemap.Map()
m.add_layer(pixel_area, None, 'Pixel area for inspection', False)
# The "area" band produced by the `pixel_area` function can be useful for
# calculating the area of a certain condition of another image. For example,
# here we use the sum reducer to determine the area above 2250m in the North
# Cascades ecoregion, according to a 30m digital elevation model.
# Import a DEM and subset the "elevation" band.
elev = ee.Image('NASA/NASADEM_HGT/001').select('elevation')
# Define a high elevation mask where pixels with elevation greater than 2250m
# are set to 1, otherwise 0.
high_elev_mask = elev.gt(2250)
# Apply the high elevation mask to the pixel area image.
high_elev_area = pixel_area.updateMask(high_elev_mask)
# Import an ecoregion feature collection and filter it by ecoregion name.
ecoregion = ee.FeatureCollection('RESOLVE/ECOREGIONS/2017').filter(
'ECO_NAME == "North Cascades conifer forests"'
)
# Display the ecoregion and high elevation area.
m.set_center(-121.127, 48.389, 7)
m.add_layer(ecoregion, None, 'North Cascades ecoregion')
m.add_layer(
high_elev_area.clip(ecoregion), {'palette': 'yellow'}, 'High elevation area'
)
display(m)
# Sum the area of high elevation pixels in the North Cascades ecoregion.
area = high_elev_area.reduceRegion(
reducer=ee.Reducer.sum(),
geometry=ecoregion,
crs=elev.projection(), # DEM coordinate reference system
crsTransform=elev.projection().getInfo()['transform'], # DEM grid alignment
maxPixels=1e8,
)
# Fetch the summed area property from the resulting dictionary and convert
# square meters to square kilometers.
square_meters = area.getNumber('area')
square_kilometers = square_meters.divide(1e6)
display('Square meters above 2250m elevation', square_meters)
display('Square kilometers above 2250m elevation', square_kilometers)
إنّ محتوى هذه الصفحة مرخّص بموجب ترخيص Creative Commons Attribution 4.0 ما لم يُنصّ على خلاف ذلك، ونماذج الرموز مرخّصة بموجب ترخيص Apache 2.0. للاطّلاع على التفاصيل، يُرجى مراجعة سياسات موقع Google Developers. إنّ Java هي علامة تجارية مسجَّلة لشركة Oracle و/أو شركائها التابعين.
تاريخ التعديل الأخير: 2025-07-26 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2025-07-26 (حسب التوقيت العالمي المتفَّق عليه)"],[[["\u003cp\u003e\u003ccode\u003eee.Image.pixelArea()\u003c/code\u003e generates an image where each pixel value represents its area in square meters.\u003c/p\u003e\n"],["\u003cp\u003eThe output image has a single band named "area" and can be used to calculate areas based on conditions applied to other images.\u003c/p\u003e\n"],["\u003cp\u003eBy default, the projection is WGS84 with a 1-degree scale; however, custom scales and projections can be used.\u003c/p\u003e\n"],["\u003cp\u003eThis function is useful for calculating the area of specific regions or features that meet defined criteria, such as calculating the total area above a certain elevation within a specific geographic boundary.\u003c/p\u003e\n"]]],[],null,["# ee.Image.pixelArea\n\nGenerate an image in which the value of each pixel is the area of that pixel in square meters. The returned image has a single band called \"area.\"\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|------------------------|---------|\n| `ee.Image.pixelArea()` | Image |\n\n**No arguments.**\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// Create a pixel area image. Pixel values are square meters based on\n// a given CRS and scale (or CRS transform).\nvar pixelArea = ee.Image.pixelArea();\n\n// The default projection is WGS84 with 1-degree scale.\nprint('Pixel area default projection', pixelArea.projection());\n\n// When inspecting the output in the Code Editor map, the scale of analysis is\n// determined by the zoom level. As you zoom in and out, you'll notice that the\n// area of the clicked pixel changes. To set a specific pixel scale when\n// performing a computation, provide an argument to the `scale` or\n// `crsTransform` parameters whenever a function gives you the option.\nMap.addLayer(pixelArea, null, 'Pixel area for inspection', false);\n\n// The \"area\" band produced by the `pixelArea` function can be useful for\n// calculating the area of a certain condition of another image. For example,\n// here we use the sum reducer to determine the area above 2250m in the North\n// Cascades ecoregion, according to a 30m digital elevation model.\n\n// Import a DEM and subset the \"elevation\" band.\nvar elev = ee.Image('NASA/NASADEM_HGT/001').select('elevation');\n\n// Define a high elevation mask where pixels with elevation greater than 2250m\n// are set to 1, otherwise 0.\nvar highElevMask = elev.gt(2250);\n\n// Apply the high elevation mask to the pixel area image.\nvar highElevArea = pixelArea.updateMask(highElevMask);\n\n// Import an ecoregion feature collection and filter it by ecoregion name.\nvar ecoregion = ee.FeatureCollection('RESOLVE/ECOREGIONS/2017')\n .filter('ECO_NAME == \"North Cascades conifer forests\"');\n\n// Display the ecoregion and high elevation area.\nMap.setCenter(-121.127, 48.389, 7);\nMap.addLayer(ecoregion, null, 'North Cascades ecoregion');\nMap.addLayer(highElevArea.clip(ecoregion),\n {palette: 'yellow'}, 'High elevation area');\n\n// Sum the area of high elevation pixels in the North Cascades ecoregion.\nvar area = highElevArea.reduceRegion({\n reducer: ee.Reducer.sum(),\n geometry: ecoregion,\n crs: elev.projection(), // DEM coordinate reference system\n crsTransform: elev.projection().getInfo().transform, // DEM grid alignment\n maxPixels: 1e8\n});\n\n// Fetch the summed area property from the resulting dictionary and convert\n// square meters to square kilometers.\nvar squareMeters = area.getNumber('area');\nvar squareKilometers = squareMeters.divide(1e6);\n\nprint('Square meters above 2250m elevation', squareMeters);\nprint('Square kilometers above 2250m elevation', squareKilometers);\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# Create a pixel area image. Pixel values are square meters based on\n# a given CRS and scale (or CRS transform).\npixel_area = ee.Image.pixelArea()\n\n# The default projection is WGS84 with 1-degree scale.\ndisplay('Pixel area default projection', pixel_area.projection())\n\n# When inspecting the output in the Code Editor map, the scale of analysis is\n# determined by the zoom level. As you zoom in and out, you'll notice that the\n# area of the clicked pixel changes. To set a specific pixel scale when\n# performing a computation, provide an argument to the `scale` or\n# `crsTransform` parameters whenever a function gives you the option.\nm = geemap.Map()\nm.add_layer(pixel_area, None, 'Pixel area for inspection', False)\n\n# The \"area\" band produced by the `pixel_area` function can be useful for\n# calculating the area of a certain condition of another image. For example,\n# here we use the sum reducer to determine the area above 2250m in the North\n# Cascades ecoregion, according to a 30m digital elevation model.\n\n# Import a DEM and subset the \"elevation\" band.\nelev = ee.Image('NASA/NASADEM_HGT/001').select('elevation')\n\n# Define a high elevation mask where pixels with elevation greater than 2250m\n# are set to 1, otherwise 0.\nhigh_elev_mask = elev.gt(2250)\n\n# Apply the high elevation mask to the pixel area image.\nhigh_elev_area = pixel_area.updateMask(high_elev_mask)\n\n# Import an ecoregion feature collection and filter it by ecoregion name.\necoregion = ee.FeatureCollection('RESOLVE/ECOREGIONS/2017').filter(\n 'ECO_NAME == \"North Cascades conifer forests\"'\n)\n\n# Display the ecoregion and high elevation area.\nm.set_center(-121.127, 48.389, 7)\nm.add_layer(ecoregion, None, 'North Cascades ecoregion')\nm.add_layer(\n high_elev_area.clip(ecoregion), {'palette': 'yellow'}, 'High elevation area'\n)\ndisplay(m)\n\n# Sum the area of high elevation pixels in the North Cascades ecoregion.\narea = high_elev_area.reduceRegion(\n reducer=ee.Reducer.sum(),\n geometry=ecoregion,\n crs=elev.projection(), # DEM coordinate reference system\n crsTransform=elev.projection().getInfo()['transform'], # DEM grid alignment\n maxPixels=1e8,\n)\n\n# Fetch the summed area property from the resulting dictionary and convert\n# square meters to square kilometers.\nsquare_meters = area.getNumber('area')\nsquare_kilometers = square_meters.divide(1e6)\n\ndisplay('Square meters above 2250m elevation', square_meters)\ndisplay('Square kilometers above 2250m elevation', square_kilometers)\n```"]]