#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int main(int argc, char* argv[]) { if(argc != 4){cout<<"wrong arguments. need file"<GetDriverByName("GTiff"); if( OUTDRIVER == NULL ) {cout << "no driver" << endl; exit( 1 );}; oSRS.SetWellKnownGeogCS( "WGS84" ); oSRS.SetUTM( zone, TRUE ); oSRS.exportToWkt( &OUTPRJ ); papszOptions = CSLSetNameValue( papszOptions, "COMPRESS", "LZW"); double GeoTransform[6]; int i, k, j, x, y, xloc, yloc; double sum, count; int mean, std, newmin, newmax, val; //arrays int xsize=(15*2+1)*(30/0.5); int ysize =(15*2+1)*(30/0.5); string filename = "/gpfs/glad3/HLSDIST/Validation/LandCoverBased/thumbs/NS1S2_v2/"+id+"/"+file+"_temp.tif"; //cout<GetGeoTransform(GeoTransform); //int xsize=INBAND->GetXSize(); //if(xsize != (15+3)*10){cout<<(int)xsize<<"wrong size"<<(15+3)*10<GetYSize(); //if(ysize != (15+3)*10){cout<GetRasterBand(1); if(INBAND==NULL){cout << "band not found" << endl; exit(1);} INBAND->RasterIO(GF_Read, 0, 0, xsize, ysize, bands[0], xsize, ysize, GDT_Byte, 0, 0); INBAND = INGDAL->GetRasterBand(2); if(INBAND==NULL){cout << "band not found" << endl; exit(1);} INBAND->RasterIO(GF_Read, 0, 0, xsize, ysize, bands[1], xsize, ysize, GDT_Byte, 0, 0); INBAND = INGDAL->GetRasterBand(3); if(INBAND==NULL){cout << "band not found" << endl; exit(1);} INBAND->RasterIO(GF_Read, 0, 0, xsize, ysize, bands[2], xsize, ysize, GDT_Byte, 0, 0); GDALClose(INGDAL); //cout<=15*(30/0.5)-1 and x<=(15+1)*(30/0.5))) or ((y>=15*(30/0.5)-1 and y<=(15+1)*(30/0.5)) and (x==15*(30/0.5)-2 or x==15*(30/0.5)-1 or x==(15+1)*(30/0.5) or x==15*(30/0.5) or x==(15+1)*(30/0.5)-1 or x==(15+1)*(30/0.5)+1))){ bands[0][y][x]=255; bands[1][y][x]=255; bands[2][y][x]=0; } //if((y>=(15)*20-1 and y<=(15+3)*20 and y%3==0) and (x==(15+1)*20-1 or x==(15+2)*20 or x==(15+1)*20 or x==(15+2)*20-1)){ //bands[0][y][x]=255; //bands[1][y][x]=0; //bands[2][y][x]=0; //} //if((x>=(15)*20-1 and x<=(15+3)*20 and x%3==0) and (y==(15+1)*20-1 or y==(15+2)*20 or y==(15+1)*20 or y==(15+2)*20-1)){ //bands[0][y][x]=255; //bands[1][y][x]=0; //bands[2][y][x]=0; //} }} filename = "/gpfs/glad3/HLSDIST/Validation/LandCoverBased/thumbs/NS1S2_v2/"+id+"/"+file+"_temp3.tif"; OUTGDAL = OUTDRIVER->Create(filename.c_str(), xsize, ysize, 3, GDT_Byte, papszOptions ); OUTGDAL->SetGeoTransform(GeoTransform); OUTGDAL->SetProjection(OUTPRJ); OUTBAND = OUTGDAL->GetRasterBand(1); OUTBAND->RasterIO( GF_Write, 0, 0, xsize, ysize, bands[0], xsize, ysize, GDT_Byte, 0, 0 ); OUTBAND = OUTGDAL->GetRasterBand(2); OUTBAND->RasterIO( GF_Write, 0, 0, xsize, ysize, bands[1], xsize, ysize, GDT_Byte, 0, 0 ); OUTBAND = OUTGDAL->GetRasterBand(3); OUTBAND->RasterIO( GF_Write, 0, 0, xsize, ysize, bands[2], xsize, ysize, GDT_Byte, 0, 0 ); GDALClose((GDALDatasetH)OUTGDAL); return(0); }