- 积分
- 621
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2011-6-20
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
各位大神,请教下,我用王老师的天气符号脚本(http://bbs.06climate.com/forum.p ... id=30931&fromuid=27)绘制天气天气符号并给给一些站名备注,可是为什么,天气符号图在meteoinfo script sample 界面,而标注的站名缺在figure界面,怎么使两者在一个界面。
#-----------------------------------------------------
# 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:/MeteoInfo_1.6.10/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, 550)
mapLayout.setPaperSize(ps)
#---- Load country layer
print 'Load country layer...'
countryLayer = MapDataManage.loadLayer(os.path.join(mapDir, 'cn_province.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, 'E:/201801/micaps/MicData/Surface/PLOT/18012508.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')
#---- 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)
#Add station name
geoshow(110.02,27.57, size=14, color='r', marker='S')
axis([107, 116, 24, 32])
text(110.02,27.57, u'怀化',fontname=u'楷体', fontsize=10)
#---- Set layout map
print 'Set layout map...'
mapLayout.getActiveLayoutMap().setWidth(600)
mapLayout.getActiveLayoutMap().zoomToExtentLonLatEx(Extent(107, 116, 24, 32))
#---- Set mapframe
mapFrame.setGridXDelt(2)
mapFrame.setGridYDelt(2)
#---- Add legend
#legend = mapLayout.addLegend(628, 10)
#legend.setLegendStyle(LegendStyles.Normal)
#legend.setLegendLayer(layer)
#legend.setColumnNumber(4)
#legend.setTitle('Weather')
#Plot
#axesm(bgcolor=(204,255,255))
frame = JFrame('MeteoInfo Script Sample', size = (530, 530))
frame.add(mapLayout)
frame.visible = True
figDir = 'E:/201801/micaps'
mapLayout.exportToPicture(os.path.join(figDir, '18012508.png'))
print 'Finished!'
|
|