- 积分
- 55955
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2011-6-21
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
之前提到过站点数据是StationData类,其中包含了站点号、站点坐标和站点观测值。还有一类站点数据是StationInfoData类,可以包含更多的站点数据信息,包括非数字信息。StationData和StationInfoData类的典型应用是创建站点分布图,分别由DrawMeteoData类的下面方法创建:
DrawMeteoData.createSTPointLayer(StationData stdata, String layerName, String fieldName)
DrawMeteoData.createSTInfoLayer(StationInfoData sidata, String layerName)
脚本示例如下:
- #-----------------------------------------------------
- # Author: Yaqiang Wang
- # Date: 2014-12-1
- # Purpose: Get and plot station data
- # Note: Sample
- #-----------------------------------------------------
- #---- Import classes
- print 'Import classes...'
- from org.meteoinfo.layout import MapLayout
- from org.meteoinfo.data.mapdata import MapDataManage
- from org.meteoinfo.data.meteodata import MeteoDataInfo, DrawMeteoData
- from org.meteoinfo.layout import LegendStyles
- from org.meteoinfo.global import Extent
- import os
- from java.awt import Color
- from javax.swing import JFrame
- #---- Set directories
- print 'Set directories...'
- baseDir = 'D:/MyProgram/Distribution/java/MeteoInfo/MeteoInfo'
- dataDir = os.path.join(baseDir, 'sample')
- mapDir = os.path.join(baseDir, 'map')
- #---- Create MapLayout object
- mapLayout = MapLayout()
- mapFrame = mapLayout.getActiveMapFrame()
- #---- Load country layer
- print 'Load country layer...'
- countryLayer = MapDataManage.loadLayer(os.path.join(mapDir, 'country1.shp'))
- lb = countryLayer.getLegendScheme().getLegendBreaks().get(0)
- lb.setDrawFill(False)
- lb.setOutlineColor(Color.blue)
- mapFrame.addLayer(countryLayer)
- #---- Create MeteoDataInfo object
- mdi = MeteoDataInfo()
- #---- Open a MICAPS data file
- fn = os.path.join(dataDir, 'MICAPS/10101414.000')
- mdi.openMICAPSData(fn)
- #---- Get station data
- sdata = mdi.getStationData('Visibility')
- sidata = mdi.getStationInfoData()
- #---- Create station point layer from the grid data
- layer = DrawMeteoData.createSTPointLayer(sdata, 'Visibility_STPoint', 'Visibility')
- #---- Add layer
- mapFrame.addLayer(layer)
- #--- Move layer to bottom
- mapFrame.moveLayer(layer, 0)
- #---- Add title
- title = mapLayout.addText('MeteoInfo script demo', 350, 30, 'Arial', 16)
- #---- Set layout map
- print 'Set layout map...'
- mapLayout.getActiveLayoutMap().setWidth(580)
- mapLayout.getActiveLayoutMap().zoomToExtentLonLatEx(Extent(70, 140, 15, 55))
- #---- Set mapframe
- mapFrame.setGridXDelt(10)
- mapFrame.setGridYDelt(10)
- #---- Add legend
- legend = mapLayout.addLegend(620, 150)
- legend.setLegendStyle(LegendStyles.Normal)
- legend.setLegendLayer(layer)
- legend.setTitle('Visibility')
- frame = JFrame('MeteoInfo Script Sample', size = (800, 600))
- frame.add(mapLayout)
- frame.visible = True
- print 'Finished!'
- #-----------------------------------------------------
- # Author: Yaqiang Wang
- # Date: 2014-12-1
- # Purpose: Get and plot station info data
- # Note: Sample
- #-----------------------------------------------------
- #---- Import classes
- print 'Import classes...'
- from org.meteoinfo.layout import MapLayout
- from org.meteoinfo.data.mapdata import MapDataManage
- from org.meteoinfo.data.meteodata import MeteoDataInfo, DrawMeteoData
- from org.meteoinfo.layout import LegendStyles
- from org.meteoinfo.global import Extent
- import os
- from java.awt import Color
- from java.awt import Font
- from javax.swing import JFrame
- #---- Set directories
- print 'Set directories...'
- baseDir = 'D:/MyProgram/Distribution/java/MeteoInfo/MeteoInfo'
- dataDir = os.path.join(baseDir, 'sample')
- mapDir = os.path.join(baseDir, 'map')
- #---- Create MapLayout object
- mapLayout = MapLayout()
- mapFrame = mapLayout.getActiveMapFrame()
- #---- Load country layer
- print 'Load country layer...'
- countryLayer = MapDataManage.loadLayer(os.path.join(mapDir, 'country1.shp'))
- lb = countryLayer.getLegendScheme().getLegendBreaks().get(0)
- lb.setDrawFill(False)
- lb.setOutlineColor(Color.blue)
- mapFrame.addLayer(countryLayer)
- #---- Create MeteoDataInfo object
- mdi = MeteoDataInfo()
- #---- Open a MICAPS data file
- fn = os.path.join(dataDir, 'MICAPS/10101414.000')
- mdi.openMICAPSData(fn)
- #---- Get station info data
- sidata = mdi.getStationInfoData()
- #---- Create station info layer from the station info data
- layer = DrawMeteoData.createSTInfoLayer(sidata, 'StationInfo')
- labset = layer.getLabelSet()
- labset.setFieldName('CloudCover')
- font = Font('Arial', Font.PLAIN, 14)
- labset.setLabelFont(font)
- labset.setYOffset(15)
- layer.addLabels()
- #---- Add layer
- mapFrame.addLayer(layer)
- #--- Move layer to bottom
- mapFrame.moveLayer(layer, 0)
- #---- Add title
- title = mapLayout.addText('MeteoInfo script demo', 350, 30, 'Arial', 16)
- #---- Set layout map
- print 'Set layout map...'
- mapLayout.getActiveLayoutMap().setWidth(580)
- mapLayout.getActiveLayoutMap().zoomToExtentLonLatEx(Extent(70, 140, 15, 55))
- #---- Set mapframe
- mapFrame.setGridXDelt(10)
- mapFrame.setGridYDelt(10)
- #---- Add legend
- legend = mapLayout.addLegend(620, 150)
- legend.setLegendStyle(LegendStyles.Normal)
- legend.setLegendLayer(layer)
- legend.setTitle('Station')
- frame = JFrame('MeteoInfo Script Sample', size = (800, 600))
- frame.add(mapLayout)
- frame.visible = True
- print 'Finished!'
|
|