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

hannesd hannes.diedrich at gfz-potsdam.de
Thu Jul 21 05:50:06 PDT 2016


Hi Even, 

thanks for your quick answer!

I have done the second suggestion you made: First made mosaik vrt files
and then performed gdalbuiltvrt -separate to merge them into a multi band
raster. 

Again two issues:
1. Is there a way to retrieve the metadata from the mosaik vrt files without
actually loading them 
into python gdal?

2. In general: I find it hard to use gdal.GetMetadataItem() and
gdal.SetMetdadatItem() or i did not get the Idea yet.

This is how my vrt file looks:
/ <VRTDataset rasterXSize="20976" rasterYSize="80982">
  <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.1000200000000000e+06,  0.0000000000000000e+00,
-1.0000000000000000e+01</GeoTransform>
  <VRTRasterBand dataType="UInt16" band="1">
    <SimpleSource>
      <SourceFilename relativeToVRT="1">20160628.vrt</SourceFilename>
      <SourceBand>1</SourceBand>
      <SourceProperties RasterXSize="20976" RasterYSize="40980"
DataType="UInt16" BlockXSize="128" BlockYSize="128" />
      <SrcRect xOff="0" yOff="0" xSize="20976" ySize="40980" />
      <DstRect xOff="0" yOff="40002" xSize="20976" ySize="40980" />
    </SimpleSource>
  </VRTRasterBand>
  <VRTRasterBand dataType="UInt16" band="2">
    <SimpleSource>
      <SourceFilename relativeToVRT="1">20160701.vrt</SourceFilename>
      <SourceBand>1</SourceBand>
      <SourceProperties RasterXSize="10980" RasterYSize="80982"
DataType="UInt16" BlockXSize="128" BlockYSize="128" />
      <SrcRect xOff="0" yOff="0" xSize="10980" ySize="80982" />
      <DstRect xOff="0" yOff="0" xSize="10980" ySize="80982" />
    </SimpleSource>
  </VRTRasterBand>
</VRTDataset>/

How can I get e.g. the value of the "SourceProperties" information?
This is what I did in Python:
ds= gdal.Open(vrtfile, gc.GA_ReadOnly )
band=ds.GetRasterBand(1)
mdi=band.GetMetadataItem("SourceProperties")

Unfortunately it returns nothing.
Of course I can read the xml file with e.g. xml.etree.ElementTree but
shouldn't it be possible with gdal as well?

Thanks again!
Hannes




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


More information about the gdal-dev mailing list