I am currently trying to crop a raster by mask layer using the C++ GDAL API. I am using the GDALWarpOptions struct.
GDALWarpOptions *psWO = GDALCreateWarpOptions();
I then enter all the necessary options into the struct. I then pass it to a GDALWarpOperation as explained in the GDALWarp tutorial. However for the psWO->hCutline option it is necessary to transform the geometry to the raster source dataset hSrcDS. This was explained in a previous post
Cropping raster file with GDAL warp C++ API
.For this there seems to two static functions declared as:
static CPLErr
LoadCutline( const char *pszCutlineDSName, const char *pszCLayer,
const char *pszCWHERE, const char *pszCSQL,
OGRGeometryH *phCutlineRet );
static CPLErr
TransformCutlineToSource( GDALDatasetH hSrcDS, OGRGeometryH hCutline,
char ***ppapszWarpOptions, char **papszTO );
that can be found in l. 222 of gdalwarp_lib.cpp. One is for loading the cutline, the other one deals with the transformation. The issue is that the functions in this file are not exposed to the API, which leads to the question:
How should a GDALWarpOperation be carried out without access to these functions?
Should I just create my own version of TransformCutlineToSource and use that?
Is there a clear reason why TransformCutlineToSource along with the other static functions aren't included in the API?
I also have trouble understanding why there is an hCutline option in the struct and there is another CUTLINE option that is entered into the **papszWarpOptions
char array.
Is it a matter of preference which one I choose?