- 积分
- 55945
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2011-6-21
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
如果获取的是天气现象站点数据(天气现象对应的数字代码),还可以生成天气现象符号图层。从MICAPS第1类数据中还可以获取站点填图数据StationModelData类,生成站点填图图层。
DrawMeteoData.createWeatherSymbolLayer(StationData weatherData, String weatherType, String layerName)
DrawMeteoData.createWeatherSymbolLayer(StationData weatherData, List<Integer> weathers, String layerName)
DrawMeteoData.createStationModelLayer(StationModelData smData, String layerName)
可以通过天气类型生成天气符号图层,如果是"All Weather"则生成所有天气现象符号。也可以通过设定天气代码列表来创建特定天气现象符号图层。
- #-----------------------------------------------------
- # Author: Yaqiang Wang
- # Date: 2014-12-1
- # Purpose: Get and plot station weather phenomenon
- # 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.layout import PaperSize
- 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()
- ps = PaperSize('Custum', 500, 1000)
- mapLayout.setPaperSize(ps)
- #---- 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.black)
- 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('WeatherNow')
- #---- Create station weather layer from the station data
- layer = DrawMeteoData.createWeatherSymbolLayer(sdata, 'All Weather', 'WeatherSymbole')
- #weathers = [5,10,11,12,40,41,42,43,44,45,46,47,48,49]
- #layer = DrawMeteoData.createWeatherSymbolLayer(sdata, weathers, 'WeatherSymbole')
- #---- 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(628, 10)
- legend.setLegendStyle(LegendStyles.Normal)
- legend.setLegendLayer(layer)
- legend.setColumnNumber(4)
- legend.setTitle('Weather')
- frame = JFrame('MeteoInfo Script Sample', size = (990, 530))
- frame.add(mapLayout)
- frame.visible = True
- print 'Finished!'
全部天气现象:
雾霾天气:
站点填图脚本:
- #-----------------------------------------------------
- # Author: Yaqiang Wang
- # Date: 2014-12-1
- # Purpose: Get and plot station model 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 model data
- smdata = mdi.getStationModelData()
- #---- Create station info layer from the station model data
- layer = DrawMeteoData.createStationModelLayer(smdata, 'StationModel')
- #---- 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)
- frame = JFrame('MeteoInfo Script Sample', size = (750, 540))
- frame.add(mapLayout)
- frame.visible = True
- print 'Finished!'
|
|