我正在尝试使用QGIS重分类按表对栅格值进行重分类,但它正在下降。我偶然发现了PyGeoprocessing库,显然它比R重分类函数快得多。但是,我在任何地方都找不到这个库的文档和教程。
谢谢你的帮助
发布于 2020-11-11 06:10:23
PyGeoProcessing的重分类函数称为reclassify_raster,可以这样调用:
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.pyhttps://stackoverflow.com/questions/61207136
复制相似问题