ubuntu20.04安装QGIS
0.引言
1.QGIS install
Note:这种方法安装的是最新版本,可能会有一些兼容问题。我这里是卸载了重新安装,卸载参考,删不干净,最后手动 搜索并收删除相关文件。然后直接使用命令行安装,自动适配:sudo apt install -f qgis qgis-plugin-grass
官方安装方式:
安装依赖项
sudo apt install gnupg software-properties-common
安装 QGIS 签名密钥,信任并安装 QGIS 存储库的 QGIS 软件:
sudo mkdir -m755 -p /etc/apt/keyrings # not needed since apt version 2.4.0 like Debian 12 and Ubuntu 22 or newer sudo wget -O /etc/apt/keyrings/qgis-archive-keyring.gpg https://download.qgis.org/downloads/qgis-archive-keyring.gpg
查看 your-distributions-codename:
lsb_release -cs
将最新稳定版 QGIS (3.36.x Maidenhead) 的 QGIS 存储库添加到
/etc/apt/sources.list.d/qgis.sources
:Types: deb deb-src URIs: https://qgis.org/debian #这个也行https://download.qgis.org/ubuntugis-ltr #Suites: your-distributions-codename Suites: focal Architectures: amd64 Components: main Signed-By: /etc/apt/keyrings/qgis-archive-keyring.gpg
更新存储库
sudo apt update
安装QGIS:
sudo apt install qgis qgis-plugin-grass qgis-server
Note:这种方法安装的是最新版本,可能会有一些兼容问题。我这里是卸载了重新安装,卸载参考,删不干净,最后手动 搜索并收删除相关文件。然后直接使用命令行安装,自动适配:sudo apt install -f qgis qgis-plugin-grass
2.插件
(1) tiandi-tool
报错:
无法加载插件“tianditu-tools”因在调用其classFactory()方法时发生错误 AttributeError: type object 'Qt' has no attribute 'MarkdownText'
ref 解决 : pip3 install PyQt5==5.15.6
- 报错:
无法加载SIP模块。 Python支持将被禁用。
ref 解决:python -m pip uninstall pyqt5 pyqt5-sip qtconsole
3.简单教程
瓦片连接如下:
高德矢量:http://webrd01.is.autonavi.com/appmaptile?x={x}&y={y}&z={z}&lang=zh_cn&size=1&scale=1&style=8
高德影像:https://webst01.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}
腾讯影像(更正:http://rt0.map.gtimg.com/realtimerender?z={z}&x={x}&y={-y}&type=vector&style=0
OSM矢量(已失效):https://tile.openstreetmap.org/{z}/{x}/{y}.png
4.加载自己数据
将 SLAM 结果转换为 geojson 格式:
import json
# 读取原始 JSON 文件
with open('optimized_keyframe_poses.json', 'r') as f:
data = json.load(f)
# 转换为新的格式
features = []
for item in data:
geometry = {
"type": "Point",
"coordinates": [item['pose']['trans'][0], item['pose']['trans'][1]]
}
properties = {
"id": item['idx'],
"stamp": item['timestamp']
}
feature = {
"type": "Feature",
"geometry": geometry,
"properties": properties
}
features.append(feature)
# 构建最终的 GeoJSON 结构
geojson = {
"type": "FeatureCollection",
"name": "track",
"features": features
}
# 将转换后的结果保存为新的文件
with open('optimized_keyframe_poses_geo.json', 'w') as f:
json.dump(geojson, f, indent=2)
加载自己数据进行投影: