<div dir="ltr">Here's a snippet of the code I use:<div><br></div><div><div><font face="monospace, monospace">using (var ds = GDAL.Open(input, Access.GA_ReadOnly))</font></div><div><font face="monospace, monospace">{</font></div><div><font face="monospace, monospace">    if (ds == null)</font></div><div><font face="monospace, monospace">    {</font></div><div><font face="monospace, monospace">        throw new Exception("Can't open GDAL dataset: " + input);</font></div><div><font face="monospace, monospace">    }</font></div><div><font face="monospace, monospace"><br></font></div><div><div><font face="monospace, monospace">            var options = new[]</font></div><div><font face="monospace, monospace">            {</font></div><div><font face="monospace, monospace">                "-of", "vrt",</font></div><div><font face="monospace, monospace">                "-overwrite",</font></div><div><font face="monospace, monospace">                "-multi",</font></div><div><font face="monospace, monospace">                "-crop_to_cutline",</font></div><div><font face="monospace, monospace">                "-cutline", borderFilename</font></div><div><font face="monospace, monospace">            };</font></div></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">    var gdalOptions = new GDALWarpAppOptions(options);</font></div><div><font face="monospace, monospace">    var ptr = new[] { Dataset.getCPtr(ds).Handle };</font></div><div><font face="monospace, monospace">    var gcHandle = GCHandle.Alloc(ptr, GCHandleType.Pinned);</font></div><div><font face="monospace, monospace">    try</font></div><div><font face="monospace, monospace">    {</font></div><div><font face="monospace, monospace">        var dss = new SWIGTYPE_p_p_GDALDatasetShadow(gcHandle.AddrOfPinnedObject(), false, null);<br></font></div><div><font face="monospace, monospace">        using (var newDs = <span style="color:rgb(34,34,34);font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">GDAL</span>.wrapper_GDALWarpDestName(output, 1, dss, gdalOptions, null, null))</font></div><div><font face="monospace, monospace">        {</font></div><div><font face="monospace, monospace">            if (newDs == null)</font></div><div><font face="monospace, monospace">            {</font></div><div><font face="monospace, monospace">                throw new Exception("GdalWarp failed: " + <span style="color:rgb(34,34,34);font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">GDAL</span>.GetLastErrorMsg());</font></div><div><font face="monospace, monospace">            }</font></div><div><font face="monospace, monospace">        }</font></div><div><font face="monospace, monospace">    }</font></div><div><font face="monospace, monospace">    finally</font></div><div><font face="monospace, monospace">    {</font></div><div><font face="monospace, monospace">        if (gcHandle.IsAllocated)</font></div><div><font face="monospace, monospace">            gcHandle.Free();</font></div><div><font face="monospace, monospace">    }</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">    return true;</font></div><div><font face="monospace, monospace">}</font></div></div><div><br></div><div class="gmail_extra">Does this help you?</div><div class="gmail_extra"><br></div><div class="gmail_extra">Regards,</div><div class="gmail_extra"><br></div><div class="gmail_extra">Paul<br><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><span><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><br></p></span>
</div></div></div></div></div></div></div></div></div></div></div>
<br><div class="gmail_quote">2018-04-02 22:18 GMT+02:00 tval <span dir="ltr"><<a href="mailto:tyeik@gktechinc.com" target="_blank">tyeik@gktechinc.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Is it possible to use the Gdal Warp wrapper or another method for clipping a<br>
raster to a polygon? I've tried using Gdal.wrapper_GDALWarpDestName and<br>
using input datasets such as a .tif and a .shp, but was unsuccessful.<br>
Perhaps I had the wrong options or inputs. Any help would be appreciated.<br>
Thanks.<br>
<br>
<br>
<br>
--<br>
Sent from: <a href="http://osgeo-org.1560.x6.nabble.com/GDAL-Dev-f3742093.html" rel="noreferrer" target="_blank">http://osgeo-org.1560.x6.<wbr>nabble.com/GDAL-Dev-f3742093.<wbr>html</a><br>
______________________________<wbr>_________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev" rel="noreferrer" target="_blank">https://lists.osgeo.org/<wbr>mailman/listinfo/gdal-dev</a></blockquote></div><br></div></div>