GDALWarp()解析

2023-04-12  本文已影响0人  NullUser

基本

在gdal_utils.h中提供GDALWarp()接口对图像进行重投影和变换。

/**
 * Image reprojection and warping function.
 *
 * This is the equivalent of the <a href="/programs/gdalwarp.html">gdalwarp</a> utility.
 *
 * GDALWarpAppOptions* must be allocated and freed with GDALWarpAppOptionsNew()
 * and GDALWarpAppOptionsFree() respectively.
 * pszDest and hDstDS cannot be used at the same time.
 *
 * @param pszDest the destination dataset path or NULL.
 * @param hDstDS the destination dataset or NULL.
 * @param nSrcCount the number of input datasets.
 * @param pahSrcDS the list of input datasets.
 * @param psOptionsIn the options struct returned by GDALWarpAppOptionsNew() or NULL.
 * @param pbUsageError pointer to a integer output variable to store if any usage error has occurred, or NULL.
 * @return the output dataset (new dataset that must be closed using GDALClose(), or hDstDS if not NULL) or NULL in case of error.
 *
 * @since GDAL 2.1
 */

GDALDatasetH GDALWarp( const char *pszDest, GDALDatasetH hDstDS,
                       int nSrcCount,
                       GDALDatasetH *pahSrcDS,
                       const GDALWarpAppOptions *psOptionsIn,
                       int *pbUsageError );

参数

该接口除了输入输出等基本参数外,栅格化的具体参数都放入了形参const GDALWarpAppOptions *psOptionsIn中,而参数形式同GDAL App中的gdal_warp相同(gdal_warp)
设置参数可参考:

    char** papszArgv = nullptr;
    papszArgv = CSLAddString(papszArgv, "-t_srs");
    papszArgv = CSLAddString(papszArgv, "EPSG:4326");
    GDALWarpAppOptions* options = GDALWarpAppOptionsNew(papszArgv, nullptr);
    CSLDestroy(papszArgv);
gdalwarp in_red.tif out_rgb.tif -srcband 1 -dstband 1
gdalwarp in_green.tif out_rgb.tif -srcband 1 -dstband 2
gdalwarp in_blue.tif out_rgb.tif -srcband 1 -dstband 3
上一篇 下一篇

猜你喜欢

热点阅读