1
我一直在使用SMAP數據衛星,專門用於溼度和土壤比例。如何解決從EASE-2網格產品SMAP到地理座標的重投影?
我按照使用的想法GDAL解決一切,並與此類似刊登在Link to first approach to download SMAP data
對矯正代碼和測試的東西:
import os
import h5py
import numpy as np
from osgeo import gdal, gdal_array, osr
# the file to download
path = "/path/to/data"
h5File = h5py.File(path + "SMAP_L4_SM_aup_20170801T030000_Vv3030_001.h5", 'r')
data = h5File.get('Analysis_Data/sm_rootzone_analysis')
lat = h5File.get("cell_lat")
lon = h5File.get("cell_lon")
np_data = np.array(data)
np_lat = np.array(lat)
np_lon = np.array(lon)
num_cols = float(np_data.shape[1])
num_rows = float(np_data.shape[0])
xmin = np_lon.min()
xmax = np_lon.max()
ymin = np_lat.min()
ymax = np_lat.max()
xres = (xmax - xmin)/num_cols
yres = (ymax - ymin)/num_rows
nrows, ncols = np_data.shape
xres = (xmax - xmin)/float(ncols)
yres = (ymax - ymin)/float(nrows)
geotransform = (xmin, xres, 0, ymax, 0, -xres)
dataFileOutput = path + "sm_rootzone_analysis.tif"
output_raster = gdal.GetDriverByName('GTiff').Create(dataFileOutput, ncols, nrows, 1, gdal.GDT_Float32) # Open the file
output_raster.SetGeoTransform(geotransform)
srs = osr.SpatialReference()
srs.ImportFromEPSG(4326)
output_raster.SetProjection(srs.ExportToWkt())
output_raster.GetRasterBand(1).WriteArray(np_data) # Writes my array to the raster
del output_raster
所以,使用這種方法,結果是一個全球性的地圖,有很多投影問題,比如下面的圖片,由py生成上面的代碼。
爲了與正確的數據進行比較,使用HEG nasa軟件從h5中提取相同的圖像。