公告 :所有在
2025 年 4 月 15 日 之前注册使用 Earth Engine 的非商业项目都必须
验证是否符合非商业性质的资格条件 ,才能继续使用 Earth Engine。如果您在 2025 年 9 月 26 日之前未完成验证,您的访问权限可能会被暂停。
发送反馈
ee.Geometry.MultiLineString.symmetricDifference
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
返回两个几何图形之间的对称差。
用法 返回 MultiLineString. symmetricDifference (right, maxError , proj )
几何图形
参数 类型 详细信息 此:left
几何图形 用作运算左操作数的几何图形。 right
几何图形 用作相应运算的右操作数的几何图形。 maxError
ErrorMargin,默认值:null 执行任何必要的重新投影时可容忍的最大误差量。 proj
投影,默认值:null 执行操作的投影。如果未指定,则操作将在球面坐标系中执行,并且球面上的直线距离将以米为单位。
示例
代码编辑器 (JavaScript)
// Define a MultiLineString object.
var multiLineString = ee . Geometry . MultiLineString (
[[[ - 122.088 , 37.418 ], [ - 122.086 , 37.422 ], [ - 122.082 , 37.418 ]],
[[ - 122.087 , 37.416 ], [ - 122.083 , 37.416 ], [ - 122.082 , 37.419 ]]]);
// Define other inputs.
var inputGeom = ee . Geometry . BBox ( - 122.085 , 37.415 , - 122.075 , 37.425 );
// Apply the symmetricDifference method to the MultiLineString object.
var multiLineStringSymmetricDifference = multiLineString . symmetricDifference ({ 'right' : inputGeom , 'maxError' : 1 });
// Print the result to the console.
print ( 'multiLineString.symmetricDifference(...) =' , multiLineStringSymmetricDifference );
// Display relevant geometries on the map.
Map . setCenter ( - 122.085 , 37.422 , 15 );
Map . addLayer ( multiLineString ,
{ 'color' : 'black' },
'Geometry [black]: multiLineString' );
Map . addLayer ( inputGeom ,
{ 'color' : 'blue' },
'Parameter [blue]: inputGeom' );
Map . addLayer ( multiLineStringSymmetricDifference ,
{ 'color' : 'red' },
'Result [red]: multiLineString.symmetricDifference' );
Python 设置
如需了解 Python API 和如何使用 geemap
进行交互式开发,请参阅
Python 环境 页面。
import ee
import geemap.core as geemap
Colab (Python)
# Define a MultiLineString object.
multilinestring = ee . Geometry . MultiLineString ([
[[ - 122.088 , 37.418 ], [ - 122.086 , 37.422 ], [ - 122.082 , 37.418 ]],
[[ - 122.087 , 37.416 ], [ - 122.083 , 37.416 ], [ - 122.082 , 37.419 ]],
])
# Define other inputs.
input_geom = ee . Geometry . BBox ( - 122.085 , 37.415 , - 122.075 , 37.425 )
# Apply the symmetricDifference method to the MultiLineString object.
multilinestring_symmetric_difference = multilinestring . symmetricDifference (
right = input_geom , maxError = 1
)
# Print the result.
display (
'multilinestring.symmetricDifference(...) =' ,
multilinestring_symmetric_difference ,
)
# Display relevant geometries on the map.
m = geemap . Map ()
m . set_center ( - 122.085 , 37.422 , 15 )
m . add_layer (
multilinestring , { 'color' : 'black' }, 'Geometry [black]: multilinestring'
)
m . add_layer ( input_geom , { 'color' : 'blue' }, 'Parameter [blue]: input_geom' )
m . add_layer (
multilinestring_symmetric_difference ,
{ 'color' : 'red' },
'Result [red]: multilinestring.symmetricDifference' ,
)
m
发送反馈
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可 获得了许可,并且代码示例已根据 Apache 2.0 许可 获得了许可。有关详情,请参阅 Google 开发者网站政策 。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
需要向我们提供更多信息?
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-07-26。"],[],["The `symmetricDifference` method calculates the symmetric difference between two geometries, a `left` and a `right`. This operation returns a new `Geometry` object. It accepts an optional `maxError` parameter for reprojection tolerance and a `proj` parameter to specify the projection. The method is demonstrated using a `MultiLineString` object and a bounding box geometry. The examples display the original geometries alongside the resulting symmetric difference on a map.\n"]]