[gdal-dev] Additional arguments in gdal driver.CreateCopy function
Even Rouault
even.rouault at spatialys.com
Fri Apr 22 11:51:38 PDT 2016
Le vendredi 22 avril 2016 20:10:48, Didier Bernard a écrit :
> Hello,
>
> I would like to create a new .tif file in GDAL C# by using the
> driver.CreateCopy<http://www.gdal.org/classGDALDriver.html#a2c897da2a6e251
> 69cccc49ef48797ce1> function. I have been reading gdal tutorial
> page<http://www.gdal.org/gdal_tutorial.html> and it looks like the python
> version of driver.CreateCopy function supports the use of additional
> arguments. For example, it supports using 'TILED=YES' argument:
>
> src_ds = gdal.Open( src_filename )
>
> dst_ds = driver.CreateCopy( dst_filename, src_ds, 0,
> [ 'TILED=YES', 'COMPRESS=PACKBITS' ] )
>
> I assume this means it can also support an argument like: "-outsize 50%
> 50%" ?
No, -outsize is an argument specific to gdal_translate. CreateCopy() only
accept driver specific creation options.
If you use GDAL 2.1.0, you can use it in gdal.Translate(). It is available in
Python. See for example test_gdal_translate_lib_7() of
https://svn.osgeo.org/gdal/trunk/autotest/utilities/test_gdal_translate_lib.py
The widthPct/heightPct are syntaxic sugar of Python bindings.
Not completely sure however how ready the C# bindings of gdal.Translate() are.
I presume that might be pretty raw. Something like (you will certainly need to
fix it to be correct C#) :
gdal.GDALTranslateOptions options = new gdal.GDALTranslateOptions( new
String[] { "-outsize", "50%", "50%" } );
gdal.wrapper_GDALTranslate("out.tif", src_ds, options);
Don't ask me more about C# bindings ;-)
>
>
> If this is so, then how can I use the same argument ("-outsize 50% 50%") in
> C# version of driver.CreateCopy function? Something like:
>
> driver.CreateCopy(filePath, dataset, False, "-outsize 50% 50%", null,
> null);
>
> ?
>
> Thank you.
>
> Didier
--
Spatialys - Geospatial professional services
http://www.spatialys.com
More information about the gdal-dev
mailing list