zoukankan      html  css  js  c++  java
  • [原创.数据可视化系列之四]跨平台,多格式的等值线和等值面的生成

       这些年做项目的时候,碰到等值面基本都是arcgis server来支撑的,通过构建GP服务,一般的都能满足做等值线和等值面的需求。可是突然有一天,我发现如果没有arcgis server 的话,我既然没法生成等值面等值线了。况且,还有许多别的要求:

    1. 没有arcgis server支持,arcgis server毕竟是很大一笔开销,个人基本无法负担;
    2. 跨平台,有的服务器是linux,有的是windows,看来,只能是java的类库了;
    3. 免费,生成等值线和等值面的程序不能有费用;
    4. 输出多种格式,既能输出图片格式,又能输出矢量格式,尤其是 kml之类的矢量数据;

         在气象家园http://bbs.06climate.com/找到一个很不错的解决方案,MeteoInfo,作者是一个很厉害的人,具体的不说了,大家可以去看他的网站和博客,下面我说说如何使用他的类库来进行等值面的生成。如果大家有很好的类似的库,欢迎推荐给我,谢谢。

    1:引用他的项目中的lib目录中的jar包,生成窗口对象:

      1 MapView mapView = new MapView();
      2 mapView.setBackground(new Color(255, 255, 255, 0));
      3 mapView.setBounds(0, 0, 200, 200);
      4 VectorLayer clipLayer = MapDataManage.readMapFile_ShapeFile(“d:/chengdu.shp”); //剪切图层,就是生成等值面的形状范围,
        //使用shp最方便了,这儿有一个坑,就是你是用的shp可以通过他自带的软件加载显示才行,否则程序会异常,至于为啥有的shp不能加载,我也没搞清楚
        //反正这个坑让我趟过去了。

    2:添加站点信息,用于插值

      1 StationData stationData = new StationData();
      2 //
      3 for(int i=0;i<10;i++)
      4 {
      5 stationData.addData("st"+i, 114+0.1*i, 35+0.1*i, i*10); //站点名称,经度,维度,值
      6 }

    3:设定插值参数

      1 GridDataSetting gridDataSetting = new GridDataSetting();
      2 gridDataSetting.dataExtent = clipLayer.getExtent();
      3 stationData.projInfo = clipLayer.getProjInfo();
      4 gridDataSetting.xNum = contourconfig.getGridx();// 格点点数
      5 gridDataSetting.yNum = contourconfig.getGridy();// 格点点数
      6 
      7 InterpolationSetting interSet = new InterpolationSetting();
      8 
      9 interSet.setGridDataSetting(gridDataSetting);
     10 interSet.setInterpolationMethod(InterpolationMethods.IDW_Radius);
     11 interSet.setRadius(5);
     12 interSet.setMinPointNum(1);
     13 GridData gridData = stationData.interpolateData(interSet);
     14 
     15 LegendScheme legendScheme =LegendManage.createLegendSchemeFromGridData(gridData, LegendType.UniqueValue,ShapeTypes.Polygon);
    4:插值生成图层:
      1 VectorLayer contourLayer = DrawMeteoData.createShadedLayer(gridData, legendScheme, "ContourLayer", "Data",
      2 					true);
      3 VectorLayer lastLayer = contourLayer.clip(clipLayer);
      4 mapView.addLayer(lastLayer);

    5:导出数据,可以是kml或者png之类的图片格式

      1 mapView.exportToPicture(“d:/ddd.png”); //地图导出为图片
      2 //地图导出为kml
      3 lastLayer.saveAsKMLFile(“d:/ddd.kml”);

    这是使用这个做出的效果图之一:

    2016-06-02 1658

    浏览数据秀(dataxiu.com)网站,了解更多数据可视化方法技术。

  • 相关阅读:
    Notes of Daily Scrum Meeting(12.18)
    Notes of Daily Scrum Meeting(12.17)
    Notes of Daily Scrum Meeting(12.16)
    Notes of Daily Scrum Meeting(12.8)
    Notes of Daily Scrum Meeting(12.5)
    Notes of Daily Scrum Meeting(12.3)
    Notes of Daily Scrum Meeting(11.12)
    Linux中profile、bashrc、bash_profile之间的区别和联系
    Linux GCC编译
    mysql 5.7.16 远程连接
  • 原文地址:https://www.cnblogs.com/songsgroup/p/5557833.html
Copyright © 2011-2022 走看看