gdal_alg.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  1. /******************************************************************************
  2. * $Id: gdal_alg.h 27850 2014-10-12 16:58:09Z rouault $
  3. *
  4. * Project: GDAL Image Processing Algorithms
  5. * Purpose: Prototypes, and definitions for various GDAL based algorithms.
  6. * Author: Frank Warmerdam, warmerdam@pobox.com
  7. *
  8. ******************************************************************************
  9. * Copyright (c) 2001, Frank Warmerdam
  10. * Copyright (c) 2008-2012, Even Rouault <even dot rouault at mines-paris dot org>
  11. *
  12. * Permission is hereby granted, free of charge, to any person obtaining a
  13. * copy of this software and associated documentation files (the "Software"),
  14. * to deal in the Software without restriction, including without limitation
  15. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  16. * and/or sell copies of the Software, and to permit persons to whom the
  17. * Software is furnished to do so, subject to the following conditions:
  18. *
  19. * The above copyright notice and this permission notice shall be included
  20. * in all copies or substantial portions of the Software.
  21. *
  22. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  23. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  24. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  25. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  26. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  27. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  28. * DEALINGS IN THE SOFTWARE.
  29. ****************************************************************************/
  30. #ifndef GDAL_ALG_H_INCLUDED
  31. #define GDAL_ALG_H_INCLUDED
  32. /**
  33. * \file gdal_alg.h
  34. *
  35. * Public (C callable) GDAL algorithm entry points, and definitions.
  36. */
  37. #ifndef DOXYGEN_SKIP
  38. #include "gdal.h"
  39. #include "cpl_minixml.h"
  40. #include "ogr_api.h"
  41. #endif
  42. CPL_C_START
  43. int CPL_DLL CPL_STDCALL GDALComputeMedianCutPCT( GDALRasterBandH hRed,
  44. GDALRasterBandH hGreen,
  45. GDALRasterBandH hBlue,
  46. int (*pfnIncludePixel)(int,int,void*),
  47. int nColors,
  48. GDALColorTableH hColorTable,
  49. GDALProgressFunc pfnProgress,
  50. void * pProgressArg );
  51. int CPL_DLL CPL_STDCALL GDALDitherRGB2PCT( GDALRasterBandH hRed,
  52. GDALRasterBandH hGreen,
  53. GDALRasterBandH hBlue,
  54. GDALRasterBandH hTarget,
  55. GDALColorTableH hColorTable,
  56. GDALProgressFunc pfnProgress,
  57. void * pProgressArg );
  58. int CPL_DLL CPL_STDCALL GDALChecksumImage( GDALRasterBandH hBand,
  59. int nXOff, int nYOff, int nXSize, int nYSize );
  60. CPLErr CPL_DLL CPL_STDCALL
  61. GDALComputeProximity( GDALRasterBandH hSrcBand,
  62. GDALRasterBandH hProximityBand,
  63. char **papszOptions,
  64. GDALProgressFunc pfnProgress,
  65. void * pProgressArg );
  66. CPLErr CPL_DLL CPL_STDCALL
  67. GDALFillNodata( GDALRasterBandH hTargetBand,
  68. GDALRasterBandH hMaskBand,
  69. double dfMaxSearchDist,
  70. int bDeprecatedOption,
  71. int nSmoothingIterations,
  72. char **papszOptions,
  73. GDALProgressFunc pfnProgress,
  74. void * pProgressArg );
  75. CPLErr CPL_DLL CPL_STDCALL
  76. GDALPolygonize( GDALRasterBandH hSrcBand,
  77. GDALRasterBandH hMaskBand,
  78. OGRLayerH hOutLayer, int iPixValField,
  79. char **papszOptions,
  80. GDALProgressFunc pfnProgress,
  81. void * pProgressArg );
  82. CPLErr CPL_DLL CPL_STDCALL
  83. GDALFPolygonize( GDALRasterBandH hSrcBand,
  84. GDALRasterBandH hMaskBand,
  85. OGRLayerH hOutLayer, int iPixValField,
  86. char **papszOptions,
  87. GDALProgressFunc pfnProgress,
  88. void * pProgressArg );
  89. CPLErr CPL_DLL CPL_STDCALL
  90. GDALSieveFilter( GDALRasterBandH hSrcBand, GDALRasterBandH hMaskBand,
  91. GDALRasterBandH hDstBand,
  92. int nSizeThreshold, int nConnectedness,
  93. char **papszOptions,
  94. GDALProgressFunc pfnProgress,
  95. void * pProgressArg );
  96. /*
  97. * Warp Related.
  98. */
  99. typedef int
  100. (*GDALTransformerFunc)( void *pTransformerArg,
  101. int bDstToSrc, int nPointCount,
  102. double *x, double *y, double *z, int *panSuccess );
  103. #define GDAL_GTI2_SIGNATURE "GTI2"
  104. typedef struct {
  105. GByte abySignature[4];
  106. const char *pszClassName;
  107. GDALTransformerFunc pfnTransform;
  108. void (*pfnCleanup)( void * pTransformerArg );
  109. CPLXMLNode *(*pfnSerialize)( void * pTransformerArg );
  110. void* (*pfnCreateSimilar)( void* pTransformerArg, double dfSrcRatioX, double dfSrcRatioY );
  111. } GDALTransformerInfo;
  112. void CPL_DLL GDALDestroyTransformer( void *pTransformerArg );
  113. int CPL_DLL GDALUseTransformer( void *pTranformerArg,
  114. int bDstToSrc, int nPointCount,
  115. double *x, double *y, double *z,
  116. int *panSuccess );
  117. void* GDALCreateSimilarTransformer( void* psTransformerArg, double dfSrcRatioX, double dfSrcRatioY );
  118. /* High level transformer for going from image coordinates on one file
  119. to image coordiantes on another, potentially doing reprojection,
  120. utilizing GCPs or using the geotransform. */
  121. void CPL_DLL *
  122. GDALCreateGenImgProjTransformer( GDALDatasetH hSrcDS, const char *pszSrcWKT,
  123. GDALDatasetH hDstDS, const char *pszDstWKT,
  124. int bGCPUseOK, double dfGCPErrorThreshold,
  125. int nOrder );
  126. void CPL_DLL *
  127. GDALCreateGenImgProjTransformer2( GDALDatasetH hSrcDS, GDALDatasetH hDstDS,
  128. char **papszOptions );
  129. void CPL_DLL *
  130. GDALCreateGenImgProjTransformer3( const char *pszSrcWKT,
  131. const double *padfSrcGeoTransform,
  132. const char *pszDstWKT,
  133. const double *padfDstGeoTransform );
  134. void CPL_DLL GDALSetGenImgProjTransformerDstGeoTransform( void *,
  135. const double * );
  136. void CPL_DLL GDALDestroyGenImgProjTransformer( void * );
  137. int CPL_DLL GDALGenImgProjTransform(
  138. void *pTransformArg, int bDstToSrc, int nPointCount,
  139. double *x, double *y, double *z, int *panSuccess );
  140. void GDALSetTransformerDstGeoTransform( void *, const double * );
  141. /* Geo to geo reprojection transformer. */
  142. void CPL_DLL *
  143. GDALCreateReprojectionTransformer( const char *pszSrcWKT,
  144. const char *pszDstWKT );
  145. void CPL_DLL GDALDestroyReprojectionTransformer( void * );
  146. int CPL_DLL GDALReprojectionTransform(
  147. void *pTransformArg, int bDstToSrc, int nPointCount,
  148. double *x, double *y, double *z, int *panSuccess );
  149. /* GCP based transformer ... forward is to georef coordinates */
  150. void CPL_DLL *
  151. GDALCreateGCPTransformer( int nGCPCount, const GDAL_GCP *pasGCPList,
  152. int nReqOrder, int bReversed );
  153. /* GCP based transformer with refinement of the GCPs ... forward is to georef coordinates */
  154. void CPL_DLL *
  155. GDALCreateGCPRefineTransformer( int nGCPCount, const GDAL_GCP *pasGCPList,
  156. int nReqOrder, int bReversed, double tolerance, int minimumGcps);
  157. void CPL_DLL GDALDestroyGCPTransformer( void *pTransformArg );
  158. int CPL_DLL GDALGCPTransform(
  159. void *pTransformArg, int bDstToSrc, int nPointCount,
  160. double *x, double *y, double *z, int *panSuccess );
  161. /* Thin Plate Spine transformer ... forward is to georef coordinates */
  162. void CPL_DLL *
  163. GDALCreateTPSTransformer( int nGCPCount, const GDAL_GCP *pasGCPList,
  164. int bReversed );
  165. void CPL_DLL GDALDestroyTPSTransformer( void *pTransformArg );
  166. int CPL_DLL GDALTPSTransform(
  167. void *pTransformArg, int bDstToSrc, int nPointCount,
  168. double *x, double *y, double *z, int *panSuccess );
  169. char CPL_DLL ** RPCInfoToMD( GDALRPCInfo *psRPCInfo );
  170. /* RPC based transformer ... src is pixel/line/elev, dst is long/lat/elev */
  171. void CPL_DLL *
  172. GDALCreateRPCTransformer( GDALRPCInfo *psRPC, int bReversed,
  173. double dfPixErrThreshold,
  174. char **papszOptions );
  175. void CPL_DLL GDALDestroyRPCTransformer( void *pTransformArg );
  176. int CPL_DLL GDALRPCTransform(
  177. void *pTransformArg, int bDstToSrc, int nPointCount,
  178. double *x, double *y, double *z, int *panSuccess );
  179. /* Geolocation transformer */
  180. void CPL_DLL *
  181. GDALCreateGeoLocTransformer( GDALDatasetH hBaseDS,
  182. char **papszGeolocationInfo,
  183. int bReversed );
  184. void CPL_DLL GDALDestroyGeoLocTransformer( void *pTransformArg );
  185. int CPL_DLL GDALGeoLocTransform(
  186. void *pTransformArg, int bDstToSrc, int nPointCount,
  187. double *x, double *y, double *z, int *panSuccess );
  188. /* Approximate transformer */
  189. void CPL_DLL *
  190. GDALCreateApproxTransformer( GDALTransformerFunc pfnRawTransformer,
  191. void *pRawTransformerArg, double dfMaxError );
  192. void CPL_DLL GDALApproxTransformerOwnsSubtransformer( void *pCBData,
  193. int bOwnFlag );
  194. void CPL_DLL GDALDestroyApproxTransformer( void *pApproxArg );
  195. int CPL_DLL GDALApproxTransform(
  196. void *pTransformArg, int bDstToSrc, int nPointCount,
  197. double *x, double *y, double *z, int *panSuccess );
  198. int CPL_DLL CPL_STDCALL
  199. GDALSimpleImageWarp( GDALDatasetH hSrcDS,
  200. GDALDatasetH hDstDS,
  201. int nBandCount, int *panBandList,
  202. GDALTransformerFunc pfnTransform,
  203. void *pTransformArg,
  204. GDALProgressFunc pfnProgress,
  205. void *pProgressArg,
  206. char **papszWarpOptions );
  207. CPLErr CPL_DLL CPL_STDCALL
  208. GDALSuggestedWarpOutput( GDALDatasetH hSrcDS,
  209. GDALTransformerFunc pfnTransformer,
  210. void *pTransformArg,
  211. double *padfGeoTransformOut,
  212. int *pnPixels, int *pnLines );
  213. CPLErr CPL_DLL CPL_STDCALL
  214. GDALSuggestedWarpOutput2( GDALDatasetH hSrcDS,
  215. GDALTransformerFunc pfnTransformer,
  216. void *pTransformArg,
  217. double *padfGeoTransformOut,
  218. int *pnPixels, int *pnLines,
  219. double *padfExtents,
  220. int nOptions );
  221. CPLXMLNode CPL_DLL *
  222. GDALSerializeTransformer( GDALTransformerFunc pfnFunc, void *pTransformArg );
  223. CPLErr CPL_DLL GDALDeserializeTransformer( CPLXMLNode *psTree,
  224. GDALTransformerFunc *ppfnFunc,
  225. void **ppTransformArg );
  226. CPLErr CPL_DLL
  227. GDALTransformGeolocations( GDALRasterBandH hXBand,
  228. GDALRasterBandH hYBand,
  229. GDALRasterBandH hZBand,
  230. GDALTransformerFunc pfnTransformer,
  231. void *pTransformArg,
  232. GDALProgressFunc pfnProgress,
  233. void *pProgressArg,
  234. char **papszOptions );
  235. /* -------------------------------------------------------------------- */
  236. /* Contour Line Generation */
  237. /* -------------------------------------------------------------------- */
  238. typedef CPLErr (*GDALContourWriter)( double dfLevel, int nPoints,
  239. double *padfX, double *padfY, void * );
  240. typedef void *GDALContourGeneratorH;
  241. GDALContourGeneratorH CPL_DLL
  242. GDAL_CG_Create( int nWidth, int nHeight,
  243. int bNoDataSet, double dfNoDataValue,
  244. double dfContourInterval, double dfContourBase,
  245. GDALContourWriter pfnWriter, void *pCBData );
  246. CPLErr CPL_DLL GDAL_CG_FeedLine( GDALContourGeneratorH hCG,
  247. double *padfScanline );
  248. void CPL_DLL GDAL_CG_Destroy( GDALContourGeneratorH hCG );
  249. typedef struct
  250. {
  251. void *hLayer;
  252. double adfGeoTransform[6];
  253. int nElevField;
  254. int nIDField;
  255. int nNextID;
  256. } OGRContourWriterInfo;
  257. CPLErr CPL_DLL
  258. OGRContourWriter( double, int, double *, double *, void *pInfo );
  259. CPLErr CPL_DLL
  260. GDALContourGenerate( GDALRasterBandH hBand,
  261. double dfContourInterval, double dfContourBase,
  262. int nFixedLevelCount, double *padfFixedLevels,
  263. int bUseNoData, double dfNoDataValue,
  264. void *hLayer, int iIDField, int iElevField,
  265. GDALProgressFunc pfnProgress, void *pProgressArg );
  266. /************************************************************************/
  267. /* Rasterizer API - geometries burned into GDAL raster. */
  268. /************************************************************************/
  269. CPLErr CPL_DLL
  270. GDALRasterizeGeometries( GDALDatasetH hDS,
  271. int nBandCount, int *panBandList,
  272. int nGeomCount, OGRGeometryH *pahGeometries,
  273. GDALTransformerFunc pfnTransformer,
  274. void *pTransformArg,
  275. double *padfGeomBurnValue,
  276. char **papszOptions,
  277. GDALProgressFunc pfnProgress,
  278. void * pProgressArg );
  279. CPLErr CPL_DLL
  280. GDALRasterizeLayers( GDALDatasetH hDS,
  281. int nBandCount, int *panBandList,
  282. int nLayerCount, OGRLayerH *pahLayers,
  283. GDALTransformerFunc pfnTransformer,
  284. void *pTransformArg,
  285. double *padfLayerBurnValues,
  286. char **papszOptions,
  287. GDALProgressFunc pfnProgress,
  288. void *pProgressArg );
  289. CPLErr CPL_DLL
  290. GDALRasterizeLayersBuf( void *pData, int nBufXSize, int nBufYSize,
  291. GDALDataType eBufType, int nPixelSpace, int nLineSpace,
  292. int nLayerCount, OGRLayerH *pahLayers,
  293. const char *pszDstProjection,
  294. double *padfDstGeoTransform,
  295. GDALTransformerFunc pfnTransformer,
  296. void *pTransformArg, double dfBurnValue,
  297. char **papszOptions, GDALProgressFunc pfnProgress,
  298. void *pProgressArg );
  299. /************************************************************************/
  300. /* Gridding interface. */
  301. /************************************************************************/
  302. /** Gridding Algorithms */
  303. typedef enum {
  304. /*! Inverse distance to a power */ GGA_InverseDistanceToAPower = 1,
  305. /*! Moving Average */ GGA_MovingAverage = 2,
  306. /*! Nearest Neighbor */ GGA_NearestNeighbor = 3,
  307. /*! Minimum Value (Data Metric) */ GGA_MetricMinimum = 4,
  308. /*! Maximum Value (Data Metric) */ GGA_MetricMaximum = 5,
  309. /*! Data Range (Data Metric) */ GGA_MetricRange = 6,
  310. /*! Number of Points (Data Metric) */ GGA_MetricCount = 7,
  311. /*! Average Distance (Data Metric) */ GGA_MetricAverageDistance = 8,
  312. /*! Average Distance Between Data Points (Data Metric) */
  313. GGA_MetricAverageDistancePts = 9
  314. } GDALGridAlgorithm;
  315. /** Inverse distance to a power method control options */
  316. typedef struct
  317. {
  318. /*! Weighting power. */
  319. double dfPower;
  320. /*! Smoothing parameter. */
  321. double dfSmoothing;
  322. /*! Reserved for future use. */
  323. double dfAnisotropyRatio;
  324. /*! Reserved for future use. */
  325. double dfAnisotropyAngle;
  326. /*! The first radius (X axis if rotation angle is 0) of search ellipse. */
  327. double dfRadius1;
  328. /*! The second radius (Y axis if rotation angle is 0) of search ellipse. */
  329. double dfRadius2;
  330. /*! Angle of ellipse rotation in degrees.
  331. *
  332. * Ellipse rotated counter clockwise.
  333. */
  334. double dfAngle;
  335. /*! Maximum number of data points to use.
  336. *
  337. * Do not search for more points than this number.
  338. * If less amount of points found the grid node considered empty and will
  339. * be filled with NODATA marker.
  340. */
  341. GUInt32 nMaxPoints;
  342. /*! Minimum number of data points to use.
  343. *
  344. * If less amount of points found the grid node considered empty and will
  345. * be filled with NODATA marker.
  346. */
  347. GUInt32 nMinPoints;
  348. /*! No data marker to fill empty points. */
  349. double dfNoDataValue;
  350. } GDALGridInverseDistanceToAPowerOptions;
  351. /** Moving average method control options */
  352. typedef struct
  353. {
  354. /*! The first radius (X axis if rotation angle is 0) of search ellipse. */
  355. double dfRadius1;
  356. /*! The second radius (Y axis if rotation angle is 0) of search ellipse. */
  357. double dfRadius2;
  358. /*! Angle of ellipse rotation in degrees.
  359. *
  360. * Ellipse rotated counter clockwise.
  361. */
  362. double dfAngle;
  363. /*! Minimum number of data points to average.
  364. *
  365. * If less amount of points found the grid node considered empty and will
  366. * be filled with NODATA marker.
  367. */
  368. GUInt32 nMinPoints;
  369. /*! No data marker to fill empty points. */
  370. double dfNoDataValue;
  371. } GDALGridMovingAverageOptions;
  372. /** Nearest neighbor method control options */
  373. typedef struct
  374. {
  375. /*! The first radius (X axis if rotation angle is 0) of search ellipse. */
  376. double dfRadius1;
  377. /*! The second radius (Y axis if rotation angle is 0) of search ellipse. */
  378. double dfRadius2;
  379. /*! Angle of ellipse rotation in degrees.
  380. *
  381. * Ellipse rotated counter clockwise.
  382. */
  383. double dfAngle;
  384. /*! No data marker to fill empty points. */
  385. double dfNoDataValue;
  386. } GDALGridNearestNeighborOptions;
  387. /** Data metrics method control options */
  388. typedef struct
  389. {
  390. /*! The first radius (X axis if rotation angle is 0) of search ellipse. */
  391. double dfRadius1;
  392. /*! The second radius (Y axis if rotation angle is 0) of search ellipse. */
  393. double dfRadius2;
  394. /*! Angle of ellipse rotation in degrees.
  395. *
  396. * Ellipse rotated counter clockwise.
  397. */
  398. double dfAngle;
  399. /*! Minimum number of data points to average.
  400. *
  401. * If less amount of points found the grid node considered empty and will
  402. * be filled with NODATA marker.
  403. */
  404. GUInt32 nMinPoints;
  405. /*! No data marker to fill empty points. */
  406. double dfNoDataValue;
  407. } GDALGridDataMetricsOptions;
  408. CPLErr CPL_DLL
  409. GDALGridCreate( GDALGridAlgorithm, const void *, GUInt32,
  410. const double *, const double *, const double *,
  411. double, double, double, double,
  412. GUInt32, GUInt32, GDALDataType, void *,
  413. GDALProgressFunc, void *);
  414. GDAL_GCP CPL_DLL *
  415. GDALComputeMatchingPoints( GDALDatasetH hFirstImage,
  416. GDALDatasetH hSecondImage,
  417. char **papszOptions,
  418. int *pnGCPCount );
  419. CPL_C_END
  420. #endif /* ndef GDAL_ALG_H_INCLUDED */