<div dir="ltr"><div>Hi Even, </div><div><br></div><div>> There's no real need of a new API for that (although it might be cleaner to</div><div>> have a dedicated one at some point). I'd note that your proposed API would</div>
<div>> only work for a single subdataset, not a vector of them.</div><div><br></div><div>Sorry, my bad. Should have been:</div><div><br></div><div>GDALDataset** pporSubDatasets;</div><div>virtual GDALDataset** GetSubDatasets();</div>
<div><br></div><div>> Anyway, the subdatasets mechanism already exist in many drivers and should do</div><div>> what you need. You can read the "SUBDATASETS domain" section of</div><div>> <a href="http://www.gdal.org/gdal_datamodel.html">http://www.gdal.org/gdal_datamodel.html</a> and have a look at the code of the</div>
<div>> mentionned drivers to see how they do that.</div><div><br></div><div>I've read the "SUBDATASETS domain" section and took a look at the HDF5 format, in particular, but I don't think that that would work for me. Maybe I'm not looking at the right place though.</div>
<div><br></div><div>The scenario:</div><div>LC82300942013289LGN00_B1.tif</div><div>LC82300942013289LGN00_B2.tif</div><div>LC82300942013289LGN00_B3.tif</div><div>LC82300942013289LGN00_B4.tif</div><div>LC82300942013289LGN00_B5.tif</div>
<div>LC82300942013289LGN00_B6.tif</div><div>LC82300942013289LGN00_B7.tif</div><div>LC82300942013289LGN00_B8.tif</div><div>LC82300942013289LGN00_B9.tif</div><div>LC82300942013289LGN00_B10.tif</div><div>LC82300942013289LGN00_B11.tif</div>
<div>LC82300942013289LGN00_BQA.tif</div><div>LC82300942013289LGN00_MTL.txt</div><div><br></div><div>I'd like to open LC82300942013289LGN00_MTL.txt and get 4 datasets:</div><div>Dataset 1:</div><div>LC82300942013289LGN00_B1.tif</div>
<div>LC82300942013289LGN00_B2.tif</div><div>LC82300942013289LGN00_B3.tif</div><div>LC82300942013289LGN00_B4.tif</div><div>LC82300942013289LGN00_B5.tif</div><div>LC82300942013289LGN00_B6.tif</div><div>LC82300942013289LGN00_B7.tif</div>
<div>LC82300942013289LGN00_B9.tif</div><div><br></div><div>Dataset 2:</div><div>LC82300942013289LGN00_B8.tif</div><div><br></div><div>Dataset 3:</div><div>LC82300942013289LGN00_B10.tif</div><div>LC82300942013289LGN00_B11.tif</div>
<div><br></div><div>Dataset 4:</div><div>LC82300942013289LGN00_BQA.tif</div><div><br></div><div>Maybe GetSubDatasets is not the most appropiate name for this purpose (I thought about that, but at that moment I couldn't think of a better name). Maybe GetAssociatedDatasets would be better.</div>
<div><br></div><div>Using it:</div><div><br></div><div>GDALDataset* poDataset = (GDALDataset *)GDALOpen(...);</div><div>poDataset->GetRasterBand(...); // would return a band from those in Dataset 1 above.</div><div><br>
</div><div>GDALDataset** pporAssocDatasets = poDataset->GetAssociatedDatasets();</div><div>pporAssocDatasets[0]->GetRasterBand(...); // would return a band from those in Dataset 2 above.</div><div><br></div><div>pporAssocDatasets[1]->GetRasterBand(...); // would retun a band from those in Dataset 3 above.</div>
<div><br></div><div>pporAssocDatasets[2]->GetRasterBand(...); // would return a band from those in Dataset 4 above.</div><div><br></div><div><br></div><div>> Another question I have is : how close or far would be Landsat8 support  from</div>
<div>> the existing code of the FAST driver. I see that FAST relies on "raw" bands,</div><div>> whereas you mention .tif for Landsat 8 + the change of metadata format. So it</div><div>> might be more appropriate to have a new driver if technically there is little</div>
<div>> common points between the drivers.</div><div><br></div><div>Yes, it might be better to add a new driver.</div><div><br></div><div><br></div><div>Hope this will give you a better idea of what I'd like to accomplish.</div>
<div><br></div><div>Thanks.</div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, May 16, 2014 at 2:56 PM, 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">Daniel,<br>
<br>
There's no real need of a new API for that (although it might be cleaner to<br>
have a dedicated one at some point). I'd note that your proposed API would<br>
only work for a single subdataset, not a vector of them.<br>
<br>
Anyway, the subdatasets mechanism already exist in many drivers and should do<br>
what you need. You can read the "SUBDATASETS domain" section of<br>
<a href="http://www.gdal.org/gdal_datamodel.html" target="_blank">http://www.gdal.org/gdal_datamodel.html</a> and have a look at the code of the<br>
mentionned drivers to see how they do that.<br>
<br>
Another question I have is : how close or far would be Landsat8 support  from<br>
the existing code of the FAST driver. I see that FAST relies on "raw" bands,<br>
whereas you mention .tif for Landsat 8 + the change of metadata format. So it<br>
might be more appropriate to have a new driver if technically there is little<br>
common points between the drivers.<br>
<br>
Best regards,<br>
<br>
Even<br>
<div class="HOEnZb"><div class="h5"><br>
> Hi, I'm writing to you because I need support for the new Landsat-8<br>
> metadata format (_MTL.txt file)<br>
><br>
> I took a look at the latest version, 1.11.0, and I couldn't find anything<br>
> on the matter. So, I was thinking I could add support for the new format by<br>
> myself.<br>
><br>
> There are 3 groups of bands: panchromatic, multispectral and thermal. One<br>
> .tif file for each band and then the MTL file with all the info. I'd like<br>
> to open the MTL file, using GDAL, and have access to all of them. So, what<br>
> I was thinking was that I could add a public method (virtual) to the<br>
> GDALDataset class, lets say GetSubDatasets, that would allow a dataset to<br>
> return associated subdatasets. Then, in the FASTDataset class, if I detect<br>
> that I'm trying to open a MTL file, I could make the FASTDataset::Open<br>
> method return a Dataset (as it does now) containing only the multispectral<br>
> bands and then with the overridden GetSubDatasets method I could get a<br>
> vector with the other 2 datasets: one with the panchromatic band and<br>
> another one with the thermal bands.<br>
><br>
> What do you think?<br>
><br>
> Any idea, suggestion or comment is very welcome :)<br>
><br>
> Sample:<br>
><br>
> class CPL_DLL GDALDataset : public GDALMajorObject<br>
> {<br>
> [...]<br>
> public:<br>
>     virtual GDALDataset* GetSubDatasets() { return NULL; }<br>
> [...]<br>
> }<br>
><br>
> class FASTDataset : public GDALPamDataset<br>
> {<br>
> [...]<br>
> private:<br>
>     GDALDataset* porSubDatasets;<br>
> [...]<br>
> public:<br>
>     virtual GDALDataset* GetSubDatasets();<br>
> [...]<br>
> }<br>
><br>
> GDALDataset *FASTDataset::Open( GDALOpenInfo * poOpenInfo )<br>
> {<br>
>     /**<br>
><br>
>     IF mtl<br>
>         LOAD main dataset<br>
>         LOAD subdatasets<br>
>         RETURN main dataset<br>
><br>
>     **/<br>
><br>
>     int i;<br>
><br>
>     if(poOpenInfo->nHeaderBytes < 1024)<br>
>         return NULL;<br>
><br>
> [...]<br>
> }<br>
><br>
> Thanks in advance.<br>
><br>
> Regards,<br>
> Daniel.<br>
<br>
</div></div><span class="HOEnZb"><font color="#888888">--<br>
Geospatial professional services<br>
<a href="http://even.rouault.free.fr/services.html" target="_blank">http://even.rouault.free.fr/services.html</a><br>
</font></span></blockquote></div><br></div>