home products news downloads documentation support gallery online maps resellers search
TNTmips Downloads Menu

HOME

CONTACT US

CURRENT RELEASE
  TNT 2013

DEVELOPMENT VERSION
  TNT 2014

TNTmips Pro
PRIOR RELEASES
  TNT 2012

FREE SOFTWARE
  TNTmips Free
  TNTatlas
  TNTsdk

MORE DOWNLOADS
  HASP Key Driver
  Screen Recorder
  TNT Language Kits
  Sample Geodata
  TNT Scripts

DOCUMENTATION
  TNTmips Tutorials
  Tutorial Datasets
  Technical Guides
  Scripts
  Quick Guides

MORE INFO
  Download FAQs
  FTP
  Download Managers
  Find Reseller

SITE MAP


RasterPrintXYZ5.sml


 # SML created 24 June 2004
 # Cindy Robbins
 # exports a raster to an X, Y, Z text file, formatted so each line of the
 # text file corresponds to one cell in the raster
 clear();
 raster R;
 class Georef geoR;
 class POINT2D coords;
 class FILE outFile;
 GetInputRaster(R);
 geoR = GetLastUsedGeorefObject(R);
 #outFile = GetOutputTextFile("c:/rasterToXYZ.txt", "Select text file for output", "txt");
if (fexists("c:/rasterToXYZ.txt"))
	DeleteFile("c:/rasterToXYZ.txt");
 outFile = fopen("c:/rasterToXYZ.txt", "a");
 # loop through each cell in the raster,
 # getting the cell value and writing to text file.
 numeric row, col;
 for row = 1 to R.$Info.NumLins {
     for col = 1 to R.$Info.NumCols  {
#   get the cell value
             numeric cellVal = R[row, col];
#		if (cellVal == null) cellVal = 0;    # uncomment if you want to set null value to 0.
          	coords = ObjectToMap(R,  col - .5, row - .5, geoR);
             fprintf(outFile, "%f%s%f%s%f%s", coords.x, " ", coords.y , " ", cellVal, " ");   
				 fprintf(outFile, "\n");
    }   #close 'for col...' 
}  # close 'for row...'
 
 CloseRaster(R);
print("done");

 ##########################################################################


Back Home ©MicroImages, Inc. 2013 Published in the United States of America
11th Floor - Sharp Tower, 206 South 13th Street, Lincoln NE 68508-2010   USA
Business & Sales: (402)477-9554  Support: (402)477-9562  Fax: (402)477-9559
Business info@microimages.com  Support support@microimages.com  Web webmaster@microimages.com

25 March 2009

page update: 26 May 11