请注意,距离也是在多边形的内部测量的。不在几何图形“searchRadius”米范围内的像素将被遮盖。
距离是在球面上计算的,因此存在一个与每个像素和最近几何图形之间的纬度差成正比的小误差。
| 用法 | 返回 |
|---|---|
FeatureCollection.distance(searchRadius, maxError) | 图片 |
| 参数 | 类型 | 详细信息 |
|---|---|---|
此:features | FeatureCollection | 用于获取特征的特征集合,这些特征用于计算像素距离。 |
searchRadius | 浮点数,默认值:100000 | 查找边缘时,每个像素的最大距离(以米为单位)。除非在此距离内有边缘,否则像素将被遮盖。 |
maxError | 浮点数,默认值:100 | 以米为单位的最大重投影误差,仅当输入折线需要重投影时使用。如果提供“0”,则在需要投影时,此操作将失败。 |
示例
代码编辑器 (JavaScript)
// FeatureCollection of power plants in Belgium. var fc = ee.FeatureCollection('WRI/GPPD/power_plants') .filter('country_lg == "Belgium"'); // Generate an image of distance to nearest power plant. var distance = fc.distance({searchRadius: 50000, maxError: 50}); // Display the image and FeatureCollection on the map. Map.setCenter(4.56, 50.78, 7); Map.addLayer(distance, {max: 50000}, 'Distance to power plants'); Map.addLayer(fc, {color: 'red'}, 'Power plants');
import ee import geemap.core as geemap
Colab (Python)
# FeatureCollection of power plants in Belgium. fc = ee.FeatureCollection('WRI/GPPD/power_plants').filter( 'country_lg == "Belgium"' ) # Generate an image of distance to nearest power plant. distance = fc.distance(searchRadius=50000, maxError=50) # Display the image and FeatureCollection on the map. m = geemap.Map() m.set_center(4.56, 50.78, 7) m.add_layer(distance, {'max': 50000}, 'Distance to power plants') m.add_layer(fc, {'color': 'red'}, 'Power plants') m