[gdal-dev] Utilities as a library, C API
Even Rouault
even.rouault at spatialys.com
Thu Oct 20 13:26:12 PDT 2016
On Thursday 20 October 2016 15:03:03 Ivan Lucena wrote:
> Hi Even,
>
>
> OK. It is what it is. I guess.
>
>
> I wrote a little test code:
>
>
> #include <gdal.h>
> #include <gdal_utils.h>
>
> int main( int argc, char** argv )
> {
> char* papszArgv[1024];
> int i = 0;
>
> const char* pszSrcFilename = "rgbsmall.tif";
> const char* pszDstFilename = "test90.tif";
>
> GDALDatasetH hSrcDataset = NULL;
> GDALDatasetH hDstDataset = NULL;
>
> GDALTranslateOptions* psOptions = NULL;
>
> GDALAllRegister();
>
> papszArgv[i++] = "-of";
> papszArgv[i++] = "GTIFF";
>
> papszArgv[i++] = "-b";
> papszArgv[i++] = "3";
>
> papszArgv[i++] = "-b";
> papszArgv[i++] = "2";
>
> papszArgv[i++] = "-b";
> papszArgv[i++] = "1";
>
> papszArgv[i++] = "-srcwin";
> papszArgv[i++] = "10";
> papszArgv[i++] = "10";
> papszArgv[i++] = "30";
> papszArgv[i++] = "30";
>
> papszArgv[i++] = "-co";
> papszArgv[i++] = "BLOCKXSIZE=4";
>
> papszArgv[i++] = "-co";
> papszArgv[i++] = "BLOCKYSIZE=4";
>
> papszArgv[i++] = NULL;
>
> psOptions = GDALTranslateOptionsNew( papszArgv, NULL );
>
> hSrcDataset = GDALOpen( pszSrcFilename, GA_ReadOnly );
>
> hDstDataset = GDALTranslate( pszDstFilename, hSrcDataset, psOptions, NULL
> );
>
> GDALTranslateOptionsFree( psOptions );
>
> GDALClose( hSrcDataset );
>
> GDALClose( hDstDataset );
> }
>
>
> And I can say that it does work as expected. Maybe we should put that
> example somewhere on the wiki.
>
>
> I found to interesting issues. That is just a C application using the GDAL C
> API but I could only compile with g++, not with gcc.
Could you be more specific about the error you got ? It should be usable from
pure C, but I'm not 100% positive this has been tested
> The GTIFF create-option BLOCKXSIZE doesn't seems to work. I tries with
> larger images and it seems like we can only control the number of rows on a
> block (BLOCKYSIZE), but not the number of columns (BLOCKXSIZE).
BLOCKXSIZE is only taken into account if you also define TILED=YES.
Even
--
Spatialys - Geospatial professional services
http://www.spatialys.com
More information about the gdal-dev
mailing list