首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PyGeoprocessing库中允许对光栅值进行重分类的函数是什么?

PyGeoprocessing库中允许对光栅值进行重分类的函数是什么?
EN

Stack Overflow用户
提问于 2020-04-14 19:58:32
回答 1查看 63关注 0票数 0

我正在尝试使用QGIS重分类按表对栅格值进行重分类,但它正在下降。我偶然发现了PyGeoprocessing库,显然它比R重分类函数快得多。但是,我在任何地方都找不到这个库的文档和教程。

谢谢你的帮助

EN

回答 1

Stack Overflow用户

发布于 2020-11-11 06:10:23

PyGeoProcessing的重分类函数称为reclassify_raster,可以这样调用:

代码语言:javascript
复制
import pygeoprocessing
from osgeo import gdal

raster_path = 'the/path/to/your/input/raster.tif'

# You'll need to load your source and destination pixel values into a dictionary
# like this.  Oftentimes, this will be loaded in from a table.
reclassification_map = {
    1: 0.35
    2: 0.6
}


pygeoprocessing.reclassify_raster(
    (raster_path, 1),  # Use band 1
    reclassification_map,
    'reclassified.tif',
    gdal.GDT_Float32,  # You could use any gdal.GDT_* datatype, this example just uses Float32
    target_nodata=-1  # You could set the nodata value to whatever you wanted it to be
)

It's possible that the maintainers might release some API documentation, but until they do that, you can always just take a look at the function docstrings.  `reclassify_raster`, for example, is found in this file: https://github.com/natcap/pygeoprocessing/blob/main/src/pygeoprocessing/geoprocessing.py
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61207136

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档