网站首页 > 开源技术 正文
TIN Terrain是HERE Technologies公司开源的一款地形处理工具,github地址https://github.com/heremaps/tin-terrain。
TIN Terrain
TIN-Terrain是一个命令行工具,用于将GeoTIFF格式的高度图转换为具有不同尺度的瓦片(不规则三角网, TIN)。
特征
- 以带有高度图heightmap的GeoTIFF作为输入
- 将高度图转换为具有给定最大误差参数的三角网网格,并输出为.obj格式
- 将高度图转换为给定缩放范围的瓦片化的TIN网格,并将瓦片金字塔输出为quantized-mesh-1.0 地形格式
让我们知道你是怎么想的
如果你提交一份简短的匿名调查,你可以帮助我们优先处理tin-terrain中的问题
安装
您可以使用Docker或直接在系统上构建和运行此工具。使用Docker构建更简单,可以在macOS、Linux和Windows上运行。
各平台的详细说明如下:
在Docker上构建
The provided Dockerfile builds the TIN Terrain executable on Ubuntu Linux.
提供的Dockerfile在Ubuntu Linux上构建TIN Terrain可执行文件
构建container,执行:
./build-docker.sh
从Docker运行TIN-Terrain:
docker run -v [local data directory]:/data:cached --name tin-terrain --rm -i -t tin-terrain tin-terrain ...
其中[本地数据目录]是包含DEM文件并将接收输出文件的文件夹。这将映射到Docker实例中的/data,因此您应该使用:
docker run -v [local data directory]:/data:cached --name tin-terrain --rm -i -t tin-terrain tin-terrain dem2tin --input /data/... --output /data/...
或者,使用
docker run -v [local data directory]:/data:cached --name tin-terrain --rm -i -t tin-terrain bash
to open an interactive shell which lets you execute tin-terrain and access /data. Any files not stored in /data will be lost when closing the session.
打开一个交互式shell,它允许您执行ttin-terrain和访问 /data 目录。关闭会话时,任何未存储在//data 目录中的文件都将丢失
先决条件和依赖项
如果选择直接在系统上编译和运行“TIN Terrain”,请注意,必须在系统上安装以下软件包:
- The C++ standard library from the compiler (tested with clang 9.1.0 and gcc 7.3.0)
- Boost (BSL-1.0) program_options, filesystem, system (tested with version 1.67)
- GDAL (MIT) gdal, gdal_priv, cpl_conv (tested with version 2.3)
在CMake配置阶段,TIN Terrain还下载了一些第三方库的源代码:
- libfmt (BSD-2-Clause)
- glm (MIT)
- Catch2 (BSL-1.0)
生成项目/生成文件时,可以通过将 -DTNTN_DOWNLOAD_DEPS=OFF选项传递给CMake来禁用此行为。如果这样做,则必须自己下载依赖项,并且如果要运行测试,还必须将TNTN_LIBGLM_SOURCE_DIR和tntntn_LIBFMT_SOURCE_DIR变量传递给CMake以及tntntn_CATCH2_SOURCE_DIR。
请参阅download-deps.cmake查看详细版本信息
在macOS上构建
- 安装依赖项:
brew install boost
brew install cmake
brew install gdal
2.创建xcode工程:
mkdir build-cmake-xcode
cd build-cmake-xcode
cmake -GXcode path/to/sourcecode/
open tin-terrain.xcodeproj
- 构建tin-terrain
生成的二进制文件将位于Debug/Release子目录中
要运行测试,请生成并运行tntn-tests
可能与GDAL相关的问题
如果您的机器上存在另一个版本的GDAL,如果通过homebrew 安装(或任何其他首选方法),cmake提供的FindGDAL.cmake可能无法正确检测到GDAL的最新版本。
无论是否是这种情况,都可以很容易地检测到,如果链接步骤在编译时出错,就链接GDAL
因此,您可能需要将cmake引导到GDAL的正确位置:
cmake -GXcode -DGDAL_LIBRARY=PATH/TO/GDAL/LIB path/to/sourcecode/
e.g
cmake -GXcode -DGDAL_LIBRARY=/usr/local/Cellar/gdal/2.3.1_2/lib/libgdal.dylib path/to/sourcecode/
在linux上构建
- 安装依赖, e.g.Ubuntu:
apt-get install build-essential cmake libboost-all-dev libgdal-dev
2.创建Makefile:
mkdir build-cmake-release
cd build-cmake-release
cmake -DCMAKE_BUILD_TYPE=Release path/to/sourcecode/
- 构建tin-terrain
VERBOSE=1 make tin-terrain
生成的二进制文件应该准备好了。要运行测试,请生成并运行tntn-tests:
VERBOSE=1 make tntn-tests
The resulting binary should then be ready. To run the tests, build and run the tntn-tests target:
- 重建Makefile (并设置 TNTN_TEST=ON):
cd build-cmake-release
cmake -DTNTN_TEST=ON -DCMAKE_BUILD_TYPE=Debug path/to/sourcecode/
- 构建 tntn-tests
VERBOSE=1 make tntn-tests
用法
tin-terrain 命令行工具有几个子命令。您可以运行tin terrain--help查看所有可用的子命令
$ tin-terrain --help
usage:
tin-terrain [OPTION]... <subcommand> ...
Global Options:
-h [ --help ] print this help message
--log arg (=stdout) diagnostics output/log target, can be stdout,
stderr, or none
-v [ --verbose ] [=arg(=1)] be more verbose
--subcommand arg command to execute
--subargs arg arguments for command
available subcommands:
dem2tin - convert a DEM into a mesh/tin
dem2tintiles - convert a DEM into mesh/tin tiles
benchmark - run all available meshing methods on a given set of input files and produce statistics (performance, error rate)
version - print version information
投影
tin-terrain要求数据集是Web Mercator投影(EPSG:3857). 如果你的数据集不在这个投影中,你可以很容易地用gdalwarp重新投影你的数据集
gdalwarp -t_srs EPSG:3857 ned19_n37x75_w122x50_ca_goldengate_2010.img ned19_n37x75_w122x50_ca_goldengate_2010_mercator.tif
创建简单网格/三角网
可以使用dem2tin子命令将栅格的高度图转换为OBJ格式的单个大网格/TIN。
您可以通过运行tin-terrain dem2tin--help 查看所有可用选项。
$ tin-terrain dem2tin --help
usage:
tin-terrain dem2tin [OPTIONS]...
dem2tin options:
--input arg input filename
--input-format arg (=auto) input file format, can be any of: auto, asc, xyz,
tiff
--output arg output filename
--output-format arg (=auto) output file format, can be any of: auto, obj,
off, terrain (quantized mesh), json/geojson
--method arg (=terra) meshing method, valid values are: terra, zemlya and dense
--max-error arg (terra & zemlya) maximum geometric error
--step arg (=1) (dense) grid spacing in pixels
methods:
terra - implements a delaunay based triangulation with point selection using a fast greedy insert mechnism
reference: Garland, Michael, and Paul S. Heckbert. "Fast polygonal approximation of terrains and height fields." (1995).
paper: https://mgarland.org/papers/scape.pdf
and http://mgarland.org/archive/cmu/scape/terra.html
zemlya - hierarchical greedy insertion
reference: Zheng, Xianwei, et al. "A VIRTUAL GLOBE-BASED MULTI-RESOLUTION TIN SURFACE MODELING AND VISUALIZETION METHOD." International Archives of the Photogrammetry, Remote Sensing & Spatial Information Sciences 41 (2016).
paper: https://www.int-arch-photogramm-remote-sens-spatial-inf-sci.net/XLI-B2/459/2016/isprs-archives-XLI-B2-459-2016.pdf
dense - generates a simple mesh grid from the raster input by placing one vertex per pixel
例如,您可以运行以下命令来将“ned19_n37x75_w122x50_ca_goldengate_2010_mercator..tif“转换为于单个大网格,其中最大误差参数为2.0米:
tin-terrain dem2tin --input /data/ned19_n37x75_w122x50_ca_goldengate_2010_mercator.tif --output /data/terrain.obj --max-error 2.0
运行此命令后,同一目录中您应该看到“terrain.obj“的输出文件。这个OBJ文件包含生成的网格。
max error参数指定以米为单位的垂直误差容限,因此max error参数越小,输出网格中的三角形越多,网格质量越好,运行时间越长
创建金字塔网格/TIN瓦片
dem2tintiles子命令将栅格高度图作为输入,并为给定的缩放范围创建三角网网格瓦片。输出瓦片可以是OBJ格式,也可以是quantized-mesh-1.0 的地形格式。
您可以通过运行tin-errain dem2tiniles--help查看所有可用选项
$ tin-terrain dem2tintiles --help
usage:
tin-terrain dem2tintiles [OPTION]...
dem2tintiles options:
--input arg input filename
--output-dir arg (=./output)
--max-zoom arg (=-1) maximum zoom level to generate tiles for. will
guesstimate from resolution if not provided.
--min-zoom arg (=-1) minimum zoom level to generate tiles for will
guesstimate from resolution if not provided.
--max-error arg (terra or zemlya) max error when using
--step arg (=1) (dense) grid spacing in pixels
--output-format arg (=terrain) output tiles in terrain (quantized mesh) or
obj
--method arg (=terra) meshing algorithm. one of: terra, zemlya or dense
For example, you can run the following command to convert "ned19_n37x75_w122x50_ca_goldengate_2010_mercator.tif" to a pyramid of mesh tiles.
例如,您可以运行以下命令来将“ned19_n37x75_w122x50_ca_goldengate_2010_mercator.tif“转换为金字塔瓦片集。
tin-terrain dem2tintiles --input /data/ned19_n37x75_w122x50_ca_goldengate_2010_mercator.tif --output-dir /data/output --min-zoom 5 --max-zoom 14 --output-format=terrain --max-error 2.0
When this command finishes running, you should see an output folder containing all the mesh tiles, organized into a pyramid of subfolders.
当这个命令完成运行时,您应该会看到一个包含所有瓦片的输出文件夹,它被组织成一个由子文件夹组成的金字塔。
├── 10
│ ├── 163
│ │ ├── 627.terrain
│ │ └── 628.terrain
│ └── 164
│ ├── 627.terrain
│ └── 628.terrain
...
文件夹结构遵循地图约定: Z/X/Y.terrain.
然后,这些网格分片可以很容易地从web服务器提供服务,并被前端应用程序用于地形可视化等目的。
样本数据集
当您在CMake配置中启用TNTN_TEST和TNTN_DOWNLOAD_DEPS选项时,一些示例数据集将下载到${CMake_SOURCE_DIR}/3rdparty/文件夹中。
例如,您将在${CMAKE_SOURCE_DIR}/3rdparty/carterlake文件夹中找到 crater lake数据集。此数据集由美国地质调查局(USGS)创建和维护,可从http://oe.oregonexplorer.info/carterlake/下载。
要从该数据集生成网格,首先需要使用GDAL安装附带的gdalwarp命令行工具将其重新投影到Web Mercator投影
gdalwarp -t_srs EPSG:3857 -r cubic -of GTiff -ot Float32 dems_10m.dem dems_10m.tif
然后,可以在此重新投影的GeoTIFF文件上运行tin terrain以创建网格:
./tin-terrain dem2tin --input dems_10m.tif --output terrain.obj --max-error 2.0 --method terra
License
Copyright (C) 2018 HERE Europe B.V.
有关许可证的详细信息,请参阅此项目根目录中的许可证文件。
论文
某些算法基于以下论文:
- Garland, Michael, and Paul S. Heckbert. "Fast polygonal approximation of terrains and height fields." (1995).
- Zheng, Xianwei, et al. "A VIRTUAL GLOBE-BASED MULTI-RESOLUTION TIN SURFACE MODELING AND VISUALIZETION METHOD." International Archives of the Photogrammetry, Remote Sensing & Spatial Information Sciences 41 (2016).
猜你喜欢
- 2024-10-22 Blazor流程编排的艺术:深入Z.Blazor.Diagrams库的使用与实践
- 2024-10-22 个性化地图制作软件OpenOrienteering Mapper
- 2024-10-22 使用 .NET 的 Dev Proxy 构建和测试弹性应用
- 2024-10-22 开发一个现代化的.NetCore控制台程序,包含依赖注入/配置/日志等要素
- 2024-10-22 .NET 配置体系结构(配置.net环境)
- 2024-10-22 西门子高级应用,将WinCC集成在STEP 7中,你也可以学会!
- 2024-10-22 OpenShift 4 之 GitOps(1)安装ArgoCD环境
- 2024-10-22 OpenLayers helloworld 以及加载天地图图层示例
- 2024-10-22 Python利用WKT创建shapefile、shapefile输出WKT
- 2024-10-22 OpenFaaS实战之四:模板(template)
你 发表评论:
欢迎- 最近发表
- 标签列表
-
- jdk (81)
- putty (66)
- rufus (78)
- 内网穿透 (89)
- okhttp (70)
- powertoys (74)
- windowsterminal (81)
- netcat (65)
- ghostscript (65)
- veracrypt (65)
- asp.netcore (70)
- wrk (67)
- aspose.words (80)
- itk (80)
- ajaxfileupload.js (66)
- sqlhelper (67)
- express.js (67)
- phpmailer (67)
- xjar (70)
- redisclient (78)
- wakeonlan (66)
- tinygo (85)
- startbbs (72)
- webftp (82)
- vsvim (79)
本文暂时没有评论,来添加一个吧(●'◡'●)