[gdal-dev] Extracting band from raster stack & ENVI Header question

Markus Reinhold markus.reinhold at uni-jena.de
Mon Aug 24 18:06:39 EDT 2009


Hejhej,
please allow me two short questions:
1) Using the GDAL Python bindings I currently need to extract a single 
band from a raster stack and save it in a different format, i.e. ENVI. 
To achieve this my processing includes
(a) analysis of the source dataset and desired band (width, height, 
pixel size, data type, geotransform),
(b) creation of a temporary in-memory dataset with one band (using 
Driver.Create()) that is identical with the desired source band except 
that it is all black and
(c) creation of a copy of the temporary dataset (using 
Driver.CreateCopy()) and setting it according to the original data 
(using RasterBand.ReadAsArray() and RasterBand.WriteArray()).
I found the second step necessary as for ENVI data it is only possible 
to create datasets using Driver.CreateCopy() for which a template is 
needed - hence the temporary single band dataset... My solution works, I 
find it a bit awkward though. Is there a simpler way to do this?
2) Another question concerning the creation of ENVI datasets with GDAL. 
I had been under the impression that *map info* strings for the ENVI 
header weren't created when copying another dataset. Now I have found 
that when the dataset is in a certain projection and coordinate system, 
i.e. UTM/WGS84 in my case, this is done after all. Is there any rule for 
which configurations GDAL is able to create a *map info*-section in the 
ENVI header?
Thank you very much in advance.
Regards,
Markus

-- 

********************************************************
Dipl.-Kartograph Markus Reinhold

Chair of Geoinformatics, Geohydrology and Modeling
Friedrich-Schiller-University Jena
Löbdergraben 32
D - 07743 Jena
Germany

Phone.: (+49)(0)3641 / 9 488 65
E-Mail: markus.reinhold at uni-jena.de
********************************************************


More information about the gdal-dev mailing list