Changes between Version 2 and Version 3 of rfc59.1_utilities_as_a_library


Ignore:
Timestamp:
Oct 2, 2015, 9:51:36 AM (9 years ago)
Author:
Even Rouault
Comment:

Update with gdal.TranslateOptions() change + add gdal.Warp()

Legend:

Unmodified
Added
Removed
Modified
  • rfc59.1_utilities_as_a_library

    v2 v3  
    8585}}}
    8686
     87Similarly for GDALWarp():
     88
     89{{{
     90/*! Options for GDALWarp(). Opaque type */
     91typedef struct GDALWarpAppOptions GDALWarpAppOptions;
     92
     93typedef struct GDALWarpAppOptionsForBinary GDALWarpAppOptionsForBinary;
     94
     95GDALWarpAppOptions CPL_DLL *GDALWarpAppOptionsNew(char** papszArgv,
     96                                                      GDALWarpAppOptionsForBinary* psOptionsForBinary);
     97
     98void CPL_DLL GDALWarpAppOptionsFree( GDALWarpAppOptions *psOptions );
     99
     100void CPL_DLL GDALWarpAppOptionsSetProgress( GDALWarpAppOptions *psOptions,
     101                                              GDALProgressFunc pfnProgress,
     102                                              void *pProgressData );
     103void CPL_DLL GDALWarpAppOptionsSetWarpOption( GDALWarpAppOptions *psOptions,
     104                                              const char* pszKey,
     105                                              const char* pszValue );
     106
     107GDALDatasetH CPL_DLL GDALWarp( const char *pszDest, GDALDatasetH hDstDS, int nSrcCount,
     108                               GDALDatasetH *pahSrcDS,
     109                               const GDALWarpAppOptions *psOptions, int *pbUsageError );
     110}}}
     111
    87112== SWIG bindings (Python / Java / C# / Perl) changes ==
    88113
     
    136161}}}
    137162
     163{{{
     164struct GDALWarpAppOptions {
     165%extend {
     166    GDALWarpAppOptions(char** options) {
     167        return GDALWarpAppOptionsNew(options, NULL);
     168    }
     169
     170    ~GDALWarpAppOptions() {
     171        GDALWarpAppOptionsFree( self );
     172    }
     173}
     174};
     175
     176/* Note: we must use 2 distinct names since there's a bug/feature in swig */
     177/* that doesn't play nicely with the (int object_list_count, GDALDatasetShadow** poObjects) input typemap */
     178
     179%inline %{
     180int wrapper_GDALWarpDestDS( GDALDatasetShadow* dstDS,
     181                            int object_list_count, GDALDatasetShadow** poObjects,
     182                            GDALWarpAppOptions* warpAppOptions,
     183                            GDALProgressFunc callback=NULL,
     184                            void* callback_data=NULL)
     185{
     186    int usageError; /* ignored */
     187    GDALWarpAppOptionsSetProgress(warpAppOptions, callback, callback_data);
     188    return GDALWarp(NULL, dstDS, object_list_count, poObjects, warpAppOptions, &usageError) != NULL;
     189}
     190%}
     191
     192%newobject wrapper_GDALWarpDestName;
     193
     194%inline %{
     195GDALDatasetShadow* wrapper_GDALWarpDestName( const char* dest,
     196                                             int object_list_count, GDALDatasetShadow** poObjects,
     197                                             GDALWarpAppOptions* warpAppOptions,
     198                                             GDALProgressFunc callback=NULL,
     199                                             void* callback_data=NULL)
     200{
     201    int usageError; /* ignored */
     202    GDALWarpAppOptionsSetProgress(warpAppOptions, callback, callback_data);
     203    return GDALWarp(dest, NULL, object_list_count, poObjects, warpAppOptions, &usageError);
     204}
     205%}
     206}}}
     207
    138208For Python bindings, convenience wrappers are created to allow specifying options in a more
    139209user friendly way.
     
    163233def TranslateOptions(options = [], format = 'GTiff',
    164234              outputType = GDT_Unknown, bandList = None, maskBand = None,
    165               oXSizePixel = 0, oYSizePixel = 0, oXSizePct = 0.0, oYSizePct = 0.0,
     235              width = 0, height = 0, widthPct = 0.0, heightPct = 0.0,
    166236              xRes = 0.0, yRes = 0.0,
    167237              creationOptions = None, srcWin = None, projWin = None, projWinSRS = None, strict = False,
    168238              unscale = False, scaleParams = None, exponents = None,
    169               assignedULLR = None, metadataOptions = None,
     239              outputBounds = None, metadataOptions = None,
    170240              outputSRS = None, GCPs = None,
    171241              noData = None, rgbExpand = None,
    172               stats = False, rat = True, resampling = None,
     242              stats = False, rat = True, resampleAlg = None,
    173243              callback = None, callback_data = None):
    174244    """ Create a TranslateOptions() object that can be passed to gdal.Translate()
     
    179249          bandList --- array of band numbers (index start at 1)
    180250          maskBand --- mask band to generate or not ("none", "auto", "mask", 1, ...)
    181           oXSizePixel --- width of the output raster in pixel
    182           oYSizePixel --- height of the output raster in pixel
    183           oXSizePct --- width of the output raster in percentage (100 = original size)
    184           oYSizePct --- height of the output raster in percentage (100 = original size)
     251          width --- width of the output raster in pixel
     252          height --- height of the output raster in pixel
     253          widthPct --- width of the output raster in percentage (100 = original width)
     254          heightPct --- height of the output raster in percentage (100 = original height)
    185255          xRes --- output horizontal resolution
    186256          yRes --- output vertical resolution
     
    193263          scaleParams --- list of scale parameters, each of the form [src_min,src_max] or [src_min,src_max,dst_min,dst_max]
    194264          exponents --- list of exponentation parameters
    195           assignedULLR --- assigned output bounds: [ulx, uly, lrx, lry]
     265          outputBounds --- assigned output bounds: [ulx, uly, lrx, lry]
    196266          metadataOptions --- list of metadata options
    197267          outputSRS --- assigned output SRS
     
    201271          stats --- whether to calcule statistics
    202272          rat --- whether to write source RAT
    203           resampling --- resampling mode
     273          resampleAlg --- resampling mode
    204274          callback --- callback method
    205275          callback_data --- user data for callback
    206        """
     276    """
    207277
    208278def Translate(destName, srcDS, **kwargs):
     
    217287}}}
    218288
     289
     290{{{
     291
     292def WarpOptions(options = [], format = 'GTiff',
     293         outputBounds = None,
     294         outputBoundsSRS = None,
     295         xRes = None, yRes = None, targetAlignedPixels = False,
     296         width = 0, height = 0,
     297         srcSRS = None, dstSRS = None,
     298         srcAlpha = False, dstAlpha = False,
     299         warpOptions = None, errorThreshold = None,
     300         warpMemoryLimit = None, creationOptions = None, outputType = GDT_Unknown,
     301         workingType = GDT_Unknown, resampleAlg = None,
     302         srcNodata = None, dstNodata = None, multithread = False,
     303         tps = False, rpc = False, geoloc = False, polynomialOrder = None,
     304         transformerOptions = None, cutlineDSName = None,
     305         cutlineLayer = None, cutlineWhere = None, cutlineSQL = None, cutlineBlend = None, cropToCutline = False,
     306         copyMetadata = True, metadataConflictValue = None,
     307         setColorInterpretation = False,
     308         callback = None, callback_data = None):
     309    """ Create a WarpOptions() object that can be passed to gdal.Warp()
     310        Keyword arguments are :
     311          options --- can be be an array of strings, a string or let empty and filled from other keywords.
     312          format --- output format ("GTiff", etc...)
     313          outputBounds --- output bounds as (minX, minY, maxX, maxY) in target SRS
     314          outputBoundsSRS --- SRS in which output bounds are expressed, in the case they are not expressed in dstSRS
     315          xRes, yRes --- output resolution in target SRS
     316          targetAlignedPixels --- whether to force output bounds to be multiple of output resolution
     317          width --- width of the output raster in pixel
     318          height --- height of the output raster in pixel
     319          srcSRS --- source SRS
     320          dstSRS --- output SRS
     321          srcAlpha --- whether to force the last band of the input dataset to be considered as an alpha band
     322          dstAlpha --- whether to force the creation of an output alpha band
     323          outputType --- output type (gdal.GDT_Byte, etc...)
     324          workingType --- working type (gdal.GDT_Byte, etc...)
     325          warpOptions --- list of warping options
     326          errorThreshold --- error threshold for approximation transformer (in pixels)
     327          warpMemoryLimit --- size of working buffer in bytes
     328          resampleAlg --- resampling mode
     329          creationOptions --- list of creation options
     330          srcNodata --- source nodata value(s)
     331          dstNodata --- output nodata value(s)
     332          multithread --- whether to multithread computation and I/O operations
     333          tps --- whether to use Thin Plate Spline GCP transformer
     334          rpc --- whether to use RPC transformer
     335          geoloc --- whether to use GeoLocation array transformer
     336          polynomialOrder --- order of polynomial GCP interpolation
     337          transformerOptions --- list of transformer options
     338          cutlineDSName --- cutline dataset name
     339          cutlineLayer --- cutline layer name
     340          cutlineWhere --- cutline WHERE clause
     341          cutlineSQL --- cutline SQL statement
     342          cutlineBlend --- cutline blend distance in pixels
     343          cropToCutline --- whether to use cutline extent for output bounds
     344          copyMetadata --- whether to copy source metadata
     345          metadataConflictValue --- metadata data conflict value
     346          setColorInterpretation --- whether to force color interpretation of input bands to output bands
     347          callback --- callback method
     348          callback_data --- user data for callback
     349    """
     350
     351def Warp(destNameOrDestDS, srcDSOrSrcDSTab, **kwargs):
     352    """ Warp one or several datasets.
     353        Arguments are :
     354          destNameOrDestDS --- Output dataset name or object
     355          srcDSOrSrcDSTab --- an array of Dataset objects or filenames, or a Dataset object or a filename
     356        Keyword arguments are :
     357          options --- return of gdal.InfoOptions(), string or array of strings
     358          other keywords arguments of gdal.WarpOptions()
     359        If options is provided as a gdal.WarpOptions() object, other keywords are ignored. """
     360}}}
     361
    219362gdal.Info() can be used either with setting the attributes of gdal.InfoOptions() or inlined arguments of gdal.Info().
    220363Arguments can be specified as array of strings, command line syntax or dedeicated keywords.