跳转到主要内容

Python脚本,用于下载全球地形数字高程模型,包括SRTM 30米DEM和SRTM 90米DEM。

项目描述

全球地理高程数据变得简单。Elevation提供了下载、缓存和访问全球数据集(SRTM 30米全球1弧秒V003,由NASA和NGA编制,存储在Amazon S3SRTM 90米数字高程数据库v4.1,由CGIAR-CSI编制)的便捷方式。

请注意,分别提供者的任何下载策略均适用。

安装

从Python包索引安装Elevation的最新版本

$ pip install elevation

需要安装和运行以下依赖项

以下命令执行一些基本检查并报告常见问题。

$ eio selfcheck
Your system is ready.

GNU make、curl 和 unzip 通常预装在大多数操作系统上。安装 GDAL 命令行工具的最佳方法因操作系统和发行版而异,请参阅GDAL 安装文档

请注意,从 高程 v1.1 版本开始,仅支持 Python 3。要获取支持 Python 2 的最新版本,请使用 pip install elevation=1.0.6

命令行使用

使用 eio 命令识别感兴趣区域的地理边界并获取 DEM。例如,要将罗马(约 41.9N 12.5E)的 SRTM 30m DEM 剪切到 Rome-30m-DEM.tif 文件。

$ eio clip -o Rome-30m-DEM.tif --bounds 12.35 41.8 12.65 42

对于 SRTM 90m DEM,使用

$ eio --product SRTM3 clip -o Rome-90m-DEM.tif --bounds 12.35 41.8 12.65 42

--bounds 选项接受纬度和经度坐标(对于关心的人来说,更精确的是在 WGS84 参考系统 EPSG:4326 的地心坐标系中)以 左下右上 的顺序给出,类似于 rio 命令的 rasterio 格式。

如果您已安装了 rasteriofiona 软件包,您可以在 GDAL 和 OGR 支持的任何其他地理空间数据源的相同范围内剪切 DEM,例如,如果您有一个地理参照图像 MyImage.tif,您可以使用以下命令剪切相应的 DEM:

$ eio clip -o MyImage-DEM.tif --reference MyImage.tif  # enable with: $ pip install rasterio

--reference 选项也可以接受矢量数据作为输入。

$ eio clip -o MyShapefile-DEM.tif --reference MyShapefile.shp  # enable with: $ pip install fiona

第一次访问某个区域时,Elevation 从美国地质调查局或 CGIAR-CSI 服务器下载数据瓦片,并以 GeoTiff 压缩格式缓存它们,对相同和附近区域的后续访问速度要快得多。

clip 子命令不允许自动下载大量 DEM 瓦片,请参考上游提供者的网站以了解批量下载的首选程序。

要清理过时的临时文件和在服务器错误的情况下修复缓存,请使用

$ eio clean

命令行参考

eio 命令有以下子命令和选项

$ Usage: eio [OPTIONS] COMMAND [ARGS]...

Options:
  --version                Show the version and exit.
  --product [SRTM1|SRTM3]  DEM product choice.  [default: SRTM1]
  --cache_dir DIRECTORY    Root of the DEM cache folder.  [default:
                           /Users/amici/Library/Caches/elevation]
  --help                   Show this message and exit.

Commands:
  clean      Clean up the product cache from temporary files.
  clip       Clip the DEM to given bounds.
  distclean  Remove the product cache entirely.
  info       Show info about the product cache.
  seed       Seed the DEM to given bounds.
  selfcheck  Audit the system for common issues.

clip 子命令

$ eio clip --help
Usage: eio clip [OPTIONS]

Options:
  -o, --output PATH     Path to output file. Existing files will be
                        overwritten.  [default: out.tif]
  --bounds FLOAT...     Output bounds in 'left bottom right top' order.
  -m, --margin TEXT     Decimal degree margin added to the bounds. Use '%' for
                        percent margin.  [default: 0]
  -r, --reference TEXT  Use the extent of a reference GDAL/OGR data source as
                        output bounds.
  --help                Show this message and exit.

可以通过设置以 EIO 为前缀的环境变量来定义默认值,例如 EIO_PRODUCT=SRTM3EIO_CLIP_MARGIN=10%

Python API

每个命令在 elevation 模块中都有一个对应的 API 函数。

>>> import elevation
>>> # clip the SRTM1 30m DEM of Rome and save it to Rome-DEM.tif
>>> elevation.clip(bounds=(12.35, 41.8, 12.65, 42), output='Rome-DEM.tif')
>>> # clean up stale temporary files and fix the cache in the event of a server error
>>> elevation.clean()

项目资源

文档

http://elevation.bopen.eu

支持

https://stackoverflow.com/search?q=python+elevation

开发

https://github.com/bopen/elevation

下载

https://pypi.ac.cn/project/elevation

代码质量

Coverage status on Codecov

贡献

非常欢迎贡献。请参阅CONTRIBUTING 文档,了解最佳帮助方式。如果您遇到任何问题,请提交一个问题,并附上详细描述。

作者

许可证

Elevation 是免费且开源的软件,根据Apache 许可证 2.0 版本分发。

项目详情


下载文件

下载适用于您平台的文件。如果您不确定选择哪一个,请了解更多关于安装包的信息。

源代码分发

elevation-1.1.3.tar.gz (27.3 kB 查看哈希值)

上传时间 源代码

构建分发

elevation-1.1.3-py3-none-any.whl (17.0 kB 查看哈希值)

上传时间 Python 3

支持