开始使用免费开始使用

导入并绘制栅格数据

在本练习中,我们将使用一份植被类型地图的栅格数据集(可从 https://www.wri.org 获取)。栅格像元是离散取值,用于指示植被类型。让我们先读取数据,并与采矿地点数据一起绘制出来。

采矿地点数据集(mining_sites)已加载,GeoPandas 和 matplotlib 也已导入。

本练习是课程的一部分

在 Python 中处理地理空间数据

查看课程

练习说明

  • 导入 rasterio 包。
  • 打开植被地图的 GeoTIFF 文件("central_africa_vegetation_map_foraf.tif"),并将其赋值给变量 src
  • 使用 rasterio.plot.show() 函数绘制该栅格数据集,并以红色、标记大小为 1 叠加绘制采矿地点位置。

交互式实操练习

通过完成这段示例代码来试试这个练习。

# Import the rasterio package
____

# Open the raster dataset
src = rasterio.____("central_africa_vegetation_map_foraf.tif")

# Import the plotting functionality of rasterio
import rasterio.plot

# Plot the raster layer with the mining sites
ax = rasterio.plot.show(____)
mining_sites.plot(____)
plt.show()
编辑并运行代码