[gdal-dev] gdalwarp from C#
Paul Meems
bontepaarden at gmail.com
Mon Nov 6 23:45:51 PST 2017
We're using it like this:
using (var ds = _gdalProxy.Open(input, Access.GA_ReadOnly))
{
if (ds == null)
{
throw new Exception("Can't open GDAL dataset: " + input);
}
var gdalOptions = new GDALWarpAppOptions(options);
var ptr = new[] { Dataset.getCPtr(ds).Handle };
var gcHandle = GCHandle.Alloc(ptr, GCHandleType.Pinned);
try
{
// https://trac.osgeo.org/gdal/ticket/6437
var dss = new
SWIGTYPE_p_p_GDALDatasetShadow(gcHandle.AddrOfPinnedObject(), false, null);
using (var newDs = _gdalProxy.wrapper_GDALWarpDestName(output, 1,
dss, gdalOptions, null, null))
{
if (newDs == null)
{
throw new Exception("GdalWarp failed: " +
_gdalProxy.GetLastErrorMsg());
}
}
}
finally
{
if (gcHandle.IsAllocated)
gcHandle.Free();
}
return true;
}
Paul
*Paul Meems *
Release manager, configuration manager
and forum moderator of MapWindow GIS.
www.mapwindow.org
Owner of MapWindow.nl - Support for
Dutch speaking users.
www.mapwindow.nl
*The MapWindow GIS project has moved to GitHub
<https://github.com/MapWindow>!*
Download the latest MapWinGIS mapping engine.
<https://github.com/MapWindow/MapWinGIS/releases>
Download the latest MapWindow 5 open source desktop application.
<https://github.com/MapWindow/MapWindow5/releases>
2017-11-04 20:04 GMT+01:00 Karu Kaarigar <kaarigar at gmail.com>:
> I am trying to use gdalwarp using C# bindings. I am using 64bit libs.
> However, I am not able to find proper docs on its usage. Specifically I
> need to know how to use the GDALWarpAppOptions and the format of options
> string array passed to its constructor. I also need to know the call
> semantics of various wrapper methods (wrapper_GDALWarpDestName,
> wrapper_GDALWarpDestName). I m confused about its arguments such as
> SWIGTYPE_p_p_GDALDatasetShadow, etc.
>
> Any help or pointers is highly appreciated. Is there any sample code that
> shows how to use gdalwarp from C#? Thanks you.
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20171107/12e1f229/attachment.html>
More information about the gdal-dev
mailing list