yeesian / ArchGDAL.jl

A high level API for GDAL - Geospatial Data Abstraction Library
https://yeesian.github.io/ArchGDAL.jl/stable/
Other
141 stars 27 forks source link

Feature Request: Add Support for `GDAL.gdalsievefilter` #431

Open JoshuaBillson opened 2 months ago

JoshuaBillson commented 2 months ago

Sieve filtering is a fairly standard tool for removing small raster polygons, a summary of which can be found in the GDAL Docs.

It appears that this method is already exposed by GDAL.jl, with the following method signature:

  GDALSieveFilter(GDALRasterBandH hSrcBand,
                  GDALRasterBandH hMaskBand,
                  GDALRasterBandH hDstBand,
                  int nSizeThreshold,
                  int nConnectedness,
                  char ** papszOptions,
                  GDALProgressFunc pfnProgress,
                  void * pProgressArg) -> CPLErr

  Removes small raster polygons.

  Parameters
  ––––––––––

    •  hSrcBand: the source raster band to be processed.

    •  hMaskBand: an optional mask band. All pixels in the mask band with a value other than
       zero will be considered suitable for inclusion in polygons.

    •  hDstBand: the output raster band. It may be the same as hSrcBand to update the source
       in place.

    •  nSizeThreshold: raster polygons with sizes smaller than this will be merged into their
       largest neighbour.

    •  nConnectedness: either 4 indicating that diagonal pixels are not considered directly
       adjacent for polygon membership purposes or 8 indicating they are.

    •  papszOptions: algorithm options in name=value list form. None currently supported.

    •  pfnProgress: callback for reporting algorithm progress matching the GDALProgressFunc()
       semantics. May be NULL.

    •  pProgressArg: callback argument passed to pfnProgress.

  Returns
  –––––––

  CENone on success or CEFailure if an error occurs.

Would it be possible to add a high-level interface through ArchGDAL? I don't mind opening a PR, but I'm not sure how to work with the C-level interface provided by GDAL.jl.

evetion commented 2 months ago

Feel free to open a PR, you can take inspiration from other related calls like gdalwarp https://github.com/yeesian/ArchGDAL.jl/blob/master/src%2Futilities.jl