|||
(1) 将以下代码存储为txt文件,后缀名改为html
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.3"></script>
<title>获取地区轮廓线</title>
</head>
<body>
<div id="container" style="width:100%;height:500px"></div>
<input type="text" id="districtName" onFocus="this.select()"/>
<input type="button" onclick="getBoundary()" value="获取轮廓线"/>
<textarea id="Div1" style="width:100%;height:200px"></textarea>
<script type="text/javascript">
var map = new BMap.Map("container");
map.centerAndZoom(new BMap.Point(116.403765, 39.914850), 5);
map.addControl(new BMap.NavigationControl({type: BMAP_NAVIGATION_CONTROL_SMALL}));
map.enableScrollWheelZoom();
function getBoundary()
{
var bdary = new BMap.Boundary();
var name = document.getElementById("districtName").value;
bdary.get(name, function(rs){ //获取行政区域
map.clearOverlays(); //清除地图覆盖物
var count = rs.boundaries.length; //行政区域的点有多少个
for(var i = 0; i < count; i++){
var ply = new BMap.Polygon(rs.boundaries[i], {strokeWeight: 2, strokeColor: "#ff0000"}); //建立多边形覆盖物
map.addOverlay(ply); //添加覆盖物
map.setViewport(ply.getPath()); //调整视野
}
document.getElementById('Div1').innerText = rs.boundaries;
//'{"type":"Feature","id":"0","properties":{"name":"'+name+'"},"geometry":{"type":"Polygon","coordinates":[[[' + String().replace(';','],[') + ']]}}';
});
}
</script>
</body>
</html>
(2) 打开上述html文件,就会出现百度地图的界面。在文本框输入想要的县域名称,点击获取轮廓图
(3) 打开MATLAB,创建任意变量,将上一步获取的经纬度信息赋值给MATLAB变量,通过xlswrite将数据写入excel中。
(4) 打开ArcMap,将上一步excel数据导入,接下来利用arcmap获取县域矢量边界。
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-6-17 16:13
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社