====== Scripts > ClipGeotTiffAndExportAsBmp ====== ^ Description | A script to import a GeoTIFF heightfield, clip the altitude range, and then export as a greyscale bitmap. | ^ Author | [[user>Aaron]] | ^ Created | 2010/05/24 | ^ Requires | L3DT 11.07 beta 2 or later | ^ Download | {{:scripts:clipgeotiffandexportasbmp.zs|ClipGeotTiffAndExportAsBmp.zs}} | ===== Script contents ===== // Author: A. Torpy // Updated: 14 Jul 2011 // create and initialise a file selector filesel FS filesel.Init &FS true NULL "GeoTIFF files (*.tif)|*.tif|All files (*.*)|*.*|" "tif" NULL // ask user for input filename using file selector if > echo "Script aborted by user" return false endif // load the map file map InputHF if 20 true true>> echo "Cannot load file" return false endif // get the map size int nx ny set nx set ny if > echo "Invalid map size" return false endif // prepare a coordinate list for user to edit varlist ls int ls.x1 ls.x2 ls.y1 ls.y2 set ls.x1 0 set ls.x2 set ls.y1 0 set ls.y2 // edit coordinate list if > echo "Script aborted by user" return false endif // retrieve coordinates from list (for shorthand) int x1 x2 y1 y2 set x1 ls.x1 set x2 ls.x2 set y1 ls.y1 set y2 ls.y2 // validate coordinates assert >>> "Invalid x1 coordinate" assert >>> "Invalid x2 coordinate" assert >>> "Invalid y1 coordinate" assert >>> "Invalid y2 coordinate" assert > "Invalid coordinates: x1>x2" assert > "Invalid coordinates: y1>y2" // get output map size int cx cy set cx 1> set cy 1> // initialise output map map OutputHF //if > // echo "Cannot initialise heightfield" // return false //endif if > echo "Invalid map size" return false endif // re-initialise file selector filesel.Init &FS false NULL "Bitmap images (*.bmp)|*.bmp|All files (*.*)|*.*|" "bmp" NULL // ask user for output filename using file selector if > echo "Script aborted by user" return false endif if false true>> echo "Cannot save heightfield" return false endif MessageBox "Success!" 0x40 return true ===== Comments ===== None.