<div dir="ltr"><div>Thanks Even.</div><div><br></div><div>So if I understand correctly, the steps would be:</div><div> 1- Create() the GTiff dataset (with a valid filename)</div><div> 2- write all the data with [many] RasterIO() calls<br></div><div> 3- close the dataset (to dump everything into disk)</div><div> 4- open the GTiff dataset in read mode<br></div><div> 5- CreateCopy() with COG driver (with in a different valid filename), based on the dataset (opened in 1 or 4, see below)<br></div><div> 6- close COG file.</div><div> 7- optionally delete the GTiff file (if only COG is needed)<br></div><div><br></div><div>I am not sure if I need steps 3 and 4. If not, should I move step 5 between 1 and 2?<br></div><div><br></div><div>Looks like this duplicates used disk space, and takes time to write the second time. Why is it needed? Is there any workaround to create the COG directly?</div><div><br></div><div>Thank you. Regards.</div><div>Javier.<br></div><div><br></div><div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">.___ ._ ..._ .. . ._.  .___ .. __ . _. . __..  ... .... ._ .__<br>Entre dos pensamientos racionales <br>hay infinitos pensamientos irracionales.<br><br></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, 14 Sep 2020 at 19:49, Even Rouault <<a href="mailto:even.rouault@spatialys.com">even.rouault@spatialys.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><u></u>
<div style="font-family:"monospace";font-size:9pt;font-weight:400;font-style:normal">
<p style="margin:0px;text-indent:0px">Javier,</p>
<p style="margin:0px;text-indent:0px"> </p>
<p style="margin:0px;text-indent:0px">> I want to create a big (I mean bigger than my RAM size) COG file in C++</p>
<p style="margin:0px;text-indent:0px">> with GDAL 3.1.</p>
<p style="margin:0px;text-indent:0px">> COG driver does not have the "Create()" method, but "CreateCopy()". I am</p>
<p style="margin:0px;text-indent:0px">> not sure how I have to do it. Should I Create() first the dataset with the</p>
<p style="margin:0px;text-indent:0px">> MEM driver, write on it, and then call the CreateCopy with the COG driver?</p>
<p style="margin:0px;text-indent:0px">> (by the way, before closing the MEM dataset? Is then everything copied?)</p>
<p style="margin:0px;text-indent:0px"> </p>
<p style="margin:0px;text-indent:0px">You shouldn't use the MEM driver for datasets that can't fit entirely into RAM.</p>
<p style="margin:0px;text-indent:0px">MEM datasets are temporary. Once you've closed the dataset handle, it is destroyed. So if you use a MEM dataset, you must pass to CreateCopy() the handle you got when calling Create() for the MEM dataset</p>
<p style="margin:0px;text-indent:0px"> </p>
<p style="margin:0px;text-indent:0px">> Or should I use a normal GTiff dataset, and then CreateCopy() with</p>
<p style="margin:0px;text-indent:0px">> the COG driver?</p>
<p style="margin:0px;text-indent:0px"> </p>
<p style="margin:0px;text-indent:0px">Yes</p>
<p style="margin:0px;text-indent:0px"> </p>
<p style="margin:0px;text-indent:0px">Even</p>
<p style="margin:0px;text-indent:0px"> </p>
<p style="margin:0px;text-indent:0px">-- </p>
<p style="margin:0px;text-indent:0px">Spatialys - Geospatial professional services</p>
<p style="margin:0px;text-indent:0px"><a href="http://www.spatialys.com" target="_blank">http://www.spatialys.com</a></p></div>_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">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/mailman/listinfo/gdal-dev</a></blockquote></div>