Giter VIP home page Giter VIP logo

Comments (2)

xiangyuecn avatar xiangyuecn commented on June 25, 2024

除了ok_geo.csv文件比较大之外,应该不存在什么格式转换难题。前提条件是对目标格式的具体语法非常了解。

可以先把csv转换成你所用语言好处理的中间格式,比如json,再去转换成目标格式。

  1. 转换成中间格式,可以参考测试和WEB数据格式转换工具.js中对csv转成js对象的代码(适用于ok_geo):
    //解析csv数据
    var lines=txt.split("\n");
    var list=[];
    var mapping={"0":{level:0,childs:[]}};
    var arr=lines[0].split(",");
    if(arr.length!=8 || arr[0]!="id"){
    return Result("粘贴csv数据不合法");
    };
    for(var i=1;i<lines.length;i++){
    var line=lines[i];
    if(line){
    var arr=line.split(",");
    if(arr.length!=8){
    return Result("粘贴csv数据第"+(i+1)+"行不合法");
    };
    var itm={
    id:+arr[0]
    ,pid:+arr[1]
    ,level:-1
    ,name:arr[3].replace(/""/g,'"').replace(/^"|"$/g,'')
    ,pinyin:arr[4].replace(/""/g,"").replace(/^"|"$/g,'')
    ,childs:[]
    };
    list.push(itm);
  2. 转换成目标格式,比如:geojsonshp格式,中间格式好处理的数据已经有了,根据目标格式的具体语法把数据填充过去就ok啦。

由于不知道geojsonshp格式的具体语法,第二步需要自己去摸索。geojson格式应该比较简单,shp二进制格式就难说了。


要是确实搞不定,还有一个简单方法,可以参考:

通过下列语句生成geometry对象,polygon有可能是POLYGON,也有可能是MULTIPOLYGON,只能通过运算才能知道正确结果
全局表##tb_polygon中包含所有的数据,通过id来关联到ok_data数据所在的表(比如把数据update过去)
```SQL
--drop table ##tb_polygon
create table ##tb_polygon(
id int
,name ntext
,geo geometry

直接把ok_geo.csv数据导入数据库,用sql将坐标文本转换成空间数据,然后再尝试数据库里面转换成需要的格式。

from areacity-jsspider-statsgov.

Inblac avatar Inblac commented on June 25, 2024

谢谢,我尝试看看。

from areacity-jsspider-statsgov.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.