ee.FeatureCollection.getDownloadURL

获取下载网址。当用户访问该网址时,系统会以多种格式之一下载 FeatureCollection。

返回下载网址;如果指定了回调,则返回 undefined。

用法返回
FeatureCollection.getDownloadURL(format, selectors, filename, callback)对象|字符串
参数类型详细信息
此:featurecollectionFeatureCollectionFeatureCollection 实例。
format字符串,可选下载格式,可以是以下值之一:“csv”“json”“geojson”“kml”“kmz”(“json”输出 GeoJSON)。如果未指定,则默认为“csv”。
selectorsList<String>|String,可选用于选择要下载的属性的要素属性名称。如果未指定,则包含所有媒体资源。
filename字符串,可选要下载的文件的名称;默认情况下,系统会附加扩展名。如果未指定,则默认为“表格”。
callback函数(可选)可选的回调。如果未提供,则会同步进行调用。

示例

代码编辑器 (JavaScript)

// FeatureCollection of power plants in Belgium.
var fc = ee.FeatureCollection('WRI/GPPD/power_plants')
            .filter('country_lg == "Belgium"');

// Get a download URL for the FeatureCollection.
var downloadUrl = fc.getDownloadURL({
  format: 'CSV',
  selectors: ['capacitymw', 'fuel1'],
  filename: 'belgian_power_plants'
});
print('URL for downloading FeatureCollection as CSV', downloadUrl);

Python 设置

如需了解 Python API 和如何使用 geemap 进行交互式开发,请参阅 Python 环境页面。

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"')

# Get a download URL for the FeatureCollection.
download_url = fc.getDownloadURL(**{
  'filetype': 'CSV',
  'selectors': ['capacitymw', 'fuel1'],
  'filename': 'belgian_power_plants',
})
print('URL for downloading FeatureCollection as CSV:', download_url)