公告:所有在
2025 年 4 月 15 日之前注册使用 Earth Engine 的非商业项目都必须
验证是否符合非商业性质的资格条件,才能继续使用 Earth Engine。
ee.Image.changeProj
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
调整输入图片的投影,将每个像素从其在 srcProj 中的位置移动到 dstProj 中的相同坐标。
用法 | 返回 |
---|
Image.changeProj(srcProj, dstProj) | 图片 |
参数 | 类型 | 详细信息 |
---|
此:input | 图片 | |
srcProj | 投影 | 原始投影。 |
dstProj | 投影 | 新投影。 |
示例
代码编辑器 (JavaScript)
// A DEM image object.
var img = ee.Image('MERIT/DEM/v1_0_3');
// Construct a projection object from a WKT string or EPSG code, for example,
// the Robinson projection (https://epsg.io/54030).
var proj = ee.Projection(
'PROJCS["World_Robinson",' +
'GEOGCS["GCS_WGS_1984",' +
'DATUM["WGS_1984",' +
'SPHEROID["WGS_1984",6378137,298.257223563]],' +
'PRIMEM["Greenwich",0],' +
'UNIT["Degree",0.017453292519943295]],' +
'PROJECTION["Robinson"],' +
'UNIT["Meter",1]]'
)
// Optionally adjust projection scale; stretch layer larger in this case.
.scale(0.9, 0.9);
// "Paint" the image in the desired projection onto the projection of
// the map canvas ('EPSG:3857').
var imgProj = img.changeProj(proj, 'EPSG:3857');
// Add an overlay image to the map to cover the default base layers.
Map.setCenter(0, 0, 2);
Map.addLayer(ee.Image(1), {palette: 'grey'}, 'Grey background', false);
// Add the projection-tweaked image to the map.
Map.addLayer(imgProj, {min: 0, max: 3000}, 'DEM in Robinson projection');
Python 设置
如需了解 Python API 和如何使用 geemap
进行交互式开发,请参阅
Python 环境页面。
import ee
import geemap.core as geemap
Colab (Python)
# A DEM image object.
img = ee.Image('MERIT/DEM/v1_0_3')
# Construct a projection object from a WKT string or EPSG code, for example,
# the Robinson projection (https://epsg.io/54030).
proj = (
ee.Projection(
'PROJCS["World_Robinson",'
+ 'GEOGCS["GCS_WGS_1984",'
+ 'DATUM["WGS_1984",'
+ 'SPHEROID["WGS_1984",6378137,298.257223563]],'
+ 'PRIMEM["Greenwich",0],'
+ 'UNIT["Degree",0.017453292519943295]],'
+ 'PROJECTION["Robinson"],'
+ 'UNIT["Meter",1]]'
)
# Optionally adjust projection scale stretch layer larger in this case.
.scale(0.9, 0.9)
)
# "Paint" the image in the desired projection onto the projection of
# the map canvas ('EPSG:3857').
img_proj = img.changeProj(proj, 'EPSG:3857')
# Add an overlay image to the map to cover the default base layers.
m = geemap.Map()
m.set_center(0, 0, 2)
m.add_layer(ee.Image(1), {'palette': 'grey'}, 'Grey background', False)
# Add the projection-tweaked image to the map.
m.add_layer(
img_proj,
{'min': 0, 'max': 3000},
'DEM in Robinson projection',
)
m
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003e\u003ccode\u003eImage.changeProj()\u003c/code\u003e modifies the projection of an image by moving pixels to match coordinates in a new projection.\u003c/p\u003e\n"],["\u003cp\u003eIt takes the original projection (\u003ccode\u003esrcProj\u003c/code\u003e) and the target projection (\u003ccode\u003edstProj\u003c/code\u003e) as inputs.\u003c/p\u003e\n"],["\u003cp\u003eYou can define projections using WKT strings or EPSG codes.\u003c/p\u003e\n"],["\u003cp\u003eThe function returns a new Image object with the altered projection.\u003c/p\u003e\n"],["\u003cp\u003eThis is useful for visualizing or processing data in different coordinate systems.\u003c/p\u003e\n"]]],["The `changeProj` function modifies an image's projection by relocating each pixel from its original projection (`srcProj`) to a new projection (`dstProj`). This is done by taking an image object as input and takes in two parameters `srcProj` and `dstProj`. For example, it takes a DEM image, defines a Robinson projection with an adjusted scale, and then applies `changeProj` to re-project the image onto the map canvas projection (`EPSG:3857`). The result is an image with the modified projection.\n"],null,["# ee.Image.changeProj\n\nTweaks the projection of the input image, moving each pixel from its location in srcProj to the same coordinates in dstProj.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|--------------------------------------|---------|\n| Image.changeProj`(srcProj, dstProj)` | Image |\n\n| Argument | Type | Details |\n|---------------|------------|--------------------------|\n| this: `input` | Image | |\n| `srcProj` | Projection | The original projection. |\n| `dstProj` | Projection | The new projection. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// A DEM image object.\nvar img = ee.Image('MERIT/DEM/v1_0_3');\n\n// Construct a projection object from a WKT string or EPSG code, for example,\n// the Robinson projection (https://epsg.io/54030).\nvar proj = ee.Projection(\n 'PROJCS[\"World_Robinson\",' +\n 'GEOGCS[\"GCS_WGS_1984\",' +\n 'DATUM[\"WGS_1984\",' +\n 'SPHEROID[\"WGS_1984\",6378137,298.257223563]],' +\n 'PRIMEM[\"Greenwich\",0],' +\n 'UNIT[\"Degree\",0.017453292519943295]],' +\n 'PROJECTION[\"Robinson\"],' +\n 'UNIT[\"Meter\",1]]'\n)\n// Optionally adjust projection scale; stretch layer larger in this case.\n.scale(0.9, 0.9);\n\n// \"Paint\" the image in the desired projection onto the projection of\n// the map canvas ('EPSG:3857').\nvar imgProj = img.changeProj(proj, 'EPSG:3857');\n\n// Add an overlay image to the map to cover the default base layers.\nMap.setCenter(0, 0, 2);\nMap.addLayer(ee.Image(1), {palette: 'grey'}, 'Grey background', false);\n\n// Add the projection-tweaked image to the map.\nMap.addLayer(imgProj, {min: 0, max: 3000}, 'DEM in Robinson projection');\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 DEM image object.\nimg = ee.Image('MERIT/DEM/v1_0_3')\n\n# Construct a projection object from a WKT string or EPSG code, for example,\n# the Robinson projection (https://epsg.io/54030).\nproj = (\n ee.Projection(\n 'PROJCS[\"World_Robinson\",'\n + 'GEOGCS[\"GCS_WGS_1984\",'\n + 'DATUM[\"WGS_1984\",'\n + 'SPHEROID[\"WGS_1984\",6378137,298.257223563]],'\n + 'PRIMEM[\"Greenwich\",0],'\n + 'UNIT[\"Degree\",0.017453292519943295]],'\n + 'PROJECTION[\"Robinson\"],'\n + 'UNIT[\"Meter\",1]]'\n )\n # Optionally adjust projection scale stretch layer larger in this case.\n .scale(0.9, 0.9)\n)\n\n# \"Paint\" the image in the desired projection onto the projection of\n# the map canvas ('EPSG:3857').\nimg_proj = img.changeProj(proj, 'EPSG:3857')\n\n# Add an overlay image to the map to cover the default base layers.\nm = geemap.Map()\nm.set_center(0, 0, 2)\nm.add_layer(ee.Image(1), {'palette': 'grey'}, 'Grey background', False)\n\n# Add the projection-tweaked image to the map.\nm.add_layer(\n img_proj,\n {'min': 0, 'max': 3000},\n 'DEM in Robinson projection',\n)\nm\n```"]]