convertmodis_gdal module

Convert MODIS HDF file using GDAL Python bindings. It can create GeoTiff file (or other GDAL supported formats) or HDF mosaic file for several tiles.

Classes:

Functions:

class pymodis.convertmodis_gdal.convertModisGDAL(hdfname, prefix, subset, res, outformat='GTiff', epsg=None, wkt=None, resampl='NEAREST_NEIGHBOR', vrt=False)[source]

A class to convert modis data from hdf to GDAL formats using GDAL

Parameters:
  • hdfname (str) – name of input data
  • prefix (str) – prefix for output data
  • subset (str) – the subset to consider
  • res (int) – output resolution
  • outformat (str) – output format, it is possible to use all the supported GDAL format
  • epsg (int) – the EPSG code for the preojection of output file
  • wkt (str) – the WKT string for the preojection of output file
  • resampl (str) – the resampling method to use
  • vrt (bool) – True to read GDAL VRT file created with createMosaicGDAL
run(quiet=False)[source]

Reproject all the subset of chosen layer

run_vrt_separated()[source]

Reproject VRT created by createMosaicGDAL, function write_vrt with separated=True

class pymodis.convertmodis_gdal.createMosaicGDAL(hdfnames, subset, outformat='HDF4Image')[source]

A class to mosaic modis data from hdf to GDAL formats using GDAL

Parameters:
  • hdfnames (list) – a list containing the name of tile to mosaic
  • subset (str) – the subset of layer to consider
  • outformat (str) – the output format to use, this parameter is not used for the VRT output, supported values are HDF4Image, GTiff, HFA, and maybe something else not tested.
run(output, quiet=False)[source]

Create the mosaic

Parameters:output (str) – the name of output file
write_mosaic_xml(prefix)[source]

Write the XML metadata file for MODIS mosaic

Parameters:prefix (str) – the prefix for the XML file containing metadata
write_vrt(output, separate=True, quiet=False)[source]

Write VRT file

Parameters:
  • output (str) – the prefix of output file
  • separate (bool) – True to write a VRT file for each band, False to write an unique file
class pymodis.convertmodis_gdal.file_info[source]

A class holding information about a GDAL file.

Class copied from gdal_merge.py

Parameters:filename (str) – Name of file to read.
Returns:1 on success or 0 if the file can’t be opened.
copy_into(t_fh, s_band=1, t_band=1, nodata_arg=None)[source]

Copy this files image into target file.

This method will compute the overlap area of the file_info objects file, and the target gdal.Dataset object, and copy the image data for the common window area. It is assumed that the files are in a compatible projection. no checking or warping is done. However, if the destination file is a different resolution, or different image pixel type, the appropriate resampling and conversions will be done (using normal GDAL promotion/demotion rules).

Parameters:
  • t_fh – gdal.Dataset object for the file into which some or all of this file may be copied.
  • s_band
  • t_band
  • nodata_arg
Returns:

1 on success (or if nothing needs to be copied), and zero one failure.

init_from_name(filename)[source]

Initialize file_info from filename

pymodis.convertmodis_gdal.getResampling(res)[source]

Return the GDAL resampling method

Parameters:res (str) – the string of resampling method
pymodis.convertmodis_gdal.raster_copy(s_fh, s_xoff, s_yoff, s_xsize, s_ysize, s_band_n, t_fh, t_xoff, t_yoff, t_xsize, t_ysize, t_band_n, nodata=None)[source]

Copy a band of raster into the output file.

Function copied from gdal_merge.py

pymodis.convertmodis_gdal.raster_copy_with_nodata(s_fh, s_xoff, s_yoff, s_xsize, s_ysize, s_band_n, t_fh, t_xoff, t_yoff, t_xsize, t_ysize, t_band_n, nodata)[source]

Copy a band of raster into the output file with nodata values.

Function copied from gdal_merge.py