<html><head></head><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px"><div id="yui_3_16_0_1_1476115792673_3589"><span id="yui_3_16_0_1_1476115792673_3617">I tried to cd to the dir that filename.h5 is in and it works:</span></div><div id="yui_3_16_0_1_1476115792673_3589"><span><br></span></div><div id="yui_3_16_0_1_1476115792673_3720"><br></div><div id="yui_3_16_0_1_1476115792673_3725"><br id="yui_3_16_0_1_1476115792673_3726"></div><div id="yui_3_16_0_1_1476115792673_3727">c:\path\gdal_bin\gdalinfo.exe HDF5:"filename.h5"://ImageData/B2</div><div dir="ltr" id="yui_3_16_0_1_1476115792673_3728"><br id="yui_3_16_0_1_1476115792673_3729"></div><div id="yui_3_16_0_1_1476115792673_3589"></div><div dir="ltr" id="yui_3_16_0_1_1476115792673_3684">I noticed that I had ImageData/h2 instead of ImageData/B2 below.  It's correct in the code that's going to GDALOpenInternal, though.</div><div class="qtdSeparateBR" id="yui_3_16_0_1_1476115792673_3574"><br><br></div><div class="yahoo_quoted" id="yui_3_16_0_1_1476115792673_3529" style="display: block;">  <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;" id="yui_3_16_0_1_1476115792673_3528"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;" id="yui_3_16_0_1_1476115792673_3527"> <div dir="ltr" id="yui_3_16_0_1_1476115792673_3526"> <font size="2" face="Arial" id="yui_3_16_0_1_1476115792673_3573"> <hr size="1" id="yui_3_16_0_1_1476115792673_3572"> <b id="yui_3_16_0_1_1476115792673_3922"><span style="font-weight:bold;" id="yui_3_16_0_1_1476115792673_3921">From:</span></b> Michele <clearlymichele@yahoo.com><br> <b id="yui_3_16_0_1_1476115792673_3924"><span style="font-weight: bold;" id="yui_3_16_0_1_1476115792673_3923">To:</span></b> Even Rouault <even.rouault@spatialys.com> <br><b id="yui_3_16_0_1_1476115792673_3893"><span style="font-weight: bold;" id="yui_3_16_0_1_1476115792673_3892">Cc:</span></b> "gdal-dev@lists.osgeo.org" <gdal-dev@lists.osgeo.org><br> <b><span style="font-weight: bold;">Sent:</span></b> Monday, October 10, 2016 10:46 AM<br> <b><span style="font-weight: bold;">Subject:</span></b> Re: [gdal-dev] GDALOpenInternal Problem Opening specific HDF5 bands<br> </font> </div> <div class="y_msg_container" id="yui_3_16_0_1_1476115792673_3792"><br><div id="yiv3549241607"><div id="yui_3_16_0_1_1476115792673_3791"><div style="color:#000;background-color:#fff;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px;" id="yui_3_16_0_1_1476115792673_3790"><div id="yiv3549241607yui_3_16_0_ym19_1_1475755398051_258720"><span id="yiv3549241607yui_3_16_0_ym19_1_1475755398051_258752">Thanks for the reply, Even!  </span></div><div id="yiv3549241607yui_3_16_0_ym19_1_1475755398051_258720"><span><br clear="none"></span></div><div dir="ltr" id="yiv3549241607yui_3_16_0_ym19_1_1475755398051_258720"><span id="yiv3549241607yui_3_16_0_ym19_1_1475755398051_258821">I can do </span>gdalinfo c:\pathToFile\filename.h5.</div><div dir="ltr" id="yiv3549241607yui_3_16_0_ym19_1_1475755398051_258720"><br clear="none"></div><div dir="ltr" id="yiv3549241607yui_3_16_0_ym19_1_1475755398051_258720">What do you mean, " try accessing the subdataset it will report. The </div><div id="yiv3549241607yui_3_16_0_ym19_1_1475755398051_258865">expected syntax is like HDF5:"c:\pathToFile\filename.h5":subdataset_name"?</div><div class="yiv3549241607qtdSeparateBR" id="yiv3549241607yui_3_16_0_ym19_1_1475755398051_258721"><br clear="none"></div><div class="yiv3549241607qtdSeparateBR" dir="ltr" id="yiv3549241607yui_3_16_0_ym19_1_1475755398051_258721">Do you mean gdalinfo HDF5:"c:\pathtoFile\filename.h5"://ImageData/h2?</div><div class="yiv3549241607qtdSeparateBR" dir="ltr" id="yiv3549241607yui_3_16_0_ym19_1_1475755398051_258721"><br clear="none"></div><div class="yiv3549241607qtdSeparateBR" dir="ltr" id="yiv3549241607yui_3_16_0_ym19_1_1475755398051_258721">When I do that, I get:</div><div class="yiv3549241607qtdSeparateBR" dir="ltr" id="yiv3549241607yui_3_16_0_ym19_1_1475755398051_258721"><br clear="none"></div><div class="yiv3549241607qtdSeparateBR" dir="ltr" id="yiv3549241607yui_3_16_0_ym19_1_1475755398051_258721"> ERROR 4: `HDF5:c:\pathToFile\filename.h5://ImageData/h2' does not exist in the file<br clear="none"></div><div dir="ltr" id="yiv3549241607yui_3_16_0_ym19_1_1475755398051_260144">and is not recognised as a supported dataset name.</div><div dir="ltr" id="yiv3549241607yui_3_16_0_ym19_1_1475755398051_260145"><br clear="none" id="yiv3549241607yui_3_16_0_ym19_1_1475755398051_260146"></div><div dir="ltr" id="yiv3549241607yui_3_16_0_ym19_1_1475755398051_260147">gdalinfo failed - unable to open 'HDF5:c:\pathToFile\filename.h5://ImageData/h2'.</div><div dir="ltr" id="yiv3549241607yui_3_16_0_ym19_1_1475755398051_260147"><br clear="none"></div><div dir="ltr" id="yiv3549241607yui_3_16_0_ym19_1_1475755398051_260147">We know h2 exists because it was listed in gdalinfo for the filename.</div><div dir="ltr" id="yiv3549241607yui_3_16_0_ym19_1_1475755398051_260147"><br clear="none"></div><div dir="ltr" id="yiv3549241607yui_3_16_0_ym19_1_1475755398051_260147">Thanks,</div><div dir="ltr" id="yiv3549241607yui_3_16_0_ym19_1_1475755398051_260147">Michele</div><div dir="ltr" id="yiv3549241607yui_3_16_0_ym19_1_1475755398051_260147"><br clear="none"></div><div class="yiv3549241607yahoo_quoted" id="yiv3549241607yui_3_16_0_ym19_1_1475755398051_258728" style="display:block;">  <div id="yiv3549241607yui_3_16_0_ym19_1_1475755398051_258727" style="font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px;"> <div id="yiv3549241607yui_3_16_0_ym19_1_1475755398051_258726" style="font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px;"> <div dir="ltr" id="yiv3549241607yui_3_16_0_ym19_1_1475755398051_258725"> <font id="yiv3549241607yui_3_16_0_ym19_1_1475755398051_258724" size="2" face="Arial"> </font><hr id="yiv3549241607yui_3_16_0_ym19_1_1475755398051_258723" size="1"> <b id="yiv3549241607yui_3_16_0_ym19_1_1475755398051_260107"><span id="yiv3549241607yui_3_16_0_ym19_1_1475755398051_260106" style="font-weight:bold;">From:</span></b> Even Rouault <even.rouault@spatialys.com><br clear="none"> <b><span style="font-weight:bold;">To:</span></b> Michele <clearlymichele@yahoo.com> <br clear="none"><b><span style="font-weight:bold;">Cc:</span></b> gdal-dev@lists.osgeo.org<br clear="none"> <b><span style="font-weight:bold;">Sent:</span></b> Monday, October 10, 2016 9:44 AM<br clear="none"> <b><span style="font-weight:bold;">Subject:</span></b> Re: [gdal-dev] GDALOpenInternal Problem Opening specific HDF5 bands<br clear="none">  </div> <div class="yiv3549241607y_msg_container" id="yiv3549241607yui_3_16_0_ym19_1_1475755398051_258732"><br clear="none">Le lundi 10 octobre 2016 15:20:08, Michele a écrit :<div class="yiv3549241607yqt5216352430" id="yiv3549241607yqtfd60216"><div class="yiv3549241607yqt8411580557" id="yiv3549241607yqtfd23505"><br clear="none">> I'm trying to open an HDF5 file, specific bands, but GDAL is giving an<br clear="none">> error message: <br clear="none">> <br clear="none">> > "'HDF5:C:\pathToFile\pathToFile/filename.h5://ImageData/B4' does not><br clear="none">> > exist in the file system and is not recognized as a supported data set><br clear="none">> > name"<br clear="none">> <br clear="none">> I got the error message after the GDALOpenInternal call using<br clear="none">> CPLGetLastErrorMsg().  I can't step into GDALOpenInternal (with Visual<br clear="none">> Studio) because we don't have GDAL source cpp file; just h file that came<br clear="none">> with the package, unless I'm searching for the wrong file name. The string<br clear="none">> for the ConnectionString parameter for GDALOpenInternal is shown in the<br clear="none">> quotes above. I found [qgis polygonize error 4 "file does not exist in the<br clear="none">> file system"], but they said it was because of using non-ascii characters<br clear="none">> in file path string.  I didn't see any other pertinent info on this error<br clear="none">> message. We need to access the specific band of the HDF5 file.  I noticed<br clear="none">> that our slashes in the path are showing in different directions, but I'm<br clear="none">> not sure that would be the issue here.  We have both windows and linux<br clear="none">> OS's.  This error was seen on windows os. We used (gdalinfo.exe<br clear="none">> filename.h5) and do see that the B4 exists there. Using the string,<br clear="none">> HDF5:"C:\pathToFile\filename.h5"://ImageData/B2, didn't work for<br clear="none">> openInternal with GDAL.<br clear="none">> <br clear="none">> I saw  (gdal.org/gdal_tutorial.html), which gives an example to open a band<br clear="none">> after a GDALOpen, but it seems that it's supposed to work with<br clear="none">> GDALOpenInternal also according to my co-workers. We just don't have a<br clear="none">> good example of the connection string to get it working with<br clear="none">> GDALOpenInternal since we don't have access to that part of the code that<br clear="none">> does it. They want me to focus on using GDALOpenInternal.<br clear="none">> <br clear="none">> I'm<br clear="none">> seeing lists.alioth.debian.org/pipermail/pkg-grass-devel/2012-Novem‌​ber/…<br clear="none">> , which gives me hope, but doesn't have a good example. I saw this which<br clear="none">> could be an example, although it isn't using a path, but I'm not sure:<br clear="none">> gdalwarp HDF4_SDS:ASTER_L1B:"pg-PR1B0000-2002031402_100_001":2<br clear="none">> pg-PR1B0000-2002031402_100_001_2.tif<br clear="none">> <br clear="none">> My question is, what format for the connection string do I need to use<br clear="none">> GDALOpenInternal, if it's not what I show for the two things I tried<br clear="none">> above? </div><br clear="none"><br clear="none">You should try first <br clear="none"><br clear="none">gdalinfo c:\pathToFile\filename.h5<br clear="none"><br clear="none">and then, if that opens, try accessing the subdataset it will report. The <br clear="none">expected syntax is like HDF5:"c:\pathToFile\filename.h5":subdataset_name<br clear="none"><br clear="none">Since you seem to mention that the path contains non ASCII characters, I <br clear="none">wouldn't be surprise if that didn't work correctly on Windows. You should <br clear="none">perhaps try making sure your path is encoded in the current ANSI code page of <br clear="none">your system since that's probably what the HDF5 API expects.<br clear="none"><br clear="none">Would probably make sense for GDAL to recode from UTF-8 to current ANSI code <br clear="none">page automagically as it does in the XLS driver:<br clear="none"><br clear="none">#ifdef _WIN32<br clear="none">    if( CPLTestBool( CPLGetConfigOption( "GDAL_FILENAME_IS_UTF8", "YES" ) ) )<br clear="none">        pszName = CPLRecode( pszFilename, CPL_ENC_UTF8, CPLString().Printf( <br clear="none">"CP%d", GetACP() ) );<br clear="none">    else<br clear="none">        pszName = CPLStrdup( pszFilename );<br clear="none">#else<br clear="none">    pszName = CPLStrdup( pszFilename );<br clear="none">#endif<br clear="none"><br clear="none">That assumes that the accentued characters you need can be expressed in the <br clear="none">current ANSI code page, otherwise you'll have to move the file elsewhere<br clear="none"><br clear="none">Even<br clear="none"><br clear="none">-- <br clear="none">Spatialys - Geospatial professional services<br clear="none"><a rel="nofollow" shape="rect" target="_blank" href="http://www.spatialys.com/">http://www.spatialys.com</a><br clear="none"><br clear="none"></div></div><div class="yiv3549241607yqt5216352430" id="yiv3549241607yqtfd29717"> </div></div><div class="yiv3549241607yqt5216352430" id="yiv3549241607yqtfd91916"> </div></div><div class="yiv3549241607yqt5216352430" id="yiv3549241607yqtfd42689">  </div></div></div></div></div><br><br></div> </div> </div>  </div></div></body></html>