Windows安装Rust版本GDAL

前言

笔者想安装GDAL,这是一个开源的地理数据库,

笔者到处搜索,最后看到这位大佬写的这篇文章,终于成功了。

aliothor/Windows-Install-Rust-Gdal-Tutorial: Windows Install Rust Version Gdal Stepshttps://github.com/aliothor/Windows-Install-Rust-Gdal-Tutorial

Windows安装Rust版本GDAL - 知乎https://zhuanlan.zhihu.com/p/655508921

正文

首先,需要安装Rust的环境,如下参考

安装 Rust - Rust 程序设计语言https://www.rust-lang.org/zh-CN/tools/install安装 - Cargo 手册 中文版https://rustwiki.org/zh-CN/cargo/getting-started/installation.html安装完成后

下载GDAL

进入下面的网址

GISInternals Support Sitehttps://www.gisinternals.com/release.php截止到目前是3.10.0,笔者下载如下两个压缩报

下载完成后,解压到同一个目录下

设置环境变量

打开环境变量,在path中

设置如下两个变量,

复制代码
C:\OSGeo4W\bin\gdal\apps
C:\OSGeo4W

设置GDAL_LIB_DIR

复制代码
C:\OSGeo4W\lib

设置PKG_CONFIG_PATH

复制代码
C:\OSGeo4W

下载window pkg-config

下载并安装choco

Releases · chocolatey/chocohttps://github.com/chocolatey/choco/releases管理员的权限下,运行

复制代码
choco install pkgconfiglite

运行后, 笔者安装在C:\ProgramData\chocolatey\lib目录下的

查看gdal版本

笔者是3.10.0

创建gdal.pc文件

在解压目录下,笔者是C:/OSGeo4W

写下如下内容

复制代码
name=gdal
prefix=/usr
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${exec_prefix}/include
datadir=${prefix}/share/${name}

Name: lib${name}
Description: Geospatial Data Abstraction Library
Version: 3.10.0
Libs: -L${libdir} -l${name}
Cflags: -I${includedir}/${name}

版本不同,Version不同。

简单使用

经过前面这些操作,就可以使用了

创建一个项目,添加依赖gdal依赖

georust/gdal: Rust bindings for GDALhttps://github.com/georust/gdal

通过下面的网址,随便下载一个地方的geojson

DataV.GeoAtlas地理小工具系列https://datav.aliyun.com/portal/school/atlas/area_selector下载完成后,运行如下代码

复制代码
use gdal::Dataset;

fn main() {
    let ds=Dataset::open("成都市.geojson").unwrap();
    println!("Driver: {}", ds.driver().long_name());
}

结果如下

哈哈哈哈哈哈

相关推荐
superman超哥8 小时前
Serde 性能优化的终极武器
开发语言·rust·编程语言·rust serde·serde性能优化·rust开发工具
sayang_shao14 小时前
Rust多线程编程学习笔记
笔记·学习·rust
鸿乃江边鸟21 小时前
Spark Datafusion Comet 向量化Rust Native--读数据
rust·spark·native·arrow
硬汉嵌入式21 小时前
基于Rust构建的单片机Ariel RTOS,支持Cortex-M、RISC-V 和 Xtensa
单片机·rust·risc-v
低调滴开发2 天前
Tauri开发桌面端服务,配置指定防火墙端口
rust·tauri·桌面端·windows防火墙规则
咚为2 天前
Rust Cell使用与原理
开发语言·网络·rust
咸甜适中2 天前
rust的docx-rs库,自定义docx模版批量生成docx文档(逐行注释)
开发语言·rust·docx·docx-rs
FAFU_kyp3 天前
RISC0_ZERO项目在macOs上生成链上证明避坑
开发语言·后端·学习·macos·rust
古城小栈3 天前
开发常用 宏
算法·rust
咸甜适中3 天前
rust的docx-rs库读取docx文件中的文本内容(逐行注释)
开发语言·rust·docx·docx-rs