[GRASS-user] Retrieving Subsets names from gdalinfo with Python

Jose Gomez-Dans jgomezdans at gmail.com
Thu Feb 25 12:26:59 EST 2010


Hi,

On 25 February 2010 16:32, Nikos Dumakis <nikosdu1980 at gmail.com> wrote:

> I'm doing/trying a Python Script to retrieve MODIS subset names using
> GDALinfo.
> 1- is there any Script already developed in GRASS- python to retrieve
> subset names using GDALINFO
> 2- If not, how can I store in a variable the result from GDALinfo?
>

It's quite easy to do this with the GDAL python bindings (presumably
installed if you bothered to install gdalinfo). GetSubDatasets() returns a
list where each element is the dataset name and the description

hands on example ;)

 In [1]: from osgeo import gdal

In [2]: g=gdal.Open("MOD09GA.A2009270.h21v10.005.2009272135254.hdf")

In [3]: g.GetSubDatasets()

Out[3]:
[('HDF4_EOS:EOS_GRID:"MOD09GA.A2009270.h21v10.005.2009272135254.hdf":MODIS_Grid_1km_2D:num_observations_1km',
  '[1200x1200] num_observations_1km MODIS_Grid_1km_2D (8-bit integer)'),
 ('HDF4_EOS:EOS_GRID:"MOD09GA.A2009270.h21v10.005.2009272135254.hdf":MODIS_Grid_1km_2D:state_1km_1',
  '[1200x1200] state_1km_1 MODIS_Grid_1km_2D (16-bit unsigned integer)'),
 ('HDF4_EOS:EOS_GRID:"MOD09GA.A2009270.h21v10.005.2009272135254.hdf":MODIS_Grid_1km_2D:SensorZenith_1',
  '[1200x1200] SensorZenith_1 MODIS_Grid_1km_2D (16-bit integer)'),
 ('HDF4_EOS:EOS_GRID:"MOD09GA.A2009270.h21v10.005.2009272135254.hdf":MODIS_Grid_1km_2D:SensorAzimuth_1',
  '[1200x1200] SensorAzimuth_1 MODIS_Grid_1km_2D (16-bit integer)'),
 ('HDF4_EOS:EOS_GRID:"MOD09GA.A2009270.h21v10.005.2009272135254.hdf":MODIS_Grid_1km_2D:Range_1',
  '[1200x1200] Range_1 MODIS_Grid_1km_2D (16-bit unsigned integer)'),
 ('HDF4_EOS:EOS_GRID:"MOD09GA.A2009270.h21v10.005.2009272135254.hdf":MODIS_Grid_1km_2D:SolarZenith_1',
  '[1200x1200] SolarZenith_1 MODIS_Grid_1km_2D (16-bit integer)'),
 ('HDF4_EOS:EOS_GRID:"MOD09GA.A2009270.h21v10.005.2009272135254.hdf":MODIS_Grid_1km_2D:SolarAzimuth_1',
  '[1200x1200] SolarAzimuth_1 MODIS_Grid_1km_2D (16-bit integer)'),
 ('HDF4_EOS:EOS_GRID:"MOD09GA.A2009270.h21v10.005.2009272135254.hdf":MODIS_Grid_1km_2D:gflags_1',
  '[1200x1200] gflags_1 MODIS_Grid_1km_2D (8-bit unsigned integer)'),
 ('HDF4_EOS:EOS_GRID:"MOD09GA.A2009270.h21v10.005.2009272135254.hdf":MODIS_Grid_1km_2D:orbit_pnt_1',
  '[1200x1200] orbit_pnt_1 MODIS_Grid_1km_2D (8-bit integer)'),
 ('HDF4_EOS:EOS_GRID:"MOD09GA.A2009270.h21v10.005.2009272135254.hdf":MODIS_Grid_500m_2D:num_observations_500m',
  '[2400x2400] num_observations_500m MODIS_Grid_500m_2D (8-bit integer)'),
 ('HDF4_EOS:EOS_GRID:"MOD09GA.A2009270.h21v10.005.2009272135254.hdf":MODIS_Grid_500m_2D:sur_refl_b01_1',
  '[2400x2400] sur_refl_b01_1 MODIS_Grid_500m_2D (16-bit integer)'),
 ('HDF4_EOS:EOS_GRID:"MOD09GA.A2009270.h21v10.005.2009272135254.hdf":MODIS_Grid_500m_2D:sur_refl_b02_1',
  '[2400x2400] sur_refl_b02_1 MODIS_Grid_500m_2D (16-bit integer)'),
 ('HDF4_EOS:EOS_GRID:"MOD09GA.A2009270.h21v10.005.2009272135254.hdf":MODIS_Grid_500m_2D:sur_refl_b03_1',
  '[2400x2400] sur_refl_b03_1 MODIS_Grid_500m_2D (16-bit integer)'),
 ('HDF4_EOS:EOS_GRID:"MOD09GA.A2009270.h21v10.005.2009272135254.hdf":MODIS_Grid_500m_2D:sur_refl_b04_1',
  '[2400x2400] sur_refl_b04_1 MODIS_Grid_500m_2D (16-bit integer)'),
 ('HDF4_EOS:EOS_GRID:"MOD09GA.A2009270.h21v10.005.2009272135254.hdf":MODIS_Grid_500m_2D:sur_refl_b05_1',
  '[2400x2400] sur_refl_b05_1 MODIS_Grid_500m_2D (16-bit integer)'),
 ('HDF4_EOS:EOS_GRID:"MOD09GA.A2009270.h21v10.005.2009272135254.hdf":MODIS_Grid_500m_2D:sur_refl_b06_1',
  '[2400x2400] sur_refl_b06_1 MODIS_Grid_500m_2D (16-bit integer)'),
 ('HDF4_EOS:EOS_GRID:"MOD09GA.A2009270.h21v10.005.2009272135254.hdf":MODIS_Grid_500m_2D:sur_refl_b07_1',
  '[2400x2400] sur_refl_b07_1 MODIS_Grid_500m_2D (16-bit integer)'),
 ('HDF4_EOS:EOS_GRID:"MOD09GA.A2009270.h21v10.005.2009272135254.hdf":MODIS_Grid_500m_2D:QC_500m_1',
  '[2400x2400] QC_500m_1 MODIS_Grid_500m_2D (32-bit unsigned integer)'),
 ('HDF4_EOS:EOS_GRID:"MOD09GA.A2009270.h21v10.005.2009272135254.hdf":MODIS_Grid_500m_2D:obscov_500m_1',
  '[2400x2400] obscov_500m_1 MODIS_Grid_500m_2D (8-bit integer)'),
 ('HDF4_EOS:EOS_GRID:"MOD09GA.A2009270.h21v10.005.2009272135254.hdf":MODIS_Grid_500m_2D:iobs_res_1',
  '[2400x2400] iobs_res_1 MODIS_Grid_500m_2D (8-bit unsigned integer)'),
 ('HDF4_EOS:EOS_GRID:"MOD09GA.A2009270.h21v10.005.2009272135254.hdf":MODIS_Grid_500m_2D:q_scan_1',
  '[2400x2400] q_scan_1 MODIS_Grid_500m_2D (8-bit unsigned integer)')]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/grass-user/attachments/20100225/21c12a76/attachment.html


More information about the grass-user mailing list