我嘗試使用 Rasterio-doc 網站上的代碼將陣列作為 TIFF 寫入磁盤 https://rasterio.readthedocs.io/en/latest/topics/writing.html
with rasterio.Env():
profile = src.profile
profile.update(
dtype=rasterio.uint8,
count=1,
compress='lzw')
with rasterio.open('example.tif', 'w', **profile) as dst:
dst.write(array.astype(rasterio.uint8), 1)
當我運行代碼時出現以下錯誤:'name 'array' is not defined'。
我在最后一行嘗試用 'np.array' 而不是 'array' 說它是一個 numpy-array 但它沒有用。
uj5u.com熱心網友回復:
變數“array”代表應該寫入磁盤的資料。創建一個 numpy 陣列,例如:
import numpy as np
array = np.array(my_array_data)
然后,您可以按照教程中的說明將此資料寫入磁盤。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/325926.html
