- 积分
- 55955
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2011-6-21
- 最后登录
- 1970-1-1
|
发表于 2014-3-10 22:26:28
|
显示全部楼层
要生成等值线填充图层可以用DrawMeteoData类的createShadedLayer方法,由于要生成等值线并填充,此方法会比较慢,如果只是关注中国区域可以先将GridData的范围缩小(用GridData类的extract方法),然后再生成shaded图层,脚本代码如下:
- #-----------------------------------------------------
- # Author: Yaqiang Wang
- # Date: 2013-10-29
- # Purpose: Read hdf4 data
- # Note: Sample
- #-----------------------------------------------------
- from org.meteoinfo.data.meteodata import MeteoDataInfo
- from org.meteoinfo.data.meteodata import Dimension
- from org.meteoinfo.data.meteodata import DimensionType
- from org.meteoinfo.data.meteodata import DrawMeteoData
- from org.meteoinfo.projection import ProjectionInfo
- from org.meteoinfo.legend import LegendManage
- from org.meteoinfo.legend import LegendType
- from org.meteoinfo.shape import ShapeTypes
- import os.path
- import jarray
- #Set data directory
- dataDir = 'D:/Temp/hdf/'
- #Create MeteoDataInfo object
- mdi = MeteoDataInfo()
- #Read hdf data file
- fn = dataDir + 'tend.HDF'
- if os.path.isfile(fn):
- print fn
- mdi.openNetCDFData(fn)
- dataInfo = mdi.getDataInfo()
- print mdi.getInfoText()
- xmin = -180.0
- ymin = -90.0
- xnum = 360
- ynum = 180
- xdelt = 1.0
- ydelt = 1.0
- xlist = []
- ylist = []
- for i in range(0,xnum):
- xlist.append(xmin + xdelt * i)
- for i in range(0,ynum):
- ylist.append(ymin + ydelt * i)
- X = jarray.array(xlist, 'd')
- Y = jarray.array(ylist, 'd')
- xDim = Dimension(DimensionType.X)
- xDim.setValues(X)
- dataInfo.setXDimension(xDim)
- yDim = Dimension(DimensionType.Y)
- yDim.setValues(Y)
- dataInfo.setYDimension(yDim)
- var = dataInfo.getVariable('AOD_Mean_Tend')
- dimList = [yDim, xDim]
- var.setDimensions(dimList)
- gData = mdi.getGridData(var.getName())
- #gData = gData.multiply(0.01)
- gData = gData.extract(70.0, 140.0, 15.0, 60.0)
- aLS = LegendManage.createLegendSchemeFromGridData(gData, LegendType.GraduatedColor, ShapeTypes.Polygon)
- #aLayer = DrawMeteoData.createRasterLayer(gData, "Test_HDF", aLS)
- aLayer = DrawMeteoData.createShadedLayer(gData, aLS, 'Test_HDF_Shaded', 'AOD', True)
- aLayer.setProjInfo(dataInfo.getProjectionInfo())
- mf = miapp.getMapDocument().getActiveMapFrame()
- mf.addLayer(aLayer)
- mf.moveLayer(aLayer, 0)
- print 'Finished!'
运行结果:
|
|