QGIS制作基站扇區(qū)圖層簡明教程
小何 2018/5/23
QGIS簡介
QGIS是一款免費(fèi)開源的地理信息系統(tǒng)軟件。目前最新版是QGIS3.0.3。界面基于QT開發(fā),跨平臺,可運(yùn)行于Windows、Linux、MAC等操作系統(tǒng)。還可用C++/Python做插件的二次開發(fā)。軟件自帶插件管理器,包含官方插件庫,可根據(jù)需要聯(lián)網(wǎng)下載,自動安裝。
QGIS官網(wǎng)
www.qgis.org

QGIS下載
從官網(wǎng)進(jìn)入下載頁面,選擇對應(yīng)的版本下載。現(xiàn)在操作系統(tǒng)一般是64位的,建議選擇64位下載。如果不確定,選擇32位下載。

QGIS界面
軟件的安裝、操作使用不做具體介紹,網(wǎng)上搜索有很多文章,官方也有很詳細(xì)的教程。


QGIS插件
QGIS集成插件管理,聯(lián)網(wǎng)后可用插件管理器下載、安裝、卸載、更新插件。
插件庫官網(wǎng):plugins.qgis.org/plugins


OpenLayers Plugin
用來顯示在線道路/衛(wèi)星圖層。

Shape Tools
用來制作扇區(qū)圖層。

制作基站扇區(qū)圖步驟
1. 安裝Shape Tools和OpenLayers Plugin插件

OpenLayers Plugin目前開發(fā)者正在適配QGIS3,還是試驗版本,所以插件管理器里不顯示。需要到官方插件庫下載。
下載頁面:http://plugins.qgis.org/plugins/openlayers_plugin/version/2.0.0/

打開插件管理器,從Install from ZIP安裝下載好的插件。

2. 制作基站/扇區(qū)工參csv文件
最重要的5個字段:經(jīng)緯、緯度、方位角、扇形起始角度、扇形結(jié)束角度、覆蓋半徑。其余工參字段可自行添加。經(jīng)緯度、方位角不用說都知道。
比如說某個扇區(qū)方位角是120°,想要繪制波瓣寬度是60°的扇形。那么扇形起始角度就是90,扇形結(jié)束角度就是150。室分的起始角度和結(jié)束角度建議分別為0和359。
覆蓋半徑建議用米作為單位,宏站建議200,室分建議30。

3. 添加文本數(shù)據(jù)圖層
圖層——添加圖層——添加文本數(shù)據(jù)圖層。文件名稱選擇制作好的工參。如出現(xiàn)亂碼,編碼選擇GBK。橫坐標(biāo)選擇經(jīng)度,縱坐標(biāo)選擇緯度。



4. 用shape tools插件生成扇區(qū)圖



5. 加載道路圖層或衛(wèi)星圖
注意加載圖層后,在右邊的圖層控制窗口,把加載的道路/衛(wèi)星圖調(diào)整到最底下。避免覆蓋基站扇區(qū)圖。


制作扇區(qū)專題圖層
按頻段Band舉例說明。





顯示鄰區(qū)
1. 制作帶有鄰區(qū)的工參
a) UniqueID列,表示扇區(qū)的唯一標(biāo)識符。
b) neighbors列,表示對應(yīng)扇區(qū)的鄰區(qū)列表。鄰區(qū)列表中每一個扇區(qū)的UniqueID必須要用”|”相隔。
c) 表頭必須要用UniqueID、neighbors,并且區(qū)分大小寫。后面顯示鄰區(qū)的代碼要用到。

2. 扇區(qū)圖層另存為SQLite格式的文件
a) 把shape tools插件生成的扇區(qū)圖層另存為SQLite格式的文件,并保存工程,這樣下次打開的時候也能顯示了。
b) 如果扇區(qū)圖層要給別的軟件用(如mapinfo、鼎利),扇區(qū)圖層可以另存為ESRI Shapefile格式的文件,但這種格式每個字段最多只能容納254個字符,鄰區(qū)多的時候鄰區(qū)列的字符串就被截斷了,會造成鄰區(qū)顯示不全。
c) 不同頻段/制式的扇區(qū)建議分別制作不同的工參、生成不同的扇區(qū)圖層。


3. 增加顯示鄰區(qū)動作的代碼


把以下代碼復(fù)制到動作文本框內(nèi)。
from qgis.PyQt.QtGui import QColor
from qgis.utils import iface
from qgis.gui import QgsHighlight
layer = iface.activeLayer()
layer.removeSelection()
source_fid = "[% $id %]"
source_feature = layer.getFeature(int(source_fid))
h = QgsHighlight(iface.mapCanvas(), source_feature, layer)
h.setColor(QColor('red'))
tmp = source_feature["neighbors"]
neighbors = tmp.split("|")
features = layer.getFeatures()
neighbors_fid = [f.id() for f in features if f["UniqueID"] in neighbors]
layer.select(neighbors_fid)
iface.mapCanvas().setSelectionColor(QColor("yellow"))



本文PDF下載鏈接
https://pan.baidu.com/s/1LlsnaamW_fE043rp_KxEOw
[[i] 本帖最后由 wsk170 于 2018-5-23 11:24 編輯 [/i]]