前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >GEE 错误:导出到谷歌云盘中出现的错误Error: Image to render must have 1 or 3 bands, but found 30. (Error code: 3)

GEE 错误:导出到谷歌云盘中出现的错误Error: Image to render must have 1 or 3 bands, but found 30. (Error code: 3)

作者头像
此星光明
发布2024-02-02 13:52:30
1170
发布2024-02-02 13:52:30
举报

您要导出的内容 (dataset.mosaic()) 没有应用 visparams。

您需要调用 Visualize() 将其转换为可以在地图瓦片中显示的内容

前言 – 人工智能教程

原始代码:

代码语言:javascript
复制
// Get data
var dataset = ee.ImageCollection('ECMWF/CAMS/NRT')
                  .filterDate('2023-07-22', '2023-07-31')
                  .filter('model_initialization_hour == 0');

// Select first and last forecast hours.
var hour00 = dataset.filter('model_forecast_hour == 0').first();
var hour21 = dataset.filter('model_forecast_hour == 21').first();

// Visualization parameters for specified aerosol band.
var visParams = {
  bands: ['total_column_nitrogen_dioxide_surface'],
  min: 0.0,
  max: 3.6,
  palette: [
    '5e4fa2', '3288bd', '66c2a5', 'abe0a4', 'e6f598', 'ffffbf',
    'fee08b', 'fdae61', 'f46d43', 'd53e4f', '9e0142'
  ]
};


var exportRegion = ee.Geometry.BBox(35.72711080753947, 31.761096539673837,
36.07730001652384, 32.088620980502085);

 
// Display forecasts on the map.
Map.addLayer(hour00, visParams, 'Total Column Nitrogen Dioxide Surface', true, 0.8);
Map.centerObject(exportRegion);


// --- Export Map Tiles for use with Map Preview ---
// Use image setup code from example at top of the page.
// Set up Export task.
Export.map.toCloudStorage({
  image: dataset.mosaic(),
  description: 'mapTilesForMapPreview',
  bucket: 'test-no2',  // replace with your GCS bucket name
  fileFormat: 'auto',
  maxZoom: 13,
  region: exportRegion,
  writePublicTiles: true,
  mapsApiKey: 'XXX'
});

因为这里需要设定一个付费的项目,所以无法进行具体的错误导出展示:

我们首先看一下原始的数据集中的波段信息:

函数:

Export.map.toCloudStorage(image, description, bucket, fileFormat, path, writePublicTiles, maxZoom, scale, minZoom, region, skipEmptyTiles, mapsApiKey, bucketCorsUris) 创建一个批处理任务,将图像导出为矩形金字塔的地图图块,供网络地图查看器使用。地图图块将附带一个参考 index.html 文件,用于使用谷歌地图 API 显示这些a图块,以及一个 earth.html 文件,用于在谷歌地球上打开地图。 参数: image (图像): 要导出为磁贴的图片。 description(字符串,可选): 任务的可读名称。默认为 "myExportMapTask"。 bucket(字符串,可选): 要写入的目标存储桶。 fileFormat(字符串,可选): 地图瓦片的文件格式,可以是 "auto"、"png "或 "jpg "中的一种。默认为 "auto",这意味着不透明的磁贴将编码为 "jpg",透明的磁贴将编码为 "png"。 path(字符串,可选): 用作输出路径的字符串。尾部的"/"为可选项。默认为任务描述。 writePublicTiles(布尔,可选): 是否写入公共磁贴,而不是使用水桶的默认对象 ACL。默认为 true,并要求调用者是水桶的所有者。 maxZoom(数值,可选): 要导出的地图磁贴的最大缩放级别。 scale(数值,可选): 最大图像分辨率(单位:米/像素),可替代 "maxZoom"。比例尺将转换为赤道上最合适的最大缩放级别。 minZoom(数值,可选): 要导出的地图图块的可选最小缩放级别。默认为零。 region(Geometry.LinearRing|Geometry.Polygon|String,可选项): 代表要导出区域的 LinearRing、Polygon 或坐标。可以指定为几何对象或序列化为字符串的坐标。将在包含此几何图形的矩形区域中生成地图方块。 skipEmptyTiles(布尔,可选): 如果为 "true",则跳过写入空(即全透明)的地图碎片。默认为 false。 mapsApiKey(字符串,可选): 在 index.html 中用于初始化 Google 地图 API。这将删除地图上的 "仅限开发目的 "信息。 bucketCorsUris(List,可选): 允许从 JavaScript 获取导出磁贴的域列表(如 https://code.earthengine.google.com)。将磁贴设置为 "公共 "还不足以让网页访问它们,因此必须明确授予域对数据桶的访问权限。这就是所谓的跨源资源共享(Cross-Origin-Resource-Sharing)或 CORS。您可以使用 "*"来允许所有域访问,但一般不鼓励这样做。更多详情,请参阅 https://cloud.google.com/storage/docs/cross-origin。

影像可视化函数

visualize(bands, gain, bias, min, max, gamma, opacity, palette, forceRgbOutput)

Produces an RGB or grayscale visualization of an image. Each of the gain, bias, min, max and gamma arguments can take either a single value, which will be applied to all bands, or a list of values the same length as bands.

Arguments:

this:image (Image):

The image to visualize.

bands (Object, default: null):

A list of the bands to visualize. If empty, the first 3 are used.

gain (Object, default: null):

The visualization gain(s) to use.

bias (Object, default: null):

The visualization bias(es) to use.

min (Object, default: null):

The value(s) to map to RGB8 value 0.

max (Object, default: null):

The value(s) to map to RGB8 value 255.

gamma (Object, default: null):

The gamma correction factor(s) to use.

opacity (Number, default: null):

The opacity scaling factor to use.

palette (Object, default: null):

The color palette to use. List of CSS color identifiers or hexadecimal color strings (e.g. ['red', '00FF00', 'bluevlolet']).

forceRgbOutput (Boolean, default: false):

Whether to produce RGB output even for single-band inputs.

Returns: Image
代码语言:javascript
复制
Export.map.toCloudStorage({
  image: dataset.mosaic().visualize(),
  description: 'mapTilesForMapPreview',
  bucket: 'test-no2',  // replace with your GCS bucket name
  fileFormat: 'auto',
  maxZoom: 13,
  region: exportRegion,
  writePublicTiles: true,
  mapsApiKey: 'XXX'
});

大家可以自己开去开一个云存储账户,因为是计费项目,所以这里不展示,因为这需要mapsApiKey,所以如果你是付费用户可以去试试。

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2024-02-01,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Arguments:
  • Returns: Image
相关产品与服务
对象存储
对象存储(Cloud Object Storage,COS)是由腾讯云推出的无目录层次结构、无数据格式限制,可容纳海量数据且支持 HTTP/HTTPS 协议访问的分布式存储服务。腾讯云 COS 的存储桶空间无容量上限,无需分区管理,适用于 CDN 数据分发、数据万象处理或大数据计算与分析的数据湖等多种场景。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档