Thanks but I don't have that module installed :(<div>What I mean was to run gdalinfo directly and have a variable to store the result from gdalinfo...<br><br></div><div>By the way, where can I find that python module (osgeo)?</div>
<div><br><div class="gmail_quote">2010/2/25 Νίκος Αλεξανδρής <span dir="ltr"><<a href="mailto:nikos.alexandris@felis.uni-freiburg.de">nikos.alexandris@felis.uni-freiburg.de</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><div></div><div class="h5">On Thu, 2010-02-25 at 17:26 +0000, Jose Gomez-Dans wrote:<br>
> Hi,<br>
><br>
> On 25 February 2010 16:32, Nikos Dumakis <<a href="mailto:nikosdu1980@gmail.com">nikosdu1980@gmail.com</a>><br>
> wrote:<br>
> I'm doing/trying a Python Script to retrieve MODIS subset<br>
> names using GDALinfo.<br>
> 1- is there any Script already developed in GRASS- python to<br>
> retrieve subset names using GDALINFO<br>
> 2- If not, how can I store in a variable the result from<br>
> GDALinfo?<br>
><br>
> It's quite easy to do this with the GDAL python bindings (presumably<br>
> installed if you bothered to install gdalinfo). GetSubDatasets()<br>
> returns a list where each element is the dataset name and the<br>
> description<br>
><br>
> hands on example ;)<br>
><br>
> In [1]: from osgeo import gdal<br>
><br>
> In [2]: g=gdal.Open("MOD09GA.A2009270.h21v10.005.2009272135254.hdf")<br>
><br>
> In [3]: g.GetSubDatasets()<br>
><br>
> Out[3]:<br>
> [('HDF4_EOS:EOS_GRID:"MOD09GA.A2009270.h21v10.005.2009272135254.hdf":MODIS_Grid_1km_2D:num_observations_1km',<br>
> '[1200x1200] num_observations_1km MODIS_Grid_1km_2D (8-bit<br>
> integer)'),<br>
> ('HDF4_EOS:EOS_GRID:"MOD09GA.A2009270.h21v10.005.2009272135254.hdf":MODIS_Grid_1km_2D:state_1km_1',<br>
> '[1200x1200] state_1km_1 MODIS_Grid_1km_2D (16-bit unsigned<br>
> integer)'),<br>
> ('HDF4_EOS:EOS_GRID:"MOD09GA.A2009270.h21v10.005.2009272135254.hdf":MODIS_Grid_1km_2D:SensorZenith_1',<br>
> '[1200x1200] SensorZenith_1 MODIS_Grid_1km_2D (16-bit integer)'),<br>
> ('HDF4_EOS:EOS_GRID:"MOD09GA.A2009270.h21v10.005.2009272135254.hdf":MODIS_Grid_1km_2D:SensorAzimuth_1',<br>
> '[1200x1200] SensorAzimuth_1 MODIS_Grid_1km_2D (16-bit integer)'),<br>
> ('HDF4_EOS:EOS_GRID:"MOD09GA.A2009270.h21v10.005.2009272135254.hdf":MODIS_Grid_1km_2D:Range_1',<br>
> '[1200x1200] Range_1 MODIS_Grid_1km_2D (16-bit unsigned integer)'),<br>
> ('HDF4_EOS:EOS_GRID:"MOD09GA.A2009270.h21v10.005.2009272135254.hdf":MODIS_Grid_1km_2D:SolarZenith_1',<br>
> '[1200x1200] SolarZenith_1 MODIS_Grid_1km_2D (16-bit integer)'),<br>
> ('HDF4_EOS:EOS_GRID:"MOD09GA.A2009270.h21v10.005.2009272135254.hdf":MODIS_Grid_1km_2D:SolarAzimuth_1',<br>
> '[1200x1200] SolarAzimuth_1 MODIS_Grid_1km_2D (16-bit integer)'),<br>
> ('HDF4_EOS:EOS_GRID:"MOD09GA.A2009270.h21v10.005.2009272135254.hdf":MODIS_Grid_1km_2D:gflags_1',<br>
> '[1200x1200] gflags_1 MODIS_Grid_1km_2D (8-bit unsigned integer)'),<br>
> ('HDF4_EOS:EOS_GRID:"MOD09GA.A2009270.h21v10.005.2009272135254.hdf":MODIS_Grid_1km_2D:orbit_pnt_1',<br>
> '[1200x1200] orbit_pnt_1 MODIS_Grid_1km_2D (8-bit integer)'),<br>
> ('HDF4_EOS:EOS_GRID:"MOD09GA.A2009270.h21v10.005.2009272135254.hdf":MODIS_Grid_500m_2D:num_observations_500m',<br>
> '[2400x2400] num_observations_500m MODIS_Grid_500m_2D (8-bit<br>
> integer)'),<br>
> ('HDF4_EOS:EOS_GRID:"MOD09GA.A2009270.h21v10.005.2009272135254.hdf":MODIS_Grid_500m_2D:sur_refl_b01_1',<br>
> '[2400x2400] sur_refl_b01_1 MODIS_Grid_500m_2D (16-bit integer)'),<br>
> ('HDF4_EOS:EOS_GRID:"MOD09GA.A2009270.h21v10.005.2009272135254.hdf":MODIS_Grid_500m_2D:sur_refl_b02_1',<br>
> '[2400x2400] sur_refl_b02_1 MODIS_Grid_500m_2D (16-bit integer)'),<br>
> ('HDF4_EOS:EOS_GRID:"MOD09GA.A2009270.h21v10.005.2009272135254.hdf":MODIS_Grid_500m_2D:sur_refl_b03_1',<br>
> '[2400x2400] sur_refl_b03_1 MODIS_Grid_500m_2D (16-bit integer)'),<br>
> ('HDF4_EOS:EOS_GRID:"MOD09GA.A2009270.h21v10.005.2009272135254.hdf":MODIS_Grid_500m_2D:sur_refl_b04_1',<br>
> '[2400x2400] sur_refl_b04_1 MODIS_Grid_500m_2D (16-bit integer)'),<br>
> ('HDF4_EOS:EOS_GRID:"MOD09GA.A2009270.h21v10.005.2009272135254.hdf":MODIS_Grid_500m_2D:sur_refl_b05_1',<br>
> '[2400x2400] sur_refl_b05_1 MODIS_Grid_500m_2D (16-bit integer)'),<br>
> ('HDF4_EOS:EOS_GRID:"MOD09GA.A2009270.h21v10.005.2009272135254.hdf":MODIS_Grid_500m_2D:sur_refl_b06_1',<br>
> '[2400x2400] sur_refl_b06_1 MODIS_Grid_500m_2D (16-bit integer)'),<br>
> ('HDF4_EOS:EOS_GRID:"MOD09GA.A2009270.h21v10.005.2009272135254.hdf":MODIS_Grid_500m_2D:sur_refl_b07_1',<br>
> '[2400x2400] sur_refl_b07_1 MODIS_Grid_500m_2D (16-bit integer)'),<br>
> ('HDF4_EOS:EOS_GRID:"MOD09GA.A2009270.h21v10.005.2009272135254.hdf":MODIS_Grid_500m_2D:QC_500m_1',<br>
> '[2400x2400] QC_500m_1 MODIS_Grid_500m_2D (32-bit unsigned<br>
> integer)'),<br>
> ('HDF4_EOS:EOS_GRID:"MOD09GA.A2009270.h21v10.005.2009272135254.hdf":MODIS_Grid_500m_2D:obscov_500m_1',<br>
> '[2400x2400] obscov_500m_1 MODIS_Grid_500m_2D (8-bit integer)'),<br>
> ('HDF4_EOS:EOS_GRID:"MOD09GA.A2009270.h21v10.005.2009272135254.hdf":MODIS_Grid_500m_2D:iobs_res_1',<br>
> '[2400x2400] iobs_res_1 MODIS_Grid_500m_2D (8-bit unsigned<br>
> integer)'),<br>
> ('HDF4_EOS:EOS_GRID:"MOD09GA.A2009270.h21v10.005.2009272135254.hdf":MODIS_Grid_500m_2D:q_scan_1',<br>
> '[2400x2400] q_scan_1 MODIS_Grid_500m_2D (8-bit unsigned integer)')<br>
><br>
<br>
</div></div>(You are too fast Jose ;-)<br>
<br>
I have also something in bash (just in case...).<br>
Regards, Nikos Al.<br>
<br>
</blockquote></div><br></div>