跳转至

开源地理信息教程

参考

  1. GitHub - ceholden/open-geo-tutorial: Tutorial of basic remote sensing and GIS methodologies using open source software (GDAL in Python or R)
  2. GitHub - patrickcgray/open-geo-tutorial: Tutorial of fundamental remote sensing and GIS methodologies using open source software in python

1 Windows 安装 GDAL

官网:GISInternals Support Site -GDAL

pypi | GDAL 官网:https://pypi.org/project/GDAL/

1.1 可能遇到的问题

安装 GDAL 库时出现:

1
error in GDAL setup command: use_2to3 is invalid.

因为:History - setuptools 58.0.0. documentation (pypa.io)

setuptools 58.0.0 版本中,移除了对 use_2to3 的支持,所以我们需要安装前一个版本

1
2
pip install setuptools==57.5.0
pip install setuptools==49.6.0
1
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/ 

参考:

  1. Microsoft Visual C++ 14.0 is required解决方法 - 知乎 (zhihu.com)
  2. Microsoft Visual C++ 14.0 is required._哈哈哈,冲冲冲的博客-CSDN博客
1
conda install libpython m2w64-toolchain -c msys2

解决方案:python3.9安装gdal库(便捷版)_python3.9 gdal_橙色的小太阳的博客-CSDN博客

whl安装包下载地址:Releases · cgohlke/geospatial-wheels (github.com)

2 配置开发环境

2.1 配置虚拟环境

创建虚拟环境

1
conda create -n open-geo python=3.8 -y

激活环境

1
conda activate open-geo

安装 mamba 包管理器

1
conda install -c conda-forge mamba -y

为 jupyterlab 配置运行环境

1
mamba install -c conda-forge jupyterlab jupyterlab-language-pack-zh-CN -y

如果后续出问题,可以直接移除虚拟环境

1
conda remove -n open-geo --all

2.2 安装 VS C++ 生成工具

参考:【已解决】error: Microsoft Visual C++ 14.0 or greater is required_ViatorSun的博客-CSDN博客

官网下载:Microsoft C++ Build Tools - Visual Studio

image-20230528143409438

选择 Visual C++ 生成工具进行安装即可

image-20230528144140873

Microsoft Visual C++ 14.0 is required._哈哈哈,冲冲冲的博客-CSDN博客

2.3 安装 GDAL 与 rasterio

rasterio 是一个 python 看栅格图像的包,依赖于 GDAL 库。

1
2
3
4
5
6
7
8
9
numpy==1.20.2
geopandas==0.9.0
fiona==1.8.18
rasterio==1.2.3
descartes==1.1.0
scikit-learn==1.0.2
click==7.1.2
seaborn==0.12.2
tensorflow==2.10.0
1
pip install -r requirements.txt

2.3 安装机器学习相关库

1
pip install geopandas descartes scikit-learn

2.4 安装深度学习库

1
pip install tensorflow
1


最后更新: 2023-06-07
创建日期: 2023-04-25
作者: gis-xh