shp面要素wgs84坐标转火星坐标(gcj)方法
直入正题,说一下大概思路
1.将shp转为geojson格式
2.将geojson里面的坐标串进行坐标转换
3.将转换好的新的geojson重新生成shp格式
下面我们具体说明操作步骤
1.利用https://mapshaper.org/工具,将shp转geojson
点击Export,导出geojson
2.利用JAVA+fastjson对geojson进行修改和编辑
主要代码如下:
package com.company;
import java.io.*;
import java.math.BigDecimal;
import java.util.ArrayList;import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONArray;
public class Main {public static String readJsonFile(String fileName) {String jsonStr = "";try {File jsonFile = new File(fileName);FileReader fileReader = new FileReader(jsonFile);Reader reader = new InputStreamReader(new FileInputStream(jsonFile),"utf-8");int ch = 0;StringBuffer sb = new StringBuffer();while ((ch = reader.read()) != -1) {sb.append((char) ch);}fileReader.close();reader.close();jsonStr = sb.toString();return jsonStr;} catch (IOException e) {e.printStackTrace();return null;}}public static void readJson(String jsonPath) throws IOException {String s = readJsonFile(jsonPath);//GeometryCollection geometryCollection = JSONObject.parseObject(s, GeometryCollection.class);JSONObject jobj = JSON.parseObject(s);JSONArray arr = jobj.getJSONArray("features");//构建JSONArray数组ArrayList<JSONObject> geoList=new ArrayList<JSONObject>();ArrayList<JSONObject> tobj=new ArrayList<JSONObject>();for(int i=0;i<arr.size();i++){JSONObject JO = (JSONObject)arr.get(i);JSONObject ar=(JSONObject)JO.get("geometry");if(ar==null){continue;}String typ=(String)ar.get("type");if(typ.equals("MultiPolygon")){continue;}JSONArray nar1=(JSONArray)ar.get("coordinates");JSONArray nar=(JSONArray)nar1.get(0);JSONObject pro=(JSONObject)JO.get("properties");//写jsonJSONObject polyobj = new JSONObject();//polyobj.put("coordinates",Polygon.class);String strSum="";ArrayList<double[]> corlist=new ArrayList<double[]>();ArrayList<ArrayList> t=new ArrayList<ArrayList>();if(i==2727){System.out.print(i+"xiao");}for(int j=0;j<nar.size();j++){JSONArray dt=(JSONArray)nar.get(j);System.out.print(i+"xiao"+j+'\t');//JSONArray xyArr=(JSONArray)dt.get(0);BigDecimal x1=(BigDecimal)dt.get(0);double x=x1.doubleValue();BigDecimal y2=(BigDecimal)dt.get(1);double y=y2.doubleValue();double[] dtar=WGS_Encrypt.WGS2Mars(y,x);corlist.add(dtar);}t.add(corlist);JSONObject corobj = new JSONObject();corobj.put("type","Polygon");corobj.put("coordinates",t);//geoList.add(corobj);JSONObject corobj2 = new JSONObject();corobj2.put("type","Feature");corobj2.put("geometry",corobj);corobj2.put("properties",pro);tobj.add(corobj2);//JSONArray ar=(JSONArray) arr.get(i);}//写JSONJSONObject wrobj = new JSONObject();wrobj.put("type","FeatureCollection");wrobj.put("features",tobj);String result=wrobj.toString();FileWriter fw = new FileWriter("D:\\temp\\outhfnew.json");PrintWriter out = new PrintWriter(fw);out.write(result);out.println();fw.close();out.close();}public static void main(String[] args) throws Exception {readJson("F:\\BaiduNetdiskDownload\\hfnew.json");}
}
3.形成新的geojson后,再通过https://mapshaper.org/工具,转成shp
4.用cesiumlab工具将shp转成3dtiles
5.加载数据,我们可以看到建筑面数据已经成功转换完成。
shp面要素wgs84坐标转火星坐标(gcj)方法相关推荐
- gps84转换gcj02公式_百度坐标(BD09)、国测局坐标(火星坐标,GCJ02)、和WGS84坐标系之间的转换...
//定义一些常量 var x_PI = 3.14159265358979324 * 3000.0 / 180.0; var PI = 3.1415926535897932384626; var a = ...
- 百度坐标(BD09)、国测局坐标(火星坐标,GCJ02)、和WGS84坐标系之间的相互转换
/*** Created by Wandergis on 2015/7/8.* 提供了百度坐标(BD09).国测局坐标(火星坐标,GCJ02).和WGS84坐标系之间的转换*///定义一些常量 var ...
- 前端javascript百度坐标(BD09)、国测局坐标(火星坐标,GCJ02)、和WGS84坐标系之间的转换
/*** * 提供了百度坐标(BD09).国测局坐标(火星坐标,GCJ02).和WGS84坐标系之间的转换*/ // UMD魔法代码 // if the module has no dependenc ...
- 地球坐标,火星坐标,百度坐标转换
标准地球坐标即GPS设备获得的坐标,该坐标需要经过国家测绘局进行加密后形成火星坐标(WGS-84 ),我们用的google坐标和高德地图坐标也就是火星坐标 百度地图,在火星坐标的基础上再进行一次加密, ...
- 地球坐标,火星坐标,百度坐标转换C++
标准地球坐标即GPS设备获得的坐标,该坐标需要经过国家测绘局进行加密后形成火星坐标(WGS-84 ),我们用的google坐标和高德地图坐标也就是火星坐标 百度地图,在火星坐标的基础上再进行一次加密, ...
- 百度坐标(BD09)、国测局坐标(火星坐标,GCJ02)、和WGS84坐标系互转
为什么写这个模块 随着移动互联网的兴起,几乎每一个app都会去收集用户位置,如果恰好你在处理与地理定位相关的代码,并且不了解地理坐标系的话,肯定要被我大天朝各种坐标系搞晕.写这个模块的目的也是因为项目 ...
- java 坐标转换工具类(很全面哦!wgs84.... gcj02(即火星坐标).... )
今天给大家分享一个java实现的地图坐标系经纬度转换工具类 /** Copyright (c). All rights reserved.* Use is subject to license ter ...
- 地球坐标、 火星坐标、百度坐标转换
地图的坐标系介绍 地球坐标 (WGS84) 国际标准,从 GPS 设备中取出的数据的坐标系 国际地图提供商使用的坐标系 火星坐标 (GCJ-02)也叫国测局坐标系 中国标准,从国行移动设备中定位获取的 ...
- html转换图片位置不正确的是,html5+经纬度定位不准确,html5坐标转火星坐标,百度地图Convertor.translate...
今天,我爱模板网在做APP考勤时,需要定位用户的位置,显示在地图上,于是就想到了用h5+的plus.geolocation.getCurrentPosition来获取经纬度,然后通过百度地图api将经 ...
最新文章
- pandas使用normalize函数将dataframe中的时间(time)数据列转化为日期(date)数据列(例如,从2019-12-25 11:30:00到2019-12-25)
- 三: cocos2d-x代码分析
- win10一按右键就闪屏_一步一步的详细讲解Win10磁盘分区教程
- gVim 取消自动备份(Windows/Linux)
- GPU — CUDA 编程模型
- [导入]使用RDLC报表(二)--使用自定义数据集
- python二十:内置函数
- java dictionary 实例化_Java Dictionary put()用法及代码示例
- .net三层架构开发步骤
- c# 获取电脑硬件信息通用查询类[测试通过]
- ubuntu编辑器terminator与vim
- 猴子选大王--约瑟夫问题浅析
- android文件搜索广播,Android 实现无网络传输文件
- sim卡没坏但苹果手机无服务_iPhone手机无服务那些事儿
- 阿里云的maven仓库配置
- 腾讯云超级播放器实现无直播占位图,有直播播放视频
- 竞品分析:网易云音乐和QQ音乐,音乐类app的战场
- 什么是MIMO(多输入多输出),以及MIMO的分类和测试(一)
- 必备算法基础——神经网络
- 基于linux网络流量监控与分析软件的设计与实现shell,Shell图形化监控网络流量