[gdal-dev] gdalwarp from C#

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[gdal-dev] gdalwarp from C#

kaarigar
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
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: gdalwarp from C#

Tamas Szekeres
Would Gdal.ReprojectImage do what you want in this particular case? This is the signature that can be used in the C# bindings:

public static CPLErr ReprojectImage(Dataset src_ds, Dataset dst_ds, string src_wkt, string dst_wkt, ResampleAlg eResampleAlg, double WarpMemoryLimit, double maxerror, Gdal.GDALProgressFuncDelegate callback, string callback_data, string[] options)

Best regards,

Tamas

2017-11-04 20:04 GMT+01:00 Karu Kaarigar <[hidden email]>:
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
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev


_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: gdalwarp from C#

Paul Meems
In reply to this post by kaarigar
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
    {
        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!


Download the latest MapWinGIS mapping engine.

Download the latest MapWindow 5 open source desktop application.


2017-11-04 20:04 GMT+01:00 Karu Kaarigar <[hidden email]>:
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
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev


_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev