从AWS下载和合并mapzen地形图块geotiffs的基本工具

terraincache的Python项目详细描述


水磨石

一个(又一个)基本Python脚本,用于从AWS下载和访问Mapzen Terrain Tilesgeotiffs。旨在与rasterio集成,并提供一个熟悉的命令行工具,用于快速重新投影下载。在

安装

pip install terraincache

设置TERRAINCACHE环境变量以保存键入:

^{pr2}$

使用

Python模块

from matplotlib import pyplot as plt
import rasterio

from terraincache import TerrainTiles

bounds =[-125.2714, 51.3706, -125.2547, 51.3768]

# Initialize with bounds and zoom of interest
tt = TerrainTiles(bounds, 11)

# load to numpy array
array = tt.load()

# plot the array directly
plt.imshow(array, cmap='terrain', extent=bounds)

alt text

转储到文件并使用rasterio.plot.show()打印数组(对于正确的轴标签):

tt.save(out_file="dem.tif")
with rasterio.open("dem.tif", "r") as src:
    fig, ax = plt.subplots()
    rasterio.plot.show(src, ax=ax, title='terrain-tiles', cmap="terrain")

alt text

CLI

$ terraincache --help
Usage: terraincache [OPTIONS]

  Write terrain tiles to geotiff

Options:
  -o, --out_file, --out-file PATH
                                  Output file name/path
  --bounds TEXT                   Bounds: "left bottom right top" or "[left,
                                  bottom, right, top]".  [required]
  -z, --zoom INTEGER              Web map zoom level  [required]
  -p, --cache-dir, --cache_dir TEXT
                                  Path to cache folder
  -tr, --resolution FLOAT         Output dataset target resolution in meters
                                  (square pixels)
  --bounds-crs, --bounds_crs TEXT
                                  CRS of provided bounds
  --dst-crs, --dst_crs TEXT       Target coordinate reference system.
  -r, --resampling_algorithm [bilinear|nearest|cubic|cubicspline|lanczos|average|mode]
                                  GDAL resampling algorithm
  -v, --verbose                   Increase verbosity.
  -q, --quiet                     Decrease verbosity.
  --help                          Show this message and exit.

例如,围绕费尔威瑟山山顶(BC/AK边界)创建一个与BC TRIM DEM对齐的geotiff。请注意,这几乎肯定是对可用数据进行上采样,请参阅下面的链接以查看源解析。在

terraincache \
  --bounds "336637.5, 1597112.5, 346637.5, 1607112.5" \
  --bounds-crs EPSG:3005 \
  --zoom 11 \
  -tr 25 \
  -r bilinear \
  -o dem.tif

数据源

参见data sources reference document

学分/其他实施

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java Admob不使用webview   Java Wicket表单:序列化对象类“myClassName”时出错   java googledriveapi更新文件与我的帐户管理员   java简单框架未知xml标记解析   java如何使用主类和用户获取Spark应用程序ID   java如何更改自定义属性的值?   java有没有办法在jMock中找到未使用的期望值?   gradle运行任务的java文档?   java通过使用数组来存储文本文件的行,通过覆盖来删除文本文件中的行   用于表达式语言注入的java利用负载   java IDEStyle程序运行   java在运行时启用/禁用Springws   爪哇芦苇。formatNumber NullPointException   java为什么我的代码无法检测两个动态实体之间的碰撞?