Geoscience Reference
In-Depth Information
//create virtual dataset as copy from input dataset
GDALDriver *poVRTDriver;
poVRTDriver = GetGDALDriverManager()->GetDriverByName("VRT");
GDALDataset *poVRTDataset;
//use empty filename to create in memory only
poVRTDataset = poVRTDriver->CreateCopy("", poSrcDataset,
FALSE, NULL, NULL, NULL);
//set the color table to the first raster band
poVRTDataset->GetRasterBand(1)->SetColorTable(&oColorTable);
GDALDriver *poDriver;
poDriver = GetGDALDriverManager()->GetDriverByName(stlsFormat.c_str())
;
//possibility to define some extra create options here...
char **papszOptions = NULL;
//create new data for output
poDataset = poDriver->CreateCopy(stlsDestImageFilename.c_str(),
poVRTDataset,
FALSE, papszOptions, NULL, NULL);
//clean up
CSLDestroy(papszOptions);
//close the read only dataset (must have been opened in
shared mode)
GDALClose((GDALDataset*) poSrcDataset);
GDALClose((GDALDataset*) poVRTDataset);
}
To illustrate the final version of our utility, we will add a color table to the first
subdataset in an HDF4 file and generate a PNG formatted output file. As input, we
use the land cover product fromMODIS (MCD12Q1) from Sect. 3.3 . Notice that we
cannot use the first two versions of our utility, because both the HDF4 and the PNG
format cannot be opened in GA_Update mode.
The first subdataset values consists of 16 classes using the nomenclature of the
international geosphere-biospshere program (IGBP). 22 We create the ASCII text,
modis_ct.txt with the following color table:
0 0 204 242 255
1 0 166 0 255
2 128 255 0 255
3 50 166 50 255
4 178 255 50 255
5 77 255 0 255
6 166 242 0 255
7 216 242 50 255
8 230 230 255 255
9 77 77 255 255
10 204 242 77 255
11 166 166 255 255
12 255 230 166 255
13 230 0 77 255
14 166 255 128 255
15 166 230 204 255
16 204 255 204 255
22 https://lpdaac.usgs.gov/products/modis_products_table/mcd12q1
 
 
Search WWH ::




Custom Search