用shp制作geoJson格式地图数据(shp convert to geoJson)
本文緊接前文,簡單說明利用shp數(shù)據(jù)制作Echarts支持的geoJson格式的地圖數(shù)據(jù)。本文以北京市通州區(qū)各鎮(zhèn)的shp數(shù)據(jù)為例進行說明。
今天是香港回歸20周年之際,在這個特殊的日子,祝愿祖國繁榮昌盛,愿世界和平。
軟件環(huán)境:
ArcGIS 10.2 (ArcGIS 10.2安裝傳送門)
1. 加載數(shù)據(jù),將shp數(shù)據(jù)加載到ArcMap中
2.為shp數(shù)據(jù)增加一個name字段
由于Echarts默認以name為字段標識地區(qū)名稱,因此要為shp數(shù)據(jù)增加一個name字段,其值為各鎮(zhèn)名稱。保存數(shù)據(jù)。
3.轉(zhuǎn)化為geoJson格式
這里利用一個在線轉(zhuǎn)化工具進行數(shù)據(jù)轉(zhuǎn)換,地址:http://mapshaper.org/ ??
點擊 select 按鈕
選擇步驟1中的shp數(shù)據(jù)
點擊 Export 選擇 GeoJson 進行導出
4.引入geoJson
var mapChart;var option;//use json file to make map layer$.get('../../js/Beijing_TZQ_TOWN.json', function (beijingJson) {echarts.registerMap('北京', beijingJson); mapChart = echarts.init(document.getElementById('map-wrap')); option = {title:{text: '通州區(qū)各鎮(zhèn)人口密度圖',left: 'center'},tooltip: {trigger: 'item',formatter: '<br/>{c} (個)'},toolbox: {show: true,orient: 'vertical',left: 'right',top: 'left',feature: {dataView: {readOnly: false},restore: {},saveAsImage: {}}},visualMap: {min: 0,max: 2000,text:['高','低'],realtime: false,calculable: true,inRange: {color: ['lightskyblue','yellow', 'orangered']}},series:[{name: '通州區(qū)各鎮(zhèn)',type: 'map',map: '北京', // 自定義擴展圖表類型aspectScale: 1.0, //長寬比. default: 0.75zoom: 1.1,roam: true,itemStyle:{normal:{label:{show:true}},emphasis:{label:{show:true}}},data: [] //需要動態(tài)加載data內(nèi)容}]}mapChart.setOption(option);}); 這里特別要注意的是:series中 map屬性要為'北京',這個根據(jù)你geoJson數(shù)據(jù)所表示的地區(qū)而定,加入你制作的是西安市g(shù)eoJson數(shù)據(jù),這里map要寫'陜西',這樣初始地圖的大小才較為合適。5.最終效果
下一篇文章將對series對象的 data 屬性所需數(shù)據(jù)進行動態(tài)組織
如遇到問題,歡迎通過公眾號留言給作者,以便共同探討。
郵箱:thinkingingis@qq.com
微信公眾號:
當然本文也是支持贊賞的:)
總結(jié)
以上是生活随笔為你收集整理的用shp制作geoJson格式地图数据(shp convert to geoJson)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Spring Boot + JSP 创建
- 下一篇: Echarts动态加载地图数据(Dyna