爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 4840|回复: 2

[求助] IDL直接图形法中如何用shp文件加载省界、县界?

[复制链接]

新浪微博达人勋

发表于 2020-5-8 15:48:02 | 显示全部楼层 |阅读模式

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

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

x
走过路过的大神们给指点一下,IDL直接图形法中如何用shp文件加载省界、县界?shap文件是有的。
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2020-5-9 10:37:33 | 显示全部楼层
pro readshapefile
  shapefile='D:\map_china\全国省级、地市级、县市级行政区划shp\省界bou2_4m\bou2_4l.shp'
  oshp=Obj_New('IDLffShape',shapefile)
  print,oshp
  ;中间处理代码
; Obj_destroy,oshp ;销毁一个shape对象
  oshp->getproperty,n_entities=n_ent,Attribute_info=attr_info,n_attributes=n_attr,Entity_type=ent_type
  print,'实体个数:',n_ent
  print,'属性表字段数:',n_attr
  print,'实体类型代码:',ent_type
  ;Obj_destroy,oshp ;销毁一个shape对象
;  FOR i=0,n_attr-1 do begin ;循环
;    PRINT, '字段序号: ',i
;    PRINT, '字段名: ', attr_info[i].name
;    PRINT, '字段类型代码: ', attr_info[i].type
;    PRINT, '字段宽度: ', attr_info[i].width
;    PRINT, '精度: ', attr_info[i].precision
;  endfor
;  stop
  FOR i=0,n_ent-1 do begin ;循环
    ent=oshp->getentity(i) ;读取第i个实体
;    attr=oshp->GetAttributes(i) ;读取第i个记录
;    for index=0, n_attr-1 do begin
;      print,attr(index)
;    endfor
;    stop
    bounds=ent.bounds ;读取实体的边界
    n_vert=ent.n_vertices ;实体中包括拐点或顶点的个数,只有polyline和polygon具有该属性
    vert=*(ent.vertices) ;实体的顶点,只有polyline和polygon具有该属性
    n_parts=ent.parts ;只有polygon具有该属性
    part=*(ent.parts) ;part坐标
    ;输出几何体范围
;    print,'min x=',bounds[0]
;    print,'min y=',bounds[1]
;    print, 'max x=',bounds[3]
;    print, 'max y=',bounds[4]
    ;如果是点的话,输出点坐标
    ;print,bounds[0],bounds[1]
    ;help,bounds,vert
    ;如果是线或面的话,输出点坐标
    ;for i=0,n_vert-1 do begin
      
    ;endfor
   ; for index in n_vert-1 do begin
   ;   print vert[index][0],vert[index][1]
    ;endfor
    p=plot(vert(0,*),vert(1,*),xrange=[60,140],yrange=[0,60],/overplot,AXIS_STYLE=0)
    print,i
  endfor
  Obj_destroy,oshp ;销毁一个shape对象

end

这是快速可视化的读取,可以参考下
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

 楼主| 发表于 2020-5-9 23:01:12 | 显示全部楼层
徐徐清风 发表于 2020-5-9 10:37
pro readshapefile
  shapefile='D:\map_china\全国省级、地市级、县市级行政区划shp\省界bou2_4m\bou2_4l ...

非常感谢,我明天去试试。
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

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

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

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