请选择 进入手机版 | 继续访问电脑版
爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 17831|回复: 32

[混合编程] IDL编程学习之地图

[复制链接]

新浪微博达人勋

发表于 2017-4-17 09:33:57 | 显示全部楼层 |阅读模式

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

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

x
画经纬线:
IDL> map('stereographic',limit=[10,80,50,130],center_latitude=30,center_longitude=105,title='map',fill_color='light blue')
1.png
画国界:
IDL> mapcontinents(/countries,fill_color='beige')
2.png
画河流:
IDL> mapcontinents(/rivers,color='blue')

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

新浪微博达人勋

发表于 2017-4-18 20:05:23 | 显示全部楼层
15195775117 发表于 2017-4-18 18:37
大体明白你的意思了,不过我也不是太会,你凑合看。
直接在地图上操作,问题不少,比如地图的颜色和等值 ...

谢谢大神,没想到还能通过调节透明度叠在一起,学到了学到了,先膜拜一波
密码修改失败请联系微信:mofangbao
回复 支持 0 反对 1

使用道具 举报

新浪微博达人勋

 楼主| 发表于 2017-4-18 18:37:58 | 显示全部楼层
andy4576 发表于 2017-4-18 15:27
data就是画图数据
huatu就是画图程序
新手程序写的丑,麻烦大神了

大体明白你的意思了,不过我也不是太会,你凑合看。
直接在地图上操作,问题不少,比如地图的颜色和等值线图的颜色冲突,
我的办法比较简单粗暴,就是画2张图,然后叠在一起,效果如下:
contour_map.jpg

你的程序使拷贝别人的吧,感觉比较啰嗦,我简化了下:
  lon=findgen(21)*2.5+65.0
  lat=findgen(15)*2.5+15.0
  a=read_ascii('C:\Users\Administrator\Desktop\data.txt',data_start=0)
  X=a.field1
  X=REFORM(X,15,21)
  P=WHERE(X EQ -9999)
  X[P]=0
  year_ave=transpose(x)
  map = MAP('Mercator', LIMIT=[15,65,50,115],$
    FILL_COLOR = "light blue",TITLE='Tibet Map Grid',$
    layout=[2,1,1])
  m1 = MapContinents(/COUNTRIES,FILL_COLOR='w')
  tu=contour(year_ave,lon,lat,rgb_table=33,max_value=1,min_value=0,$
    /fill,layout=[2,1,2],xrange=[65,115],yrange=[15,50],$
    axis_style=0,/current)

两张图画好后,窗口有调节透明度的选项,调节一张图的透明度然后移到另一张图上就行了。
密码修改失败请联系微信:mofangbao
回复 支持 1 反对 0

使用道具 举报

新浪微博达人勋

发表于 2017-4-17 11:26:10 | 显示全部楼层
好棒啊  个人感觉IDL很难学~
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2017-4-17 23:42:05 | 显示全部楼层
左孔疚 发表于 2017-4-17 11:26
好棒啊  个人感觉IDL很难学~

一点也不难,手里没资料,自然是难学,网上买本书吧
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2017-4-18 09:55:30 | 显示全部楼层
在地图上画countour图是不是要投影啥的
map = MAP('Mercator', LIMIT=[15,65,50,115],LONGITUDE_MIN=65, LONGITUDE_MAX=115, FILL_COLOR = "light blue", TITLE='Tibet Map Grid')

m1 = MapContinents(/COUNTRIES,FILL_COLOR="white")

假如要画的countour数据是data,经纬度是lon和lat,投影是Mercator,请问下大神怎么把这个图和之前画的地图合在一块啊,给个大概的语句就行,谢谢大神了
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2017-4-18 15:04:43 | 显示全部楼层
andy4576 发表于 2017-4-18 09:55
在地图上画countour图是不是要投影啥的
map = MAP('Mercator', LIMIT=[15,65,50,115],LONGITUDE_MIN=65, L ...

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

新浪微博达人勋

发表于 2017-4-18 15:27:04 | 显示全部楼层
data就是画图数据
huatu就是画图程序
新手程序写的丑,麻烦大神了

data.txt

4.61 KB, 下载次数: 7, 下载积分: 金钱 -5

countour数据

huatu.pro

1017 Bytes, 下载次数: 6, 下载积分: 金钱 -5

画图程序

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

新浪微博达人勋

发表于 2017-4-18 15:39:24 | 显示全部楼层
。。等会,下载居然要金币,我发个文字:
pro huatu

lat1=15.00
lat2=50.00

lon1=65.00
lon2=115.00

grid=2.5
map_limit=[15,65,50,115]
m=(lat2-lat1)/grid+1
n=(lon2-lon1)/grid+1

lon=fltarr(n)
lat=fltarr(m)

for i=0,n-1,1 do begin
    lon[i]=lon1+grid*i
endfor
for i=0,m-1,1 do begin
    lat[i]=lat1+grid*i
endfor


year_ave=fltarr(n,m)
path='D:\Xftp_download\';文件路径
file1=path+'data.txt'
openr,lun1,file1,/GET_LUN
for i=0,n-1,1 do begin
    for j=0,m-1,1 do begin
        year_ave[i,j]=readfile(lun1)
    endfor
endfor
FREE_LUN, lun1


map = MAP('Mercator', LIMIT=[15,65,50,115],LONGITUDE_MIN=65, LONGITUDE_MAX=115, FILL_COLOR = "light blue",TITLE='Tibet Map Grid')
m1 = MapContinents(/COUNTRIES,FILL_COLOR="white")
tu=contour(year_ave,lon,lat,rgb_table=33,c_color=['r','g','b'],max_value=1,min_value=0,/fill,/overplot);样例countour,想和前面的map图合在一起

end

function readfile,lun_
    temp=''
    element=0.0
    readf,lun_,temp
    temp=STRTRIM(temp,1)
    element=float(temp)
    return,element
end


data数据:
     0.847775
     0.803897
     0.895948
     0.784974
     0.543512
     0.490438
     0.372255
     0.645180
     0.457275
     0.404388
     0.594056
     0.731158
     0.753999
     0.788967
     -9999.00
     0.806070
     0.821918
     0.667756
     0.868020
     0.574098
     0.451387
     0.611733
     0.582190
     0.560048
     0.517264
     0.670680
     0.691526
     0.669438
     0.853292
     -9999.00
     0.739828
     0.789288
     0.601495
     0.693505
     0.679296
     0.556458
     0.511176
     0.551423
     0.788021
     0.728772
     0.619197
     0.739435
     0.566152
     0.727716
     -9999.00
     0.917722
     0.755470
     0.682671
     0.608460
     0.661071
     0.779162
     0.557692
     0.665796
     0.787605
     0.773886
     0.736177
     0.535050
     0.693939
     0.806280
     -9999.00
     0.933550
     0.895272
     0.818488
     0.742771
     0.619521
     0.615538
     0.801419
     0.906007
     0.843039
     0.710990
     0.829159
     0.587845
     0.743928
     0.777161
     -9999.00
     0.882166
     0.831812
     0.800906
     0.690331
     0.625613
     0.668777
     0.768636
     0.843269
     0.739670
     0.758841
     0.866483
     0.584332
     0.662231
     0.747907
     -9999.00
     0.854307
     0.768332
     0.641085
     0.712451
     0.646825
     0.720211
     0.870058
     0.864561
     0.637312
     0.655785
     0.715474
     0.704759
     0.637116
     0.779872
     -9999.00
     0.770611
     0.832011
     0.769473
     0.647681
     0.685100
     0.782585
     0.708556
     0.725049
     0.692241
     0.777546
     0.831262
     0.757202
     0.646557
     0.746275
     -9999.00
     0.858581
     0.712838
     0.808351
     0.689043
     0.602414
     0.808506
     0.782696
     0.843561
     0.761469
     0.777229
     0.711417
     0.901740
     0.715211
     0.639193
     -9999.00
     0.878122
     0.888215
     0.801882
     0.843998
     0.773500
     0.777973
     0.731342
     0.849047
     0.726063
     0.504546
     0.628384
     0.456769
     0.742494
     0.738554
     -9999.00
     0.809100
     0.866146
     0.891813
     0.742217
     0.784129
     0.818693
     0.820084
     0.735665
     0.687540
     0.716941
     0.711494
     0.642540
     0.623392
     0.791364
     -9999.00
     0.871973
     0.799525
     0.668880
     0.844898
     0.771003
     0.926131
     0.884088
     0.860899
     0.688588
     0.710404
     0.736317
     0.535464
     0.799203
     0.866876
     -9999.00
     0.761256
     0.797022
     0.731561
     0.729408
     0.826160
     0.890728
     0.975832
     0.843211
     0.645069
     0.599914
     0.699866
     0.541020
     0.666909
     0.719509
     -9999.00
     0.811251
     0.789051
     0.888625
     0.851370
     0.813726
     0.883625
     0.883035
     0.869441
     0.668896
     0.791279
     0.553227
     0.760513
     0.614624
     0.712052
     -9999.00
     0.864596
     0.828502
     0.820157
     0.853717
     0.871437
     0.812663
     0.814660
     0.803284
     0.702740
     0.487821
     0.510238
     0.498011
     0.573560
     0.646928
     -9999.00
     0.847258
     0.854627
     0.879647
     0.856251
     0.899689
     0.912638
     0.899470
     0.800653
     0.616889
     0.552543
     0.588055
     0.524080
     0.610529
     0.691581
     -9999.00
     0.881988
     0.846766
     0.849287
     0.775011
     0.844503
     0.831759
     0.812524
     0.860763
     0.677800
     0.514424
     0.486565
     0.755192
     0.640447
     0.692254
     -9999.00
     0.874010
     0.738449
     0.686478
     0.728932
     0.840935
     0.854292
     0.885446
     0.763973
     0.835386
     0.724639
     0.716065
     0.538208
     0.705559
     0.683823
     -9999.00
     0.784050
     0.856435
     0.723548
     0.737347
     0.774811
     0.916230
     0.869508
     0.700426
     0.728978
     0.762578
     0.613730
     0.719106
     0.536223
     0.589620
     -9999.00
     0.861974
     0.904889
     0.798907
     0.823334
     0.869404
     0.846196
     0.604104
     0.722350
     0.770921
     0.737348
     0.588120
     0.792085
     0.756891
     0.882393
     -9999.00
     -9999.00
     -9999.00
     -9999.00
     -9999.00
     -9999.00
     -9999.00
     -9999.00
     -9999.00
     -9999.00
     -9999.00
     -9999.00
     -9999.00
     -9999.00
     -9999.00
     -9999.00
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2017-4-18 21:21:41 | 显示全部楼层
andy4576 发表于 2017-4-18 15:27
data就是画图数据
huatu就是画图程序
新手程序写的丑,麻烦大神了

其实也不用调透明度,改了透明度颜色就不鲜艳了,地图直接不填色,只留线条,盖在等值线图上面就行了
  lon=findgen(21)*2.5+65.0
  lat=findgen(15)*2.5+15.0
  a=read_ascii('C:\Users\Administrator\Desktop\data.txt',data_start=0)
  X=a.field1
  X=REFORM(X,15,21)
  P=WHERE(X EQ -9999)
  X[P]=0
  year_ave=transpose(x)
  tu=contour(year_ave,lon,lat,rgb_table=33,max_value=1,min_value=0,$
    /fill,xrange=[65,115],yrange=[15,50],$
    axis_style=0,/current,position=[0.1,0.1,0.9,0.9])
  map = MAP('Mercator', LIMIT=[15,65,50,115],TITLE='Tibet Map Grid',$
    /current,position=[0.1,0.1,0.9,0.9])
  m1 = MapContinents(/COUNTRIES)
contour.jpg
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

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

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

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