<div dir="ltr"><div><div>As usual Even, spot on!  <br><br></div>Thank you for precise diagnosis and the quick solution.  My project is back on track and the product can be delivered soon.  I am guessing that I could bump the pool_size up somewhat.  I plan to play around with that value and maybe get a little more performance (on my old Mac laptop...).<br>
<br>Thanks again, <br><br></div>David.<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, May 20, 2014 at 3:37 AM, Even Rouault <span dir="ltr"><<a href="mailto:even.rouault@mines-paris.org" target="_blank">even.rouault@mines-paris.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Selon David Fawcett <<a href="mailto:david.fawcett@gmail.com">david.fawcett@gmail.com</a>>:<br>
<div class=""><br>
> I am using gdal_translate and a .vrt to take 115 .jp2 files from the USGS,<br>
> pull them together and then export a lower resolution .jp2.<br>
><br>
> This is with GDAL 1.10 on OSX.<br>
> gdalinfo --version<br>
> GDAL 1.10.1, released 2013/08/26<br>
><br>
> When I run gdal_translate, it gets about 30% of the way through the process<br>
> and errors out saying that it can't open one of the .j2w files.  When I run<br>
> gdalinfo on the file, I can open it, and if I run gdal_translate on just<br>
> that file, I can successfully export a reduced resolution copy.<br>
><br>
> The output of gdalinfo is here:<br>
> <a href="https://gist.github.com/fawcett/beead31741e24394b38e" target="_blank">https://gist.github.com/fawcett/beead31741e24394b38e</a><br>
><br>
> I can also load the .vrt image into QGIS 2.2 and it loads (slowly of<br>
> course).<br>
<br>
</div>Even when you zoom out at 10% like your gdal_translate command ?<br>
<div><div class="h5"><br>
><br>
> gdal_translate img_index.vrt mpls34.jp2 -outsize 10% 10% -of JP2OpenJPEG<br>
> -co QUALITY=25 -epo<br>
> Input file size is 45000, 65000<br>
> 0...10...20.ERROR 4:<br>
><br>
CSLLoad2("/Users/david/projects/mpls_watersheds/data/15TVK830815_201203_0x3000m_CL_1/15TVK830815_201203_0x3000m_CL_1.j2w")<br>
> failed: unable to open file.<br>
> ERROR 4:<br>
><br>
`/Users/david/projects/mpls_watersheds/data/15TVK830830_201203_0x3000m_CL_1/15TVK830830_201203_0x3000m_CL_1.jp2'<br>
> not recognised as a supported file format.<br>
><br>
> gdalinfo 15TVK830815_201203_0x3000m_CL_1.jp2<br>
> Driver: JP2OpenJPEG/JPEG-2000 driver based on OpenJPEG library<br>
> Files: 15TVK830815_201203_0x3000m_CL_1.jp2<br>
>        15TVK830815_201203_0x3000m_CL_1.j2w<br>
> Size is 5000, 5000<br>
> Coordinate System is:<br>
> PROJCS["NAD83 / UTM zone 15N",<br>
>     GEOGCS["NAD83",<br>
>         DATUM["North_American_Datum_1983",<br>
>             SPHEROID["GRS 1980",6378137,298.2572221010002,<br>
>                 AUTHORITY["EPSG","7019"]],<br>
>             AUTHORITY["EPSG","6269"]],<br>
>         PRIMEM["Greenwich",0],<br>
>         UNIT["degree",0.0174532925199433],<br>
>         AUTHORITY["EPSG","4269"]],<br>
>     PROJECTION["Transverse_Mercator"],<br>
>     PARAMETER["latitude_of_origin",0],<br>
>     PARAMETER["central_meridian",-93],<br>
>     PARAMETER["scale_factor",0.9996],<br>
>     PARAMETER["false_easting",500000],<br>
>     PARAMETER["false_northing",0],<br>
>     UNIT["metre",1,<br>
>         AUTHORITY["EPSG","9001"]],<br>
>     AUTHORITY["EPSG","26915"]]<br>
> Origin = (483000.000000000000000,4983000.000000000000000)<br>
> Pixel Size = (0.300000000000012,-0.300000000000186)<br>
> Image Structure Metadata:<br>
>   INTERLEAVE=PIXEL<br>
> Corner Coordinates:<br>
> Upper Left  (  483000.000, 4983000.000) ( 93d12'56.50"W, 45d 0' 0.87"N)<br>
> Lower Left  (  483000.000, 4981500.000) ( 93d12'56.32"W, 44d59'12.26"N)<br>
> Upper Right (  484500.000, 4983000.000) ( 93d11'47.99"W, 45d 0' 1.00"N)<br>
> Lower Right (  484500.000, 4981500.000) ( 93d11'47.82"W, 44d59'12.39"N)<br>
> Center      (  483750.000, 4982250.000) ( 93d12'22.16"W, 44d59'36.63"N)<br>
> Band 1 Block=1024x1024 Type=Byte, ColorInterp=Red<br>
>   Overviews: 2500x2500, 1250x1250, 625x625, 312x312, 156x156<br>
>   Overviews: arbitrary<br>
> Band 2 Block=1024x1024 Type=Byte, ColorInterp=Green<br>
>   Overviews: 2500x2500, 1250x1250, 625x625, 312x312, 156x156<br>
>   Overviews: arbitrary<br>
> Band 3 Block=1024x1024 Type=Byte, ColorInterp=Blue<br>
>   Overviews: 2500x2500, 1250x1250, 625x625, 312x312, 156x156<br>
>   Overviews: arbitrary<br>
><br>
> The .vrt file contents are here:<br>
> <a href="https://gist.github.com/fawcett/c8cd5d271b0a89e67779" target="_blank">https://gist.github.com/fawcett/c8cd5d271b0a89e67779</a><br>
><br>
> Does anyone have a suggestion on how to troubleshoot this?  I am wondering<br>
> if I am just running out of memory.<br>
<br>
</div></div>I guess you might rather run out of file descriptors. What is the default limit<br>
on Mac : 1024 as on Linux ?<br>
For each opened JP2 by the OpenJPEG driver, it maintains a file descriptor per<br>
overview level (and for the main level). So in your above case, 6 file<br>
descriptors.<br>
The VRT mechanism shouldn't open simultaneously more than<br>
GDAL_MAX_DATASET_POOL_SIZE=100 datasets<br>
(<a href="http://trac.osgeo.org/gdal/browser/trunk/gdal/gcore/gdalproxypool.cpp#L313" target="_blank">http://trac.osgeo.org/gdal/browser/trunk/gdal/gcore/gdalproxypool.cpp#L313</a>).<br>
100 * 6 = 600... So if you have JP2 images bigger than the one you sampled, you<br>
might have more overview levels. Or possibly the limit on Mac is lower than<br>
1024.<br>
You might want to try setting the GDAL_MAX_DATASET_POOL_SIZE configuration<br>
option/environmenet variable to a lower value, let's say 10, and see if it works<br>
better.<br>
<span class="HOEnZb"><font color="#888888"><br>
Even<br>
<br>
<br>
</font></span></blockquote></div><br></div>