scala - 将 IndexedColorMap 类型转换为 ColorMap
问题描述
我有一个获取图像颜色图的代码(* .tif)。
val geotiff = SinglebandGeoTiff(abcd.tif)
val colorMap1 = geotiff.options.colorMap
现在 colorMap1 是 IndexedColorMap 类型。
有没有办法将 colormap1 转换或类型转换为 ColorMap(geotrellis.raster.render.ColorMap) ,因为我的整个代码是基于 ColorMap 而不是 IndexedColorMap
解决方案
IndexedColorMap
extends 扩展IntColorMap
,ColorMap
因此它们是兼容的。但它看起来不像是geotiff.options.colorMap
回来了。所以你可以这样做:Option[IndexedColourMap]
IndexedColorMap
val defaultColorMap: ColorMap = ???
val colorMap1: ColorMap = geotiff.options.colorMap.getOrElse(defaultColorMap)
在线查看其他Option
在 Scala 中以干净、实用的方式处理值的方法。
推荐阅读
- reactjs - 我的 api 调用有问题 react ' http://localhost/https://myapiurl.com '
- python - 查找 docker 守护进程是否正在运行
- pybind11 - 使用 pybind11 对 Eigen::Vector/Matrix 类型进行全透明曝光
- python - BigQuery 代码因使用 pandas python 客户端库的 MemoryError 而失败
- mysql - 更新表条目告诉我该表在过程中不存在
- spring - Grails 可运行 jar 中的 Spring Security 重定向到 HTTP
- reactjs - 尽管使用单引号,有没有办法让标签中的所有文本保持相同的字体颜色?
- scala - 在 Scala 中是否有任何理由使用类与对象?
- cypress - 如何处理(cy.get())动态元素如果存在则做A如果不做B
- ssl - 如何将大使连接到启用 ssl 的谷歌实例组