[gdal-dev] Get Metadata from VRT file, store 4D Dataset into VRT

Even Rouault even.rouault at spatialys.com
Thu Jul 14 06:47:37 PDT 2016


> 1st Question: How can I get the metadata from each band e.g. the
> "SourceFilename"?
> I tried the following:
> /band1=ds.GetRasterBand(1)
> metadata_band1=band1.GetMetadata()/
> Unfortunately, there is not output, although /gdalinfo/ (outside python)
> provides all the metadata of the vrt file.

You can get the file list with ds.GetFileList()
And if you want to get the file below a given pixel, you can do, here for pixel 

band1.GetMetadataItem('Pixel_0_0', 'LocationInfo') 

That will return something like :

> 2nd Question:
> Is there a way that I can add another dimension to the vrt file, for
> example by adding multiple products (jp2-files) to each virtual raster
> band, just like gdalbuildvrt does if the "-separate" keyword is not set?

Not sure to really understand what you mean, but the GDAL raster model is 
limited to several bands of 2D raster, so "3D". You can emulate 4D by 
flattening the extra dimensions.

But here it seems you want to do a spatial mosaic ? You could potentially do 
gdalbuildvrt in default mode to mosaic the same bands of several products, and 
then gdalbuildvrt -separate those mosaiced VRTs to make a multi band raster.


Spatialys - Geospatial professional services

More information about the gdal-dev mailing list