2017-08-31 170 views
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 

https://n5eil01u.ecs.nsidc.org/SMAP/SPL4SMAU.003/2017.08.01/SMAP_L4_SM_aup_20170801T030000_Vv3030_001.h5

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生成上面的代碼。 Map produced using the code above

爲了與正確的數據進行比較,使用HEG nasa軟件從h5中提取相同的圖像。 Map correct

回答

0

如果數據確實在EASE2 Global網格中,則不應將EPSG:4326指定爲地理變換中緯度/經度的座標系。

如果轉換緯度/經度距9km座標到EASE2網格,你的地理座標應該是這樣的:

geotransform = (-17367530.44516138, 9000, 0, 7314540.79258289, 0, -9000.0)

和SRS:

srs.ImportFromEPSG(6933)

相關問題