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

hannes.diedrich at gfz-potsdam.de hannes.diedrich at gfz-potsdam.de
Thu Jul 14 03:05:15 PDT 2016


Hello,

I just started to use virtual raster bands with gdal (python) and have two
questions (see below).
My aim: I like to manage Sentinel 2 data with VRB preferably in an 4D
environment (x,y,time, spectral band)

This is what I have done so far:
I managed to build a vrt file by adding multiple 
jpg2000 files (Sentinel 2 L1C data) to a VRT file with:

/gdalbuildvrt -separate -input_file_list list.list vrt.vrt/

The vrt file looks like:
-------------------------------------------------------------------------------------
<VRTDataset rasterXSize="10980" rasterYSize="10980">
  <SRS>PROJCS["WGS 84 / UTM zone 32N",GEOGCS["WGS
84",DATUM["WGS_1984",SPHEROID["WGS
84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",9],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","32632"]]</SRS>
  <GeoTransform>  6.0000000000000000e+05,  1.0000000000000000e+01, 
0.0000000000000000e+00,  6.0000000000000000e+06,  0.0000000000000000e+00,
-1.0000000000000000e+01</GeoTransform>
  <VRTRasterBand dataType="UInt16" band="1">
    <SimpleSource>
      <SourceFilename
relativeToVRT="0">/misc/fluo10/Sentinel2_L1C/32U/PE/2016/S2A_OPER_MSI_L1C_TL_SGS__20160113T143043_A002922_T32UPE_N02.01/B02.jp2</SourceFilename>
      <SourceBand>1</SourceBand>
      <SourceProperties RasterXSize="10980" RasterYSize="10980"
DataType="UInt16" BlockXSize="2048" BlockYSize="128" />
      <SrcRect xOff="0" yOff="0" xSize="10980" ySize="10980" />
      <DstRect xOff="0" yOff="0" xSize="10980" ySize="10980" />
    </SimpleSource>
  </VRTRasterBand>
  <VRTRasterBand dataType="UInt16" band="2">
    <SimpleSource>
      <SourceFilename
relativeToVRT="0">/misc/fluo10/Sentinel2_L1C/32U/PE/2016/S2A_OPER_MSI_L1C_TL_SGS__20160614T154940_A005110_T32UPE_N02.02/B02.jp2</SourceFilename>
      <SourceBand>1</SourceBand>
      <SourceProperties RasterXSize="10980" RasterYSize="10980"
DataType="UInt16" BlockXSize="2048" BlockYSize="128" />
      <SrcRect xOff="0" yOff="0" xSize="10980" ySize="10980" />
      <DstRect xOff="0" yOff="0" xSize="10980" ySize="10980" />
    </SimpleSource>
  </VRTRasterBand>
-----------------------------------------------------------------

In python i've done the following:

/import gdal
import gdalconst as gc
dataset = gdal.Open("vrt.vrt", gc.GA_ReadOnly )
array=dataset.GetVirtualMemArray()
/

array is a 3D-array that fetches the data of all files for my wanted subset
e.g. subset =array[*,100:110,2:5]
So far so good.

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.

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?

Thanks in advance!
Hannes



--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Get-Metadata-from-VRT-file-store-4D-Dataset-into-VRT-tp5276331.html
Sent from the GDAL - Dev mailing list archive at Nabble.com.


More information about the gdal-dev mailing list