<font face="courier new,monospace">Even, here is the basic flow of my task.  I am opening several subdatasets in a for loop, warping them and populating an internal data structure.  <br><br>#include &quot;gdal_priv.h&quot;<br>

#include &quot;gdalwarper.h&quot;<br>#include &quot;cpl_conv.h&quot;<br>#include &quot;cpl_port.h&quot;<br>#include &lt;string&gt;<br>#include &lt;vector&gt;<br>int main()<br>{<br>GDALAllRegister();<br>/*<br> * Variable names for the netcdf forecast file<br>

 */<br><br>std::vector&lt;std::string&gt; varList;<br>varList.push_back( &quot;Temperature_height_above_ground&quot; );<br>varList.push_back( &quot;V-component_of_wind_height_above_ground&quot; );<br>varList.push_back( &quot;U-component_of_wind_height_above_ground&quot; );<br>

varList.push_back( &quot;Total_cloud_cover&quot; );<br><br>std::string temp;<br>GDALDataset* srcDS;<br>GDALDataset* wrpDS;<br>GDALWarpOptions* psWarpOptions;<br>std::string srcWkt, dstWkt;<br>dstWkt = &quot;PROJCS[\&quot;WGS 84 / UTM zone 12N\&quot;,GEOGCS[\&quot;WGS 84\&quot;,DATUM[\&quot;WGS_1984\&quot;,SPHEROID[\&quot;WGS 84\&quot;,6378137,298.257223563]],PRIMEM[\&quot;Greenwich\&quot;,0],UNIT[\&quot;degree\&quot;,0.0174532925199433]],UNIT[\&quot;metre\&quot;,1],PROJECTION[\&quot;Transverse_Mercator\&quot;],PARAMETER[\&quot;latitude_of_origin\&quot;,0],PARAMETER[\&quot;central_meridian\&quot;,-111],PARAMETER[\&quot;scale_factor\&quot;,0.9996],PARAMETER[\&quot;false_easting\&quot;,500000],PARAMETER[\&quot;false_northing\&quot;,0]]&quot;;<br>

<br>/*<br> * Loop over variable names and open sub datasets<br> */<br><br>for( int i = 0;i &lt; varList.size();i++ ) {<br><br>    temp = &quot;NETCDF:<a href="http://test.nc">test.nc</a>:&quot; + varList[i];<br><br>    srcDS = (GDALDataset*)GDALOpenShared( temp.c_str(), GA_ReadOnly );<br>

<br>    srcWkt = srcDS-&gt;GetProjectionRef();<br><br>    /*<br>     * Grab the first band to get the nodata value for the variable,<br>     * assume all bands have the same ndv<br>     */<br>    GDALRasterBand *poBand = srcDS-&gt;GetRasterBand( 1 );<br>

    int pbSuccess;<br>    double dfNoData = poBand-&gt;GetNoDataValue( &amp;pbSuccess );<br>    psWarpOptions = GDALCreateWarpOptions();<br><br>    int nBandCount = srcDS-&gt;GetRasterCount();<br>    psWarpOptions-&gt;padfDstNoDataReal =<br>

        (double*) CPLMalloc( sizeof( double ) * nBandCount );<br>    psWarpOptions-&gt;padfDstNoDataImag =<br>        (double*) CPLMalloc( sizeof( double ) * nBandCount );<br>    for( int b = 0;b &lt; srcDS-&gt;GetRasterCount();b++ ) {<br>

        psWarpOptions-&gt;padfDstNoDataReal[b] = dfNoData;<br>        psWarpOptions-&gt;padfDstNoDataImag[b] = dfNoData;<br>    }<br>    if( pbSuccess == false )<br>        dfNoData = -9999.0;<br>    psWarpOptions-&gt;papszWarpOptions =<br>

    CSLSetNameValue( psWarpOptions-&gt;papszWarpOptions,<br>                     &quot;INIT_DEST&quot;, &quot;NO_DATA&quot; );<br><br>    //set the dskWkt with an internal structure<br><br>    wrpDS = (GDALDataset*) GDALAutoCreateWarpedVRT( srcDS, srcWkt.c_str(),<br>

                                                    dstWkt.c_str(),<br>                                                    GRA_NearestNeighbour,<br>                                                    1.0, psWarpOptions );<br>

    <br>    //copy warped data to internal structure<br><br>    GDALDestroyWarpOptions( psWarpOptions );<br>    GDALClose((GDALDatasetH) srcDS );<br>    GDALClose((GDALDatasetH) wrpDS );<br>}<br>}<br><br>I am sure I am missing something.<br>

<br>kss<br clear="all"></font><br>/**<br> *<br> * Kyle Shannon<br> * <a href="mailto:ksshannon@gmail.com" target="_blank">ksshannon@gmail.com</a><br> *<br> */<br><br><br>
<br><br><div class="gmail_quote">On Tue, May 10, 2011 at 03:51, Even Rouault <span dir="ltr">&lt;<a href="mailto:even.rouault@mines-paris.org">even.rouault@mines-paris.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

Selon Kyle Shannon &lt;<a href="mailto:ksshannon@gmail.com">ksshannon@gmail.com</a>&gt;:<br>
<div class="im"><br>
&gt; I did have to set the padfNoDataImag array as well, so I am one step<br>
&gt; closer.  My new issue is ownership of my psWarpOptions.  I assume that since<br>
&gt; I create it, and the warp api tutorial implies that is it mine, I destroy it<br>
&gt; with GDALDestroyWarpOptions().  My problem is that AutoCreateWarpedVRT<br>
&gt; appears to be stepping on my warp options when it destroys it&#39;s own copy.<br>
&gt;<br>
&gt; I call AutoCreateWarpedVRT() and that function calls<br>
&gt; GDALCloneWarpOptions().  When AutoCreateWarpedVRT destroys the copy it owns,<br>
&gt; it appears to be stepping on my copy, and when I call<br>
&gt; GDALDestroyWarpOptions(), I get a seg fault.  Am I doing something wrong?<br>
<br>
</div>Difficult to say without seeing your code. Could you post a small<br>
self-sufficient code snippet that demonstrates your issue ?<br>
<br>
By reviewing the code, one potential issue would be if you try to free the<br>
pTransformerArg field by yourself, as it is freed by the destructor of the<br>
VRTWarpedDataset. But if you just use GDALDestroyWarpOptions(), it should work<br>
OK<br>
<div><div></div><div class="h5"><br>
&gt;<br>
&gt; kss<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; /**<br>
&gt;  *<br>
&gt;  * Kyle Shannon<br>
&gt;  * <a href="mailto:ksshannon@gmail.com">ksshannon@gmail.com</a><br>
&gt;  *<br>
&gt;  */<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; On Mon, May 9, 2011 at 15:43, Even Rouault<br>
&gt; &lt;<a href="mailto:even.rouault@mines-paris.org">even.rouault@mines-paris.org</a>&gt;wrote:<br>
&gt;<br>
&gt; &gt; Le lundi 09 mai 2011 23:30:05, Kyle Shannon a écrit :<br>
&gt; &gt; &gt; Thanks Even,<br>
&gt; &gt; &gt; If that is the case, are there other values in psWarpOptions I *have* to<br>
&gt; &gt; &gt; set?  I can&#39;t find docs discussing that.<br>
&gt; &gt;<br>
&gt; &gt; I don&#39;t think so, but you&#39;ll just have to try... I&#39;m not  surprised the<br>
&gt; &gt; docs<br>
&gt; &gt; don&#39;t talk about NaN. It is a corner case, and likely not really well<br>
&gt; &gt; supported in all places.<br>
&gt; &gt;<br>
&gt;<br>
<br>
<br>
</div></div></blockquote></div><br>