爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 3657|回复: 2

[转载]如何用IDL画土壤质地三角图

[复制链接]

新浪微博达人勋

发表于 2014-2-15 16:33:10 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

x
本帖最后由 hillside 于 2014-2-15 20:55 编辑

       此帖转载自:http://njuzhaodz.blog.163.com/blog/static/2711250020073211445722/        

                                                     如何用IDL画土壤质地三角图

;相关算法请参考:
;[1] 张丽萍, 张镱锂, 王英安. 基于计算机图形学的土壤质地自动分类系统[J]. 2006.
;以下是源代码部分:
pro drawtriangle
样点值
Clay=[11.5,12.025,10.403,20.138,14.444,17.128,15.469,26.085,18.615,1.088];粘粒
Sand=[18.578,16.097,65.264,46.057,15.970,18.341,20.603,8.277,30.5,15.68] ;沙粒
Silt=[1,1,1,1,1,1,1,1,1,1]*100-Clay-Sand ;z粉粒
x=100-sand-clay/2
y=sqrt(3.0)*clay/2.0
Symbol=Obj_new(’IDLgrSymbol’,data=3,size=3,color=[255,0,0])
point=obj_new(’IDLgrPlot’,x,y,color=[0,200,0],LINESTYLE=6,Symbol=Symbol)
base=widget_base()
draw=widget_draw(base,xsize=700,ysize=700,graphics_level=2, $
  retain=2)
widget_control,base,/realize
widget_control,draw,get_value=oWindow
;oWindow=;=obj_new(’IDlgrWindow’,dim=[700,700],Title=’Draw Triangle’)
oview=obj_new(’IDLgrView’,VIEWPLANE_RECT=[-10,-20,120,120])
omodel=obj_new(’IDLgrModel’)
axis_y=obj_new(’IDLgrAxis’,1,Range=[0,100*sin(!pi/3.0)],/hide)

;画坐标轴
top_x=[100,50,0,100]
top_y=[0,100*sin(!pi/3.0),0,0]

plot_axis=obj_new(’IDLgrPlot’,top_x,top_y,thick=3)
;add Sand Axis Title and Tick
Sand_Title=obj_new(’IDLgrText’,'Sand(%,2-0.05mm)’,$
  alignment=0.5,Font=TitleFont)
Sand_Tickvalue=[0,10,20,30,40,50,60,70,80,90]
Sand_Tickname=[’100′,’90′,’80′,’70′,’60′,’50′,’40′,’30′,’20′,’10′]
Sand_TickText=OBJ_NEW(’IDLgrText’,Sand_Tickname)
axis_Sand=obj_new(’IDLgrAxis’,0,Title=Sand_Title,RANGE=[0,100],$
  TICKVALUES=Sand_Tickvalue,TICKTEXT=Sand_TickText)
;add Clay Axis Title and Tick

Clay_Title=Obj_New(’IDLgrText’,'Clay(%,<0.002mm)’,location=[25-8,50*sin(!pi/3.0)],$
  alignment=0.5,Font=TitleFont,baseline=[1,2*sin(!pi/3.0)])
Clay_Tick1=Obj_New(’IDLgrText’,'10′,location=[5-3,10*sin(!pi/3.0)],$
  alignment=0.0,Font=TitleFont)
Clay_Tick2=Obj_New(’IDLgrText’,'20′,location=[10-3,20*sin(!pi/3.0)],$
  alignment=0.0,Font=TitleFont)
Clay_Tick3=Obj_New(’IDLgrText’,'30′,location=[15-3,30*sin(!pi/3.0)],$
  alignment=0.0,Font=TitleFont)
Clay_Tick4=Obj_New(’IDLgrText’,'40′,location=[20-3,40*sin(!pi/3.0)],$
  alignment=0.0,Font=TitleFont)
Clay_Tick5=Obj_New(’IDLgrText’,'50′,location=[25-3,50*sin(!pi/3.0)],$
  alignment=0.0,Font=TitleFont)
Clay_Tick6=Obj_New(’IDLgrText’,'60′,location=[30-3,60*sin(!pi/3.0)],$
  alignment=0.0,Font=TitleFont)
Clay_Tick7=Obj_New(’IDLgrText’,'70′,location=[35-3,70*sin(!pi/3.0)],$
  alignment=0.0,Font=TitleFont)
Clay_Tick8=Obj_New(’IDLgrText’,'80′,location=[40-3,80*sin(!pi/3.0)],$
  alignment=0.0,Font=TitleFont)
Clay_Tick9=Obj_New(’IDLgrText’,'90′,location=[45-3,90*sin(!pi/3.0)],$
  alignment=0.0,Font=TitleFont)
Clay_Tick10=Obj_New(’IDLgrText’,'100′,location=[50-4,100*sin(!pi/3.0)],$
  alignment=0.0,Font=TitleFont)

omodel->add,point
oModel->add,Clay_Tick1
oModel->add,Clay_Tick2
oModel->add,Clay_Tick3
oModel->add,Clay_Tick4
oModel->add,Clay_Tick5
oModel->add,Clay_Tick6
oModel->add,Clay_Tick7
oModel->add,Clay_Tick8
oModel->add,Clay_Tick9
oModel->add,Clay_Tick10
;add Silt Axis Title and Tick
Silt_Title=Obj_New(’IDLgrText’,'Silt(%,0.05-0.002mm)’,location=[75+5,50*sin(!pi/3.0)],$
  alignment=0.5,Font=TitleFont,baseline=[1,-2*sin(!pi/3.0)])
Silt_Tick1=Obj_New(’IDLgrText’,'10′,location=[55,90*sin(!pi/3.0)],$
  alignment=0.0,Font=TitleFont)
Silt_Tick2=Obj_New(’IDLgrText’,'20′,location=[60,80*sin(!pi/3.0)],$
  alignment=0.0,Font=TitleFont)
Silt_Tick3=Obj_New(’IDLgrText’,'30′,location=[65,70*sin(!pi/3.0)],$
  alignment=0.0,Font=TitleFont)
Silt_Tick4=Obj_New(’IDLgrText’,'40′,location=[70,60*sin(!pi/3.0)],$
  alignment=0.0,Font=TitleFont)
Silt_Tick5=Obj_New(’IDLgrText’,'50′,location=[75,50*sin(!pi/3.0)],$
  alignment=0.0,Font=TitleFont)
Silt_Tick6=Obj_New(’IDLgrText’,'60′,location=[80,40*sin(!pi/3.0)],$
  alignment=0.0,Font=TitleFont)
Silt_Tick7=Obj_New(’IDLgrText’,'70′,location=[85,30*sin(!pi/3.0)],$
  alignment=0.0,Font=TitleFont)
Silt_Tick8=Obj_New(’IDLgrText’,'80′,location=[90,20*sin(!pi/3.0)],$
  alignment=0.0,Font=TitleFont)
Silt_Tick9=Obj_New(’IDLgrText’,'90′,location=[95,10*sin(!pi/3.0)],$
  alignment=0.0,Font=TitleFont)
Silt_Tick10=Obj_New(’IDLgrText’,'100′,location=[100,0*sin(!pi/3.0)],$
  alignment=0.0,Font=TitleFont)
oModel->add,Silt_Tick1
oModel->add,Silt_Tick2
oModel->add,Silt_Tick3
oModel->add,Silt_Tick4
oModel->add,Silt_Tick5
oModel->add,Silt_Tick6
oModel->add,Silt_Tick7
oModel->add,Silt_Tick8
oModel->add,Silt_Tick9
oModel->add,Silt_Tick10
;add line
line_X=[5,95,90,10,15,85,80,20,25,75,70,30,35,65,60,40,45,55,$
  10,20,60,65,30,40,70,75,50,60,80,85,70,80,90,95,90,$
  45,40,80,70,35,30,60,50,25,20,40,30,15,10,20,10,5]
line_Y=[10*sin(!pi/3.0),10*sin(!pi/3.0),$
  20*sin(!pi/3.0),20*sin(!pi/3.0),$
  30*sin(!pi/3.0),30*sin(!pi/3.0),$
  40*sin(!pi/3.0),40*sin(!pi/3.0),$
  50*sin(!pi/3.0),50*sin(!pi/3.0),$
  60*sin(!pi/3.0),60*sin(!pi/3.0),$
  70*sin(!pi/3.0),70*sin(!pi/3.0),$
  80*sin(!pi/3.0),80*sin(!pi/3.0),$
  90*sin(!pi/3.0),90*sin(!pi/3.0),$
  0,0,$
  80*sin(!pi/3.0),70*sin(!pi/3.0),$
  0,0,$
  60*sin(!pi/3.0),50*sin(!pi/3.0),$
  0,0,$
  40*sin(!pi/3.0),30*sin(!pi/3.0),$
  0,0,$
  20*sin(!pi/3.0),10*sin(!pi/3.0),0,$
  90*sin(!pi/3.0),80*sin(!pi/3.0),$
  0,0,70*sin(!pi/3.0),60*sin(!pi/3.0),$
  0,0,50*sin(!pi/3.0),40*sin(!pi/3.0),$
  0,0,30*sin(!pi/3.0),20*sin(!pi/3.0),$
  0,0,10*sin(!pi/3.0),0]
plot_line=Obj_New(’IDLgrPlot’,line_X,line_Y)
;add class line
;sand line,Class 1
sandline_x=[5,15]
sandline_y=[10*sin(!pi/3.0),0]
sand_line=Obj_new(’IDLgrPlot’,sandline_x,sandline_y,color=[200,0,0],thick=2)
;Loamy sand line,Class 2
LoamySline_x=[7.5,30]
LoamySline_y=[15*sin(!pi/3.0),0]
LoamyS_line=Obj_new(’IDLgrPlot’,LoamySline_x,LoamySline_y,color=[200,0,0],thick=2)
;Silt line,Class 3
Siltline_x=[80,85,95]
Siltline_y=[0,10*sin(!pi/3.0),10*sin(!pi/3.0)]
Silt_line=Obj_new(’IDLgrPlot’,Siltline_x,Siltline_y,color=[200,0,0],thick=2)
;Sandy loam
SandLline_x=[10,38,44.5,53.5]
SandLline_y=[20*sin(!pi/3.0),20*sin(!pi/3.0),7*sin(!pi/3.0),7*sin(!pi/3.0)]
SandL_line=Obj_new(’IDLgrPlot’,SandLline_x,SandLline_y,color=[200,0,0],thick=2)

;Silt Loam line,Class 6
SiltLline_x=[50,63.5,86.5]
SiltLline_y=[0,27*sin(!pi/3.0),27*sin(!pi/3.0)]
SiltL_line=Obj_new(’IDLgrPlot’,SiltLline_x,SiltLline_y,color=[200,0,0],thick=2)

;Sandy clay,Class 10
SandyCline_x=[17.5,37.5,27.5,35,80,60,70]
SandyCline_y=[35*sin(!pi/3.0),35*sin(!pi/3.0),55*sin(!pi/3.0),$
  40*sin(!pi/3.0),40*sin(!pi/3.0),40*sin(!pi/3.0),60*sin(!pi/3.0)]
SandyC_line=Obj_new(’IDLgrPlot’,SandyCline_x,SandyCline_y,color=[200,0,0],thick=2)
;Clay loam
ClayLline_x=[38,41.5,66.5,60,35,41.5]
ClayLline_y=[20*sin(!pi/3.0),27*sin(!pi/3.0),27*sin(!pi/3.0),40*sin(!pi/3.0),$
  40*sin(!pi/3.0),27*sin(!pi/3.0)]
ClayL_line=Obj_new(’IDLgrPlot’,ClayLline_x,ClayLline_y,color=[200,0,0],thick=2)

omodel->add,ClayL_line
omodel->add,SandyC_line
omodel->add,SandL_line
omodel->add,SiltL_line
omodel->add,Silt_line
omodel->add,LoamyS_line
omodel->add,sand_line
omodel->add,plot_line
omodel->add,plot_axis
omodel->add,axis_y
omodel->add,axis_Sand
oModel->add,Clay_Title
oModel->add,Silt_Title
oview->add,omodel
oWindow->draw,oview
obj_destroy,oview
end


评分

参与人数 1金钱 +10 收起 理由
言深深 + 10

查看全部评分

密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2014-2-15 19:18:14 | 显示全部楼层
谢谢分享  
可以把图贴上就更好了
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2014-2-15 20:56:46 | 显示全部楼层
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表