ee.Geometry.MultiLineString.buffer

返回按指定距离缓冲的输入。如果距离为正值,则几何图形会扩大;如果距离为负值,则几何图形会缩小。

用法返回
MultiLineString.buffer(distance, maxError, proj)几何图形
参数类型详细信息
此:geometry几何图形要缓冲的几何图形。
distance浮点数缓冲的距离,可能为负值。如果未指定投影,则单位为米。否则,单位将采用投影的坐标系。
maxErrorErrorMargin,默认值:null在近似计算缓冲区圆和执行任何必要的重新投影时,可容忍的最大误差量。如果未指定,则默认为距离的 1%。
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]]]);

// Apply the buffer method to the MultiLineString object.
var multiLineStringBuffer = multiLineString.buffer({'distance': 100});

// Print the result to the console.
print('multiLineString.buffer(...) =', multiLineStringBuffer);

// Display relevant geometries on the map.
Map.setCenter(-122.085, 37.422, 15);
Map.addLayer(multiLineString,
             {'color': 'black'},
             'Geometry [black]: multiLineString');
Map.addLayer(multiLineStringBuffer,
             {'color': 'red'},
             'Result [red]: multiLineString.buffer');

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]],
])

# Apply the buffer method to the MultiLineString object.
multilinestring_buffer = multilinestring.buffer(distance=100)

# Print the result.
display('multilinestring.buffer(...) =', multilinestring_buffer)

# 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(
    multilinestring_buffer,
    {'color': 'red'},
    'Result [red]: multilinestring.buffer',
)
m