我在Breeze中有一个表示图像的矩阵。例如,每个单元格(x,y)保持RGB值。我可以使用Scrimage将其保存为各种图像格式(GIF,Jpeg ...)。
如何生成geoTiff图像?我正在考虑GeoTrellis,但尚未找到一种直截了当的方式。
答案 0 :(得分:0)
所以你在谈论RGB图像,可能它意味着一个int GeoTiff。
代码看起来像(当前快照版本1.0.0-SNAPSHOT
):
val matrix: Array[Array[Int]] = ???
val cols = ??? // matrix dimensions
val rows = ???
val extent: Extent = ??? // you need extent for geotiff
val crs: CRS = ??? // you need to know crs
val tile = IntArrayTile.empty(cols, rows) // create an empty tile
for {
c <- 0 until cols
r <- 0 until rows
} tile.set(c, r, matrix(c)(r))
val geotiff = SinglebandGeoTiff(tile, extent, crs) // it's a geotiff
geotiff.write("dir where you plan to save your geotiff")
然而,这将是一个灰度级的地理位置,要保留RGB图像,您可能想要创建三个图块,并将所有内容保存为多波段GeoTiff。
val red: Tile = ???
val green: Tile = ???
val blue: Tile = ???
val mbtile = MultibandTile(red, green, bule)
val mbgeotiff = new MultibandGeoTiff(
mbtile,
extent,
crs,
GeoTiffOptions(
Striped,
NoCompression,
ColorSpace.RGB
)
) // GeoTiff options setup is quite important, to set up `TIFFTAG_PHOTOMETRIC` tag
mbgeotiff.write("dir where you plan to save your geotiff")
但我不熟悉Breeze
API,我们可以在GeoTrellis gitter频道中讨论您的用例或/并在那里提供更多信息。