日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 综合教程 >内容正文

综合教程

web前端利用turf.js生成等值线、等值面

發布時間:2023/12/15 综合教程 37 生活家
生活随笔 收集整理的這篇文章主要介紹了 web前端利用turf.js生成等值线、等值面 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

樣例如下:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>等值線的生成</title>
    <link href="Script/leaflet/leaflet.css" rel="stylesheet" />
    <style>
        #map
        {
            height: 2000px;
             1500px;
        }
    </style>
    <script src="Script/leaflet/leaflet.js"></script>
    <script src="Script/leaflet/leaflet.ChineseTmsProviders.js"></script>
    <script src='https://npmcdn.com/@turf/turf/turf.min.js'></script>
</head>
<body>
    <div id="map"></div>
    
</body>
    <script>
        var normalm = L.tileLayer.chinaProvider('TianDiTu.Normal.Map', {
            maxZoom: 18,
            minZoom: 1
        }),
            normala = L.tileLayer.chinaProvider('TianDiTu.Normal.Annotion', {
                maxZoom: 18,
                minZoom: 1
            }),
            imgm = L.tileLayer.chinaProvider('TianDiTu.Satellite.Map', {
                maxZoom: 18,
                minZoom: 1
            }),
            imga = L.tileLayer.chinaProvider('TianDiTu.Satellite.Annotion', {
                maxZoom: 18,
                minZoom: 1
            });
 
        var normal = L.layerGroup([normalm, normala]);
        image = L.layerGroup([imgm, imga]);
 
        var baseLayers = {
            "地圖": normal,
            "影像": image,
        }
 
        var overlayLayers = {
            "圖": normal,
            "像": image,
        }
 
        var map = L.map("map", {
            center: [31.59, 120.29],
            zoom: 12,
            layers: [normal],
            zoomControl: false
 
        });
        // 創建等值線區域
        var extent = [0, 30, 20, 50];
        var cellWidth = 100;
        var pointGrid = turf.pointGrid(extent, cellWidth, { units: 'miles' });
 
        for (var i = 0; i < pointGrid.features.length; i++) {
            pointGrid.features[i].properties.temperature = Math.random() * 10;
        }
        console.log(pointGrid.features.length);
        //等值線的級數
        var breaks = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
 
        var lines = turf.isolines(pointGrid, breaks, { zProperty: 'temperature' });
        //設置顏色
        var myStyle = {
            "color": "#ff7800",
            "weight": 5,
            "opacity": 0.65
        };
        //進行平滑處理
            var _lFeatures = lines.features;
            for(var i=0;i<_lFeatures.length;i++){
                var _coords = _lFeatures[i].geometry.coordinates;
                var _lCoords = [];
                for(var j=0;j<_coords.length;j++){
                    var _coord = _coords[j];
                    var line = turf.lineString(_coord);
                    var curved = turf.bezierSpline(line);
                    _lCoords.push(curved.geometry.coordinates);
                }
                _lFeatures[i].geometry.coordinates = _lCoords;
            }
        //geojson數據讀取
        L.geoJSON(lines, {
            style: myStyle
        }).addTo(map);
    </script>
</html>

原文地址:https://blog.csdn.net/weixin_40184249/article/details/81198282

另外一個文章地址:http://www.cnblogs.com/naaoveGIS/p/6142226.html

總結

以上是生活随笔為你收集整理的web前端利用turf.js生成等值线、等值面的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。